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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
use super::ToolArgs;
use crate::cli::commands::kill::KillArgs;
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser, Debug)]
pub struct McpArgs {
#[command(subcommand)]
pub cmd: McpSub,
}
#[derive(Subcommand, Debug)]
pub enum McpSub {
/// Wrap an MCP server process
Wrap(McpWrapArgs),
/// Detect config path and generate setup
ConfigPath(ConfigPathArgs),
/// Discover MCP servers on this machine
Discover(DiscoverArgs),
/// Emit the assay.mcp_server_inventory.v0 carrier (coverage-honest, hashed command/args)
Inventory(InventoryArgs),
/// Kill or terminate MCP server processes
Kill(KillArgs),
/// Sign and verify MCP tool definitions
Tool(ToolArgs),
/// Check whether assay-mcp-server on PATH can start with this policy root
Preflight(PreflightArgs),
/// Review and explicitly promote observed MCP manifests
Manifest(ManifestArgs),
}
#[derive(Parser, Debug)]
pub struct ManifestArgs {
#[command(subcommand)]
pub cmd: ManifestSub,
}
#[derive(Subcommand, Debug)]
pub enum ManifestSub {
/// Export a non-approved candidate from a complete observed manifest
Candidate {
#[arg(long)]
from_observed: PathBuf,
#[arg(long)]
out: PathBuf,
},
/// Promote a reviewed candidate after rereading its exact observed source
Promote {
#[arg(long)]
candidate: PathBuf,
#[arg(long)]
source: PathBuf,
#[arg(long)]
out: PathBuf,
},
}
#[derive(ValueEnum, Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum PreflightFormat {
#[default]
Terminal,
Json,
}
#[derive(Parser, Clone, Debug)]
pub struct PreflightArgs {
/// Directory the host would pass as --policy-root. Must exist and be a directory.
#[arg(long, default_value = ".")]
pub policy_root: PathBuf,
/// Report format
#[arg(long, value_enum, default_value_t = PreflightFormat::Terminal)]
pub format: PreflightFormat,
}
#[derive(Parser, Clone, Debug)]
pub struct ConfigPathArgs {
/// Client to configure: claude|cursor
pub client: String,
/// Policy path to include in config
#[arg(long)]
pub policy: Option<String>,
/// Wrapped server config (command)
#[arg(long)]
pub server: Option<String>,
/// Output JSON only
#[arg(long)]
pub json: bool,
}
#[derive(clap::Args, Debug, Clone)]
pub struct SetupArgs {
/// Dry run: show what would be installed but do not make changes (default)
#[arg(long, default_value_t = true)]
pub dry_run: bool,
/// Apply changes: actually perform installation (may require sudo)
#[arg(long, conflicts_with = "dry_run")]
pub apply: bool,
/// Install helper binary from this local path (e.g. target/release/assay-bpf)
#[arg(long)]
pub helper_from: Option<PathBuf>,
/// Installation prefix for binary (default: /usr/local/bin)
#[arg(long, default_value = "/usr/local/bin")]
pub prefix: PathBuf,
/// Runtime directory for socket (default: /run/assay)
#[arg(long, default_value = "/run/assay")]
pub runtime_dir: PathBuf,
/// Hidden alias for the top-level `--non-interactive` posture (for
/// CI/automation). Kept so existing `assay setup --non-interactive`
/// invocations keep parsing; it feeds the same fail-closed posture as the
/// top-level flag. Prefer the top-level flag (see `describe` posture).
#[arg(long, hide = true)]
pub non_interactive: bool,
}
#[derive(Parser, Clone, Debug)]
pub struct McpWrapArgs {
/// Policy file (default: assay.yaml)
#[arg(long, default_value = "assay.yaml")]
pub policy: PathBuf,
/// Log decisions but do not block
#[arg(long)]
pub dry_run: bool,
/// Print decisions to stderr
#[arg(long)]
pub verbose: bool,
/// Unique label for this server (used for tool identity)
#[arg(long)]
pub label: Option<String>,
/// Write tool-call policy decision summaries to this NDJSON log.
/// Requires --event-source. This is distinct from the structured CloudEvents decision log.
#[arg(long, requires = "event_source")]
pub audit_log: Option<PathBuf>,
/// Write tool decision events (assay.tool.decision) to this NDJSON log.
/// Requires --event-source.
#[arg(long, requires = "event_source")]
pub decision_log: Option<PathBuf>,
/// Require --decision-log to be a new file: refuse an existing path or alias and create it
/// with mode 0600 on Unix, so the log holds only this run's events. Without it, an existing log is
/// appended to. Not tamper evidence: the file stays writable by its owner.
#[arg(long, requires = "decision_log")]
pub decision_log_new: bool,
/// Write one startup-context CloudEvent to a new, separate file (never a decision log).
/// Records enforcement mode and an argv digest, not executable identity or execution proof.
#[arg(long, value_name = "PATH", requires = "event_source")]
pub session_context_out: Option<PathBuf>,
/// EXPERIMENTAL: retain private bounded request-to-decision receipts in a new file.
/// Caller-asserted metadata only; not execution proof or incident source admission.
#[arg(long, value_name = "PATH", requires = "decision_log")]
pub request_receipts_out: Option<PathBuf>,
/// Generate a coverage_report_v1 from wrap decision events at session end.
/// Requires --event-source. If --decision-log is omitted, a temporary decision log is used.
#[arg(long, requires = "event_source")]
pub coverage_out: Option<PathBuf>,
/// Write a session_state_window_v1 informational report after the wrapped MCP session completes.
#[arg(long, requires = "event_source")]
pub state_window_out: Option<PathBuf>,
/// CloudEvents source URI (e.g. assay://org/app).
/// Must be absolute URI with scheme://. Required for audit, decision, coverage, state-window, and session-context outputs.
#[arg(long, value_name = "URI")]
pub event_source: Option<String>,
/// EXPERIMENTAL (unstable): opt-in tool-decision-truth carrier producer. Append
/// `assay.tool_decision_truth.v0` carriers (one JSON object per line) to this NDJSON file during the
/// run, as a separate sink alongside the decision log. Requires ASSAY_TDT_HMAC_KEY and
/// ASSAY_TDT_HMAC_KEY_ID in the environment; the producer fails closed at startup if either is
/// missing or malformed. The key is read from the environment, held in memory only, and never logged
/// or persisted. Evidence-only: no runtime action is taken on the verdict.
#[arg(long = "tool-decision-truth-out", value_name = "PATH")]
pub tool_decision_truth_out: Option<PathBuf>,
/// Command to wrap (use -- to separate args)
#[arg(required = true, last = true, allow_hyphen_values = true)]
pub command: Vec<String>,
/// Fail if deprecated v1 policy format is detected
#[arg(long)]
pub deny_deprecations: bool,
}
/// The shapes `mcp discover` can emit.
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
pub enum DiscoverFormat {
Table,
Json,
Yaml,
}
#[derive(clap::Args, Debug, Clone)]
pub struct DiscoverArgs {
/// Scan local machine (config files & processes)
#[clap(long, default_value_t = true)]
pub local: bool,
/// Output format (table, json, yaml)
#[clap(long, default_value = "table")]
pub format: DiscoverFormat,
/// Write output to file
#[arg(short, long)]
pub output: Option<PathBuf>,
/// Fail if specific conditions met (comma separated): unmanaged, no_auth
#[arg(long, value_delimiter = ',')]
pub fail_on: Option<Vec<String>>,
/// Policy file to use for configuration
#[arg(long)]
pub policy: Option<PathBuf>,
}
#[derive(clap::Args, Debug, Clone)]
pub struct InventoryArgs {
/// Write the assay.mcp_server_inventory.v0 carrier to this path ("-" or omitted = stdout).
#[arg(long, default_value = "-")]
pub out: String,
/// Scope the scan to config files only: skip running-process discovery and report
/// process_scan coverage as not_scanned (honest: not looked), never partial. Deterministic,
/// useful for CI and reproducible inventory review.
#[arg(long)]
pub no_process_scan: bool,
}