Skip to content

Add ADR-038 trust-boundary controls and installer support for nodespace mcp - #2551

Merged
mstomar125 merged 1 commit into
mainfrom
issue-2512-mcp-trust-boundary
Sep 10, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-2512-mcp-trust-boundary

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

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_mcp Tauri command, install.sh/uninstall.sh MCP registration, mcp_configured config 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)

  • Explicit user enablement. run_server refuses to serve anything — not even initialize — unless ~/.nodespace/daemon.toml's [mcp] enabled flag is true. 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 to false and is only ever flipped by the new install/uninstall subcommands.
  • Provenance marking. Every tools/list entry now carries _meta.source: "external". This is the scoped analog of ADR-038's registry-node source marker — 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.
  • Generated-schema validation. validate_tool_schema enforces bounded nesting depth, no unbounded additionalProperties, and a size cap on the tool's own inputSchema before tools_list_result ever 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 under daemon.toml's [mcp] section, mirroring CaptureConfig's existing shape (same enabled-flag pattern already used for the opt-in session-capture feature). read_mcp_settings/set_mcp_enabled are plain, daemon-independent file operations — nodespace mcp is a separate process from the daemon with no RPC connection, so these read/write daemon.toml directly, the same way record_routing_probe_verdict already does from outside the RPC surface.

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 — a run that configures nothing leaves the tool disabled. uninstall reverses both, unconditionally landing on "disabled" regardless of what state the client configs were in.
  • commands::skill's resolve_installer/run_installer_subcommand/Installer/InstallOutcome/SkippedAgent are now pub(crate) so commands::mcp reuses the exact same compiled-installer resolution (same binary, same bundled packages/skill dist) instead of duplicating sidecar/script discovery.
  • packages/skill/src/mcp-clients.ts + mcp-installer.ts (new): the MCP-client equivalent of agents.ts/installer.ts. Writes/removes Claude Desktop's mcpServers.nodespace entry, preserving every other top-level key and every other configured MCP server untouched. Resolves nodespace's absolute path via which rather 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's dependencies stays {}).
  • install.ts gains mcp-install/mcp-uninstall/mcp-status commands using the identical "✓ name: ..." / "⚠ name: reason" stdout contract the Rust side already parses for the skill installer.
  • Regenerated 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.ts that claimed Antigravity CLI consumes nodespace mcp — it doesn't; Antigravity uses skill + CLI directly like every other shell-capable harness (confirmed against agents.ts's own antigravity entry and ADR-035's amendment). No behavior change, comment only.

Non-goals confirmed unchanged

  • Still exactly one passthrough tool — no many-tool MCP surface reintroduced.
  • Claude Code, Codex, OpenCode, and Antigravity CLI all still use skill + nodespace CLI as their only/default path; none of them were touched or wired to MCP.
  • packages/agent was not touched.

Verification — what's real vs. what still needs a human

Verified, at increasing levels of rigor:

  1. Unit level: validate_tool_schema/enforce_enabled tested directly (valid + adversarial cases: excessive nesting, unbounded additionalProperties, oversized schema, disabled-config rejection).
  2. Installer file-logic: 26 new vitest tests against the real installMcp/uninstallMcp/checkMcpInstalled functions — config merge/preserve behavior, malformed-JSON handling, absolute-path resolution via a mocked which.
  3. Real JSON-RPC over real stdio: packages/cli/tests/mcp_integration.rs spawns the actual compiled nodespace binary 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-false cases), asserting zero stdout is written.
  4. Full real lifecycle, no mocks on either side: one more mcp_integration.rs test builds packages/skill/dist/install.js locally and drives nodespace mcp install --yes → status → a live server connection → uninstall → status against a fake $HOME/fake Claude Desktop directory. It asserts on the actual claude_desktop_config.json written to disk, the actual daemon.toml flag, and a real initialize response from the now-enabled server — then confirms the server refuses again post-uninstall. (Skipped, not failed, in CI where dist/ isn't pre-built — same convention the existing skill install tests already follow.)

NOT verified (needs a human with a real Claude Desktop install): that Claude Desktop's Chat tab actually launches nodespace mcp from 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 own Tool-object parser tolerates the added _meta.source field on a tools/list entry (spec-permitted per the MCP _meta extension 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 tests
  • bunx vitest run + bunx tsc --noEmit in packages/skill — 89 tests green
  • bun run skill:gen regenerated and verified clean against skill_md_generation.rs
  • bun run quality:fix — clean across the whole repo
  • bun 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

…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]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

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 true case, not an omitted key or {} (both JSON-Schema-equivalent to unbounded). Not exploitable today since the validated schema is hardcoded, but worth closing before this validator is ever pointed at an externally-supplied schema. Filed as #2553. Merging.

@mstomar125
mstomar125 merged commit 0a75726 into main Sep 10, 2026
@mstomar125
mstomar125 deleted the issue-2512-mcp-trust-boundary branch September 10, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Finish the general nodespace mcp service: trust-boundary controls and a verified bash-less consumer

1 participant