fix(mcp): offer MCP tools in Code mode, not just Chat - #240
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 forCODE_TOOLS, the interactive terminal tools anddesktop, then falls through toreturn 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
desktopbranch 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
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:
+layout.svelte, so it is present on every routestartConfiguredMcpServersruns there too, so servers are already running regardless of which tab is openexecuteTool's MCP gate (registry.ts:296) never consulted the modeSame 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.
Full suite 1808 passing,
npm run checkclean, 0 lint errors.🤖 Generated with Claude Code
https://claude.ai/code/session_016z8Mdnd4sPugsUMickSwip