Repository navigation
Add ADR-038 trust-boundary controls and installer support for nodespace mcp - #2551
Conversation
…ce mcp
nodespace mcp (the stdio passthrough server for bash-less MCP clients) had
no enablement gate, no provenance marking, no schema validation, and no
installer -- it was a working binary nothing could safely go live with.
Trust boundary (packages/cli/src/commands/mcp.rs):
- run_server refuses to serve anything, including initialize, unless
~/.nodespace/daemon.toml's [mcp] enabled flag is true (enforce_enabled).
The flag defaults to false and is only ever set by the new
install/uninstall subcommands.
- tools/list runs the passthrough tool's schema through
validate_tool_schema (bounded nesting depth, no unbounded
additionalProperties, size cap) before returning it, and stamps
_meta.source: "external" for provenance -- the scoped analog of a
registry-node source marker, since no node-backed external-tool
registry exists in the codebase yet.
Settings (packages/daemon/src/services/settings_service.rs):
- New McpConfig { enabled: bool } persisted under daemon.toml's [mcp]
section, mirroring CaptureConfig's shape. read_mcp_settings/
set_mcp_enabled are plain, daemon-independent file operations so the
separate nodespace CLI process can read/write them without an RPC
connection.
Installer:
- New nodespace mcp install/uninstall/status subcommands. install writes
a detected client's MCP config via the shared skill/MCP installer and
only then enables the flag; uninstall reverses both, unconditionally
landing on disabled.
- commands::skill's resolve_installer/run_installer_subcommand/
Installer/InstallOutcome/SkippedAgent are now pub(crate) so
commands::mcp reuses the same compiled-installer resolution rather
than duplicating it.
- packages/skill/src/mcp-clients.ts + mcp-installer.ts: the MCP-client
equivalent of agents.ts/installer.ts. Writes/removes Claude Desktop's
mcpServers.nodespace entry, preserving every other key/server in the
file, resolving nodespace's absolute path via `which` since GUI apps
don't inherit the shell's $PATH.
- install.ts gains mcp-install/mcp-uninstall/mcp-status commands using
the same stdout contract the Rust side already parses.
Also corrects a stale comment in shim-parity.test.ts that incorrectly
claimed Antigravity CLI consumes nodespace mcp -- it uses skill + CLI
directly, same as every other shell-capable harness.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Reviewed (adversarial pass, security-focused given the trust-boundary shape): enablement gate confirmed airtight (checked before the read loop, nothing writable to stdout before the check, no other code path can flip the enabled flag besides install/uninstall). Provenance marking confirmed unconditional on the single tools/list response builder. Installer confirmed to genuinely merge/preserve other mcpServers entries and top-level keys rather than overwrite the whole config file — a real, verified regression-avoidance. Deleted ADR-035 surface confirmed genuinely gone, not resurrected. Test counts verified exactly (26 installer tests, 6 real stdio integration tests). The 'not verified against real Claude Desktop' gap is honestly and separately flagged, not glossed over. One real, non-blocking gap found: the additionalProperties bound only catches the explicit |
Summary
Closes #2512.
nodespace mcp(the stdio passthrough server for bash-less MCP surfaces like Claude Desktop's Chat tab) was a working binary with no consumer wired to it and none of the ADR-038 Trust Boundary controls in place. This PR finishes it: explicit user enablement, provenance marking, generated-schema validation, and an installer — scoped to the single-passthrough-tool shape ADR-035's amendment clears, not a general framework.Confirmed before writing any code that the previous MCP installer surface ADR-035 deliberately deleted (
configure_mcpTauri command,install.sh/uninstall.shMCP registration,mcp_configuredconfig fields) is genuinely gone — this is a new, ADR-038-compliant surface, not a resurrection of the deleted shape.Trust boundary (
packages/cli/src/commands/mcp.rs)run_serverrefuses to serve anything — not eveninitialize— unless~/.nodespace/daemon.toml's[mcp] enabledflag istrue. This is the strongest form the boundary can take: a disabled server never accepts a client's first message at all, rather than accepting a connection and gating individual calls. The flag defaults tofalseand is only ever flipped by the newinstall/uninstallsubcommands.tools/listentry now carries_meta.source: "external". This is the scoped analog of ADR-038's registry-nodesourcemarker — no node-backed registry for external tools exists in the codebase yet (that's ADR-038's still-open Implementation Notes item 5), so this marks the one place provenance can attach today (the wire-level tool definition), ready to feed a future registry integration.validate_tool_schemaenforces bounded nesting depth, no unboundedadditionalProperties, and a size cap on the tool's owninputSchemabeforetools_list_resultever returns it — a validation failure now surfaces as a JSON-RPC internal error rather than shipping a bad schema.Settings (
packages/daemon/src/services/settings_service.rs)New
McpConfig { enabled: bool }persisted underdaemon.toml's[mcp]section, mirroringCaptureConfig's existing shape (sameenabled-flag pattern already used for the opt-in session-capture feature).read_mcp_settings/set_mcp_enabledare plain, daemon-independent file operations —nodespace mcpis a separate process from the daemon with no RPC connection, so these read/writedaemon.tomldirectly, the same wayrecord_routing_probe_verdictalready does from outside the RPC surface.Installer
nodespace mcp install/uninstall/statussubcommands.installwrites a detected client's MCP config via the shared skill/MCP installer and only then enables the flag — a run that configures nothing leaves the tool disabled.uninstallreverses both, unconditionally landing on "disabled" regardless of what state the client configs were in.commands::skill'sresolve_installer/run_installer_subcommand/Installer/InstallOutcome/SkippedAgentare nowpub(crate)socommands::mcpreuses the exact same compiled-installer resolution (same binary, same bundledpackages/skilldist) instead of duplicating sidecar/script discovery.packages/skill/src/mcp-clients.ts+mcp-installer.ts(new): the MCP-client equivalent ofagents.ts/installer.ts. Writes/removes Claude Desktop'smcpServers.nodespaceentry, preserving every other top-level key and every other configured MCP server untouched. Resolvesnodespace's absolute path viawhichrather than a bare command name — GUI apps on macOS/Linux spawn child processes without the interactive shell's$PATH, a well-known way for an MCP server entry to silently fail to launch. Zero new npm dependencies (packages/skill'sdependenciesstays{}).install.tsgainsmcp-install/mcp-uninstall/mcp-statuscommands using the identical "✓ name: ..." / "⚠ name: reason" stdout contract the Rust side already parses for the skill installer.packages/skill/references/cli.md(bun run skill:gen) so the CLI reference documents the new subcommands.Also included
A one-line factual correction to a stale comment in
shim-parity.test.tsthat claimed Antigravity CLI consumesnodespace mcp— it doesn't; Antigravity uses skill + CLI directly like every other shell-capable harness (confirmed againstagents.ts's ownantigravityentry and ADR-035's amendment). No behavior change, comment only.Non-goals confirmed unchanged
nodespaceCLI as their only/default path; none of them were touched or wired to MCP.packages/agentwas not touched.Verification — what's real vs. what still needs a human
Verified, at increasing levels of rigor:
validate_tool_schema/enforce_enabledtested directly (valid + adversarial cases: excessive nesting, unboundedadditionalProperties, oversized schema, disabled-config rejection).installMcp/uninstallMcp/checkMcpInstalledfunctions — config merge/preserve behavior, malformed-JSON handling, absolute-path resolution via a mockedwhich.packages/cli/tests/mcp_integration.rsspawns the actual compilednodespacebinary and speaks JSON-RPC over its real stdin/stdout —initialize,tools/list,tools/call— plus two new tests proving the disabled server genuinely refuses to start (both the missing-file and explicit-falsecases), asserting zero stdout is written.mcp_integration.rstest buildspackages/skill/dist/install.jslocally and drivesnodespace mcp install --yes→status→ a live server connection →uninstall→statusagainst a fake$HOME/fake Claude Desktop directory. It asserts on the actualclaude_desktop_config.jsonwritten to disk, the actualdaemon.tomlflag, and a realinitializeresponse from the now-enabled server — then confirms the server refuses again post-uninstall. (Skipped, not failed, in CI wheredist/isn't pre-built — same convention the existingskill installtests already follow.)NOT verified (needs a human with a real Claude Desktop install): that Claude Desktop's Chat tab actually launches
nodespace mcpfrom the written config, discovers the tool, and a model successfully invokes it end-to-end through Claude Desktop's own UI. Also unconfirmed: whether Claude Desktop's ownTool-object parser tolerates the added_meta.sourcefield on atools/listentry (spec-permitted per the MCP_metaextension convention, but not confirmed against the real client). This is the one acceptance criterion this environment cannot fully close — flagging it explicitly rather than claiming full end-to-end coverage.Test plan
cargo test -p nodespace-daemon -p nodespace-cli— all green, including the 4 new e2e trust-boundary/lifecycle testsbunx vitest run+bunx tsc --noEmitinpackages/skill— 89 tests greenbun run skill:genregenerated and verified clean againstskill_md_generation.rsbun run quality:fix— clean across the whole repobun run test:all— clean (frontend coverage, scripts, skill, full Rust workspace)This is security-relevant trust-boundary work (explicit user consent gating an external tool's access) — please give it an adversarial review rather than a quick skim, especially the enablement-gate ordering and the schema-validation bounds.
🤖 Generated with Claude Code