1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// === m1nd-mcp CLI argument parsing ===
//
// Clap derive struct for m1nd-mcp binary modes.
// Replaces manual std::env::args() parsing in main.rs.
use clap::Parser;
#[derive(Parser, Debug)]
#[command(name = "m1nd-mcp", about = "Neuro-symbolic connectome engine", version)]
pub struct Cli {
/// Start HTTP server with embedded web UI
#[arg(long)]
pub serve: bool,
/// HTTP server port
#[arg(long, default_value = "1337")]
pub port: u16,
/// Bind address override (default: 127.0.0.1). Use 0.0.0.0 for network access.
#[arg(long, default_value = "127.0.0.1")]
pub bind: String,
/// Serve frontend from disk instead of embedded (dev mode)
#[arg(long)]
pub dev: bool,
/// Also run JSON-RPC stdio server alongside HTTP
#[arg(long)]
pub stdio: bool,
/// Auto-open browser on startup
#[arg(long)]
pub open: bool,
/// Path to config JSON file
#[arg(long)]
pub config: Option<String>,
/// Graph source path override
#[arg(long)]
pub graph: Option<String>,
/// Plasticity state path override
#[arg(long)]
pub plasticity: Option<String>,
/// Runtime directory override for instance sidecar state
#[arg(long)]
pub runtime_dir: Option<String>,
/// Global registry directory override
#[arg(long)]
pub registry_dir: Option<String>,
/// Domain: code, music, memory, generic
#[arg(long, default_value = "code")]
pub domain: String,
/// Disable auto-launching the HTTP GUI in stdio mode (for CI, headless servers)
#[arg(long)]
pub no_gui: bool,
/// Path to event log file (append-only JSON lines). Enables cross-process SSE via file bus.
#[arg(long)]
pub event_log: Option<String>,
/// Watch an event log file and broadcast new events via SSE (HTTP-only mode).
/// Use when a separate stdio process writes events to this file.
#[arg(long)]
pub watch_events: Option<String>,
/// Attach read-only: load the snapshot and serve queries, but never write to
/// disk and never take an exclusive lease. Mutation tools are disabled.
/// Also honored via env `M1ND_READ_ONLY=1`.
#[arg(long)]
pub read_only: bool,
/// Attach to a running `--serve` owner as a thin stdio↔HTTP MCP bridge.
/// Takes the owner's base URL (e.g. `http://127.0.0.1:1337`), or the literal
/// `auto` to auto-discover the live serve ReadWrite owner for this client's
/// runtime_root via the instance registry (read-only, NO lease). The env var
/// `M1ND_ATTACH_URL`, when set, overrides both and wins. The bridge loads NO
/// graph, builds NO engines, and takes NO lease: it speaks stdio MCP to the
/// host (Claude Code), forwards every JSON-RPC frame to the owner's
/// `POST /mcp`, and relays the owner's server→client SSE push notifications
/// (`notifications/m1nd/graph_changed`) back to stdout. Multiple `--attach`
/// clients pointed at one owner share that owner's single live graph.
/// Requires the `serve` feature.
#[arg(long)]
pub attach: Option<String>,
}