Skip to content

fix(mcp): offer MCP tools in Code mode, not just Chat - #240

Merged
tmac1973 merged 1 commit into
mainfrom
fix/mcp-tools-in-code-mode
Sep 7, 2026
Merged

fix(mcp): offer MCP tools in Code mode, not just Chat#240
tmac1973 merged 1 commit into
mainfrom
fix/mcp-tools-in-code-mode

Conversation

@tmac1973

@tmac1973 tmac1973 commented Sep 7, 2026

Copy link
Copy Markdown
Owner

A configured MCP server was available in the Chat tab but vanished in the Shell tab with Code mode on.

Cause

shouldIncludeCodeTool (registry.ts:113) returns true for CODE_TOOLS, the interactive terminal tools and desktop, then falls through to return false. There was no MCP branch, so every MCP tool was filtered out of the schema before the model saw it. Chat has that branch; Code mode never got one.

An omission rather than a decision. Nothing in the plans scopes MCP to Chat, and the Code-mode filter reads as a list of what it does include — written before MCP servers existed. The desktop branch immediately above it carries a comment justifying its inclusion in Code mode on exactly the reasoning that applies here, and more strongly: driving Blender or Godot is more useful with a repo open than it is in Chat.

Fix

if (reg.category === 'mcp') return isMcpToolEnabled(name);

The rest of the path was checked rather than assumed — "tools appear but calls fail" would be worse than the current behaviour. It was already route-agnostic:

  • the approval modal is mounted in +layout.svelte, so it is present on every route
  • startConfiguredMcpServers runs there too, so servers are already running regardless of which tab is open
  • executeTool's MCP gate (registry.ts:296) never consulted the mode

Same agent loop, same registry. The schema filter really was the only thing in the way.

The per-tool switches in Settings → MCP keep deciding which tools are exposed, exactly as in Chat.

Scope

Plain Shell mode (Code mode off) still excludes MCP tools — that assistant is read-only by design. There is now a test pinning that, so it does not get swept in later by accident.

Testing

The two new Code-mode tests were checked against a reverted fix: both fail without the one-line branch and pass with it.

FAIL  mcp.test.ts > per-tool enablement > offers the same tools in Code mode as in Chat
FAIL  mcp.test.ts > per-tool enablement > honours an explicit per-tool choice in Code mode too

Full suite 1808 passing, npm run check clean, 0 lint errors.

🤖 Generated with Claude Code

https://claude.ai/code/session_016z8Mdnd4sPugsUMickSwip

A configured MCP server vanished in the Shell tab with Code mode on.
`shouldIncludeCodeTool` returns true for CODE_TOOLS, the interactive terminal
tools and `desktop`, then falls through to `return false` — and there was no
MCP branch, so every MCP tool was filtered out of the schema before the model
saw it.

An omission rather than a decision: nothing in the plans scopes MCP to Chat,
and the Code-mode filter reads as a list of what it does include, written
before MCP servers existed. The same reasoning already applied to `desktop`
applies here, and more strongly — Blender and Godot are more useful with a
repo open than they are in Chat.

Everything else on the path was already route-agnostic, so this is the whole
fix: the approval modal is mounted in the root layout, `startConfiguredMcpServers`
runs there too, and `executeTool`'s MCP gate never consulted the mode. The
per-tool switches in Settings → MCP keep deciding which tools are exposed,
exactly as in Chat.

Plain Shell mode (Code mode off) still excludes them, which is deliberate —
that assistant is read-only by design — and there is now a test pinning it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016z8Mdnd4sPugsUMickSwip
@tmac1973
tmac1973 merged commit a3de206 into main Sep 7, 2026
4 checks passed
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