Skip to content

Make nodespace mcp database-independent; remove external_tools_enabled - #3673

Merged
mstomar125 merged 2 commits into
mainfrom
issue-3672-mcp-database-independent
Oct 6, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-3672-mcp-database-independent

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3672

Corrects #3664: nodespace mcp no longer depends on a database.

What changed

  • database-settings (flat type, category: settings) loses external_tools_enabled: schema, DatabaseSettingsFields, typed update, promoted fields, regenerated TypeScript. No migration or compatibility code; a flat node update naming it is rejected as an undeclared key.
  • mcp install/uninstall/status make no daemon connection, take no database and print no database label. The client config install writes is the enablement; status reports whether it is present (the installer's mcp-status).
  • The server reads no settings, binds no database and starts with the daemon down. Each call acts on the daemon's active database at that moment. NODESPACE_DATABASE is no longer passed to calls.
  • A call naming --database (either spelling), a --socket other than the server's own, or the database subcommand is refused; a printed delete confirm_command (which carries only --socket) still replays.
  • Removed Move the daemon's settings into each database's settings node and delete daemon.toml (ADR-095) #3664's id binding, label resolution, enforce_enabled and their tests; replaced with active-database tests.
  • CLI reference (hand-written Database settings section, generated mcp text) and SKILL.md updated; skill:gen run.

Tests

Unit tests for argv building and child env, stdio integration tests (active database follows database use, env ignored, refusals, delete replay, daemon down at start, install/status/uninstall with no daemon), removal of the field in types/core/daemon/app-lib/frontend tests. Each new test was mutation-checked.

Documentation

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Code Review Summary

Verdict: APPROVE, no blockers. I reviewed the diff against origin/main (56c34db) at medium depth, with most of the time on the build_child_args trust boundary.

The change does what #3672 asks:

  • external_tools_enabled is gone from the schema, the wire type, the typed update, the promoted fields and the generated TypeScript. git grep finds it only in the two tests that check it is now rejected.
  • install, uninstall and status have no daemon path, and dispatch no longer calls resolve_routing for Mcp.
  • The id-binding, label and enforce_enabled code is deleted.
  • The child process runs without NODESPACE_DATABASE.
  • Companion docs PR nodespace-docs#116 removes the sheet row and the consumer bullet. It must land before the gate runs node-types:check, as the PR body says.

Bypass hunt on build_child_args. I tried each route below and none gets through with the current CLI definition:

  • Flag spellings. --database x, --database=x and nodespace --database … are all refused. So is --database after the subcommand, after --, quoted, or with no value. --socket gets the same treatment unless it names the server's own socket.
  • Abbreviations and aliases. Cli sets neither infer_long_args nor infer_subcommands. There are no alias or visible_alias entries anywhere in packages/cli/src, no allow_external_subcommands, and no short flag for --socket or --database. So --data x, datab use and db use all fail inside clap.
  • -- handling. Clap stops matching subcommands after --, and the top-level Cli has no positionals, so -- database use x is a parse error. The scan refuses it anyway.
  • Picking the subcommand. Before the subcommand, clap only accepts the top-level globals. --json, -h and -V take no value, --socket's value is consumed by the scan, and --database is refused outright. So "the first word that doesn't start with -" really is the subcommand.
  • Environment. NODESPACE_DATABASE is stripped from the child. NODESPACED_SOCKET is overridden by the explicit --socket. A call cannot set env.
  • Other ways to change the active database. Only commands/database.rs writes to the registry. Other connect_database callers only resolve and list (resolve_routing, diagnostics). No other subcommand declares a database-like argument.
  • Fresh routing per call. With no selection, each child resolves the default id at call time (resolve_default_database_id), so it really does follow database use.

Findings

Critical Issues

None.

Suggested Improvements

  1. packages/cli/src/commands/mcp.rs build_child_args: no test pins the clap settings the guard relies on. The token scan is sound only because clap does not infer abbreviations and nothing has an alias. If someone later adds #[command(infer_subcommands = true)], infer_long_args, or visible_alias = "db" on Database, then data use x, --data x or db use x would get past the guard and every existing test would still pass.

    • Cheap fix: add a unit test that asserts the assumption through clap's own behaviour. Cli::try_parse_from(["nodespace", "--datab", "x", "search", "q"]) and Cli::try_parse_from(["nodespace", "datab", "list"]) must fail. Cli::command().find_subcommand("database") must have no aliases, and neither must the database or socket args.
    • Stronger option (not required): after the scan, parse the built argv with Cli::try_parse_from and refuse a Command::Database match or a database arg whose value_source() is the command line. That checks with the same parser the child uses. Ignore env-sourced values, because the server process may have NODESPACE_DATABASE set.
  2. packages/core/tests/it/database_settings_fields_test.rs a_flat_update_is_validated_like_the_typed_one: the AC1 case only asserts is_err(). This is the evidence for "a flat node update naming the field is rejected as an undeclared key", and it is good that the value is now true rather than 1. But the case would still pass if the update failed for some unrelated reason. Assert that the error names external_tools_enabled or says the key is undeclared, so the test proves the reason for the rejection.

Nitpicks

  • Nit: packages/skill/SKILL.md wording. "--database and --socket naming another daemon, and the database subcommand, are refused" reads as if --database names a daemon. Suggested: "--database, a --socket naming another daemon, and the database subcommand are refused." Separately, the sentence before it ("Every command in this skill, its references … works the same way through it") is now contradicted by the nodespace --database work … examples in references/cli.md. Consider "…works the same way through it, except database selection:".
  • Nit: mcp.rs uninstall() always ends by printing "The NodeSpace MCP passthrough tool is disabled." It prints this even when a client reports a skip reason, for example an unreadable config where uninstallMcp sets skipReason to the read error. Now that the client config is the only thing that enables the tool, that line can be wrong. Print it only when no client reports a skip reason, or base it on a follow-up mcp-status.
  • Nit: packages/cli/tests/it/mcp_integration.rs mcp_install_status_uninstall_round_trip_needs_no_daemon has a stale doc comment. It says CI does not build packages/skill/dist, so the test runs only locally. The merge gate's skillInstaller tier (scripts/gate-stage.ts) does build it, so the test runs in the gate. Worth fixing while that comment is already being rewritten.
  • Nit: run_child_does_not_inherit_the_database_environment_variable modifies process-wide env. It uses std::env::set_var and then remove_var, and it neither restores the previous value nor takes a lock. It is safe under nextest's process-per-test model but would race under plain cargo test. The integration test mcp_ignores_a_database_named_in_its_environment already covers this end to end, so you could drop the unit test or restore the previous value.
  • Nit: the scan is conservative on purpose, and that is fine. It refuses --database and a foreign --socket even after -- or as a literal value, and it silently drops a --socket <own> pair wherever it appears. This is acceptable for a trust guard; I mention it only so the over-refusal is a known choice.

FYI (out of scope, no change requested)

  • A delete preview is not tied to a database any more. A confirm_command printed in database A and replayed after the user runs database use B acts on B. It matches only if B has a node with the same id, version and descendant count, which is realistic only for a registered copy of A's file. The shell CLI behaves the same way when no --database is passed, and ADR-095 §4 chose this behaviour.
  • The passthrough can still run nodespace uninstall with no prompt. That stops the daemon and removes the bin dir. This predates this PR and is not about choosing a database. The install prompt already says a client "will be able to run any nodespace CLI command". Raising it only in case ADR-038's trust boundary should cover machine-level destructive commands in a follow-up.

Acceptance criteria

AC Status
Field removed: schema, DatabaseSettingsFields, typed update, TS, sheet; flat update rejected Met. The sheet change is in docs#116 and must land before the gate. The flat-update test is weak, see Improvement 2.
install, uninstall and status need no daemon and take no database; status reports the config; uninstall works with the daemon stopped Met (mcp_install_status_uninstall_round_trip_needs_no_daemon, socket with nothing listening).
Server starts with no settings read and the daemon down; each call follows database use Met (mcp_serves_with_the_daemon_down_at_start, mcp_acts_on_the_active_database_at_each_call).
--database (both spellings), a foreign --socket and the database subcommand are refused; delete confirm_command replays Met (unit and stdio tests; the replay is checked by a clap parse and an end-to-end delete).
#3664 binding, label and id-resolution gone, tests replaced Met.
CLI guidance and SKILL.md updated; drift check passes Text is updated; I did not run the drift check (read-only review).
test:changed and quality:fix Not verified here (read-only review, no cargo).

@mstomar125

Copy link
Copy Markdown
Contributor Author

Review addressed (review round 1: approve, no blockers).

  • Improvement 1: added a unit test pinning the clap settings the guard depends on (no flag abbreviation, no subcommand abbreviation, no db alias, no aliases or short forms for --database/--socket/database). Mutation-checked with infer_long_args = true.
  • Improvement 2: the flat-update case for the removed field is now its own test and asserts the error names external_tools_enabled. Mutation-checked by re-adding the schema field.
  • Nits fixed: uninstall no longer claims "disabled" when a client config could not be removed; stale CI comment on the round-trip test; SKILL.md wording.
  • Left as is: the env-var test relies on nextest process isolation (same as other env tests in the crate); the confirm_command replay across database use is the ADR-095 §4 behaviour and matches the shell CLI.

mstomar125 and others added 2 commits October 6, 2026 13:25
Enablement is the client config mcp install writes, not a database
setting. install/uninstall/status make no daemon connection and take no
database; the server binds no database and acts on the active one at
each call. A call naming --database, another --socket, or the database
subcommand is refused, and NODESPACE_DATABASE is not passed to calls.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3672-mcp-database-independent branch from 511d2ac to 3405a66 Compare October 6, 2026 11:25
@mstomar125
mstomar125 merged commit 0bb30bf into main Oct 6, 2026
@mstomar125
mstomar125 deleted the issue-3672-mcp-database-independent branch October 6, 2026 11:26
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.

Make nodespace mcp database-independent: remove external_tools_enabled and the database binding

1 participant