fix(mcp): keep codegraph_explore loaded in Claude Code and Copilot CLI - #1697
fix(mcp): keep codegraph_explore loaded in Claude Code and Copilot CLI#1697bompus wants to merge 1 commit into
Conversation
colbymchenry#1696) Claude Code defers every MCP tool behind ToolSearch by default, so a fresh session sees only the tool name until the model searches for it. The explore tool now carries `_meta: { "anthropic/alwaysLoad": true }`, which exempts it on existing installs, and the Claude Code installer target writes `alwaysLoad: true` on the server entry (re-running install adds the key to an older entry). Copilot CLI tool search holds MCP tools back the same way once ~30 tools are connected, so its entry carries `deferTools: "never"`.
|
Merged into a local integration build of current |
|
Verified both halves of this against first-party docs and then over the wire. It's correct. Key names check out. Measured over stdio, not read off the source: I spoke MCP to the built server (
So the flag actually reaches the client in the tool listing, which is the only place it can matter. That's the whole claim, and it's confirmed at the protocol boundary rather than at the config file. LGTM. |
Fixes #1696.
Claude Code defers every MCP tool behind its
ToolSearchstep by default, so a fresh session sees onlycodegraph_explore's name until the model searches for it. On a defaultcodegraph installsetup with no project rule naming the tool, 4 of 6 headless Opus sessions never called it and did the task with Grep/Read; with the schema in context from the first turn, 6 of 6 did (numbers and the reproduction in #1696).Change
codegraph_explorecarries_meta: { "anthropic/alwaysLoad": true }insrc/mcp/tools.ts, andToolDefinitiongains an optional_meta. Claude Code reads the key and keeps the tool's schema loaded from the first prompt. It reaches an existing install on upgrade without touching the user's config; other hosts ignore_meta."alwaysLoad": trueon the server entry (src/installer/targets/claude.ts), on both the project.mcp.jsonand the global~/.claude.jsonpath. Re-runningcodegraph installadds the key to an entry that predates it. The README's manual~/.claude.jsonsnippet shows the key."deferTools": "never"on its entry (src/installer/targets/copilot-cli.ts). Copilot CLI's tool search defers MCP tools once ~30 tools are connected, and that key is its per-server opt-out (docs). Docs-verified only; the host is not installed here.mcp-tool-annotations.test.tsasserts the_metaon everytools/listsurface (the master array,getStaticTools(),ToolHandler.getTools(), and the live server);installer-targets.test.tscovers the key on the Claude project and global paths, the Copilot CLI entry, and the re-run migration for both.Verified
--strict-mcp-configwith the plain entry: the released 1.6.0 server runsToolSearchthencodegraph_explore; this branch's build runscodegraph_explorealone.vitest: 233 passed, 3 skipped.tscclean.Not in this PR
OpenCode 2's Code Mode, which puts MCP tools behind a code interface by default. Its per-server opt-out,
"codemode": false, only survives on the native v2 entry shape, which the installer does not write yet. Separate issue to follow.