Skip to content

feat: scope MCP connectors through mcp.json, Project Settings and This Session - #190

Merged
sanchitrk merged 3 commits into
canaryfrom
claude/mcp-connector-scoping-core
Dec 2, 2026
Merged

sanchitrk merged 3 commits into
canaryfrom
claude/mcp-connector-scoping-core

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Stored connections are no longer attached to every session. A connector reaches a session only when an mcp.json names it ({ "connector": "app.linear" }), or when Project Settings or This Session adds it. Both soft layers are stored by the host that runs the session, never in a file. The desktop UI follows in a stacked PR.

mcp.json

  • Each entry is a connector, a url or a command, used as written. The project file replaces the user file's entry of the same name or connector, like a .env file. Nothing is merged.
  • Refused, reported and skipped: partial project entries ({ "enabled": false } over a user server), auth (replaced by connector), a connection field, and the same connector named twice in one file.

Soft layers and accounts (harness)

  • mcp/layers.ts holds one resolver for the runtime, the host RPCs and the CLI. It also has edit, which enforces the three rules: a layer can switch off what the layer below has on, can never switch on what it has off (a file's "enabled": false included), and can add what no layer below names.
  • A connector runs on the session's pick, else Project Settings', else the vault's Default. It uses stored connections only, with no environment variable and no fallback. Picking the inherited account clears the pick.
  • The account is pinned per run (mcp_account): a Make Default lands at the next run, and a run resumed after a restart keeps its account. A connection turned off mid-turn refuses that turn's remaining calls with MCP server "x" is disabled., not the sign-in hint.
  • New tables: project_mcp, session_mcp, mcp_account.

Plugin, schema and vault

  • ServerConfig gains ConnectorServer { connector, connection? }. HttpServer.auth is removed, and McpServer.override becomes from.
  • The broker's listMcpConnections (auto-attach) is replaced by mcpConnections(): every stored MCP connection, enabled or not.
  • Deleting the Default promotes the oldest remaining connection, enabled ones first.
  • Host RPCs mcp.view and mcp.edit take projectId, sessionId, or a directory the host maps to a project without creating one.

CLI

  • mcp add --connector <id>, plus mcp view|on|off|attach|detach|account|reset through the home's server.
  • mcp list checks connector entries against the local vault.
  • mcp login on a connector entry points to connect login <connection>.

Breaking, by design (no users yet): auth entries and partial project entries stop loading, and vault connections no longer appear in sessions until something adds them.

Testing

  • New harness E2E suite mcp.connector.test.ts, with a stub vault and a real MCP server over HTTP:

    • a run uses the Default;
    • a Make Default between runs lands at the next run;
    • a Make Default between two turns of one run waits for the run to settle;
    • a connection turned off between two calls of one turn refuses the second as disabled;
    • a session switch-off withholds the tools.
  • Server E2E server.mcp.layers.json: views, edits and every refusal, a turned-off connection, and promotion.

  • CLI E2E cli.mcp.layers.test.ts: a real serve, project resolved from the directory, and the next turn's declared tools following the layers.

  • Updated suites (artifact diffs reviewed): mcp.session, mcp.race, settings, db, server.settings, mcpcli, cli.mcp.oauth and connector.

  • Full harness run: 641 passed. The two live prompt suites that failed did so only because this worktree had no generated model catalog; with a fresh catalog they pass (4 passed, 6 skipped for keys not set). vp run verify passes.

  • New live suite cli.mcp.linear.live.test.ts runs against the real Linear MCP server, with Anthropic claude-haiku-5-5 and OpenAI gpt-6-luna, over five placements:

    • User Only: This Session adds it.
    • Project Only: Project Settings adds it.
    • File User: ~/.codework/mcp.json.
    • File Project: .codework/mcp.json.
    • User + Project: both files.

    In each placement:

    • the model listed the last 10 issues through list_issues on the vault's Default;
    • a session switched to a wrong key made no list_issues call at its next run;
    • Linear switched off or removed made no call either.

    All 30 checks passed (2 providers × 5 placements × 3 checks). The prompt suites also pass with these keys: 8 passed, 2 skipped (OpenRouter, key not set).

  • cli.mcp.oauth failed once on timing while running alongside other suites, and passed alone (9 of 9).

  • In a real session with a real model call, a switched-off server wasn't offered, and an account picked in Project Settings took effect at the next run.

Done by Claude Opus 5.5 in Claude Code; the CLI half was built by an Opus subagent and reviewed.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

sanchitrk and others added 2 commits December 2, 2026 17:38
…s Session

Stored connections are no longer attached to every session. A connector reaches
a session only through `{ "connector": "<id>" }` in `mcp.json`, or through the
Project Settings and This Session layers the host stores.

- mcp.json entries are a connector, a url or a command, used as written. The
  project file replaces the user file's entry of the same name or connector,
  like a `.env` file; partial entries, `auth` and `connection` are refused.
- The soft layers can switch off what the layer below has on, never switch on
  what it has off, and add what no layer below names. One resolver in the
  harness serves the runtime, the host RPCs and the CLI.
- A connector runs on the session's pick, else Project Settings', else the
  vault's Default, from stored connections only. The account is pinned per run
  and kept by a resumed run; a connection turned off mid-turn refuses as
  disabled. Deleting the Default promotes the oldest remaining connection.
- Host RPCs `mcp.view` and `mcp.edit`; CLI `mcp add --connector`,
  `mcp view|on|off|attach|detach|account|reset`, and `mcp list` checks
  connector entries against the local vault.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…from

A live suite against the real Linear MCP server and live models: Linear added
by This Session, by Project Settings, named by the user mcp.json, by the
project mcp.json, and by both. In each, `whoami` answers on the vault's
Default, a session switched to a wrong key does not reach Linear at its next
run, and a switched-off or removed connector is gone. It runs when
`CODEWORK_LIVE_LINEAR_HOME` names a home with a working Linear connection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…enAI

The live Linear suite asks for the last 10 issues through Linear's read-only
`list_issues` instead of `whoami`, runs against Anthropic and OpenAI's API, and
writes the replies to `CODEWORK_LIVE_LINEAR_REPLIES` when it is set, never into
the artifact. A run cut off before its cleanup no longer blocks the next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sanchitrk
sanchitrk merged commit bac3fd3 into canary Dec 2, 2026
3 checks passed
@sanchitrk
sanchitrk deleted the claude/mcp-connector-scoping-core branch December 2, 2026 12:47
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.

1 participant