Repository navigation
feat(mcp): load the structural tools upfront and say what the graph answers - #2698
Merged
Merged
Conversation
…nswers Claude Code defers every MCP tool behind ToolSearch by default: at session start the model sees only tool names and server instructions, while Grep and Read are always loaded. Codex does the same and shows the server instructions as the namespace description of the deferred tools. Agents therefore reached for grep before the graph tools were even loaded (#509, discussion #2025). - tools/list: search_graph, trace_path and get_code_snippet carry _meta["anthropic/alwaysLoad"] = true (a documented per-tool hint), so the structural discovery path loads upfront while the other 14 tools stay deferred. About 4.6K characters of schema; clients that do not know the key ignore it, as MCP reserves _meta. - Server instructions (default profile) now state, keywords first and as facts, which structural questions the graph answers and where grep fits better: 309 -> 999 characters, within Claude Code's 4,096-character cut. - SessionStart/SubagentStart: the untrusted-metadata label now covers the graph-derived project name only. Wrapping the routing sentences too told the model to treat cbm's own guidance as data. The other sentences are unchanged; sanitization is unchanged. The initialize byte budget is raised deliberately from 512 B to 1.5 KiB (1,188 bytes now); tools/list stays within its 21 KiB budget (20,938 bytes). Refs #509 Signed-off-by: Martin Vogel <[email protected]>
timothybrush
pushed a commit
to timothybrush/codebase-memory-mcp
that referenced
this pull request
Oct 19, 2026
…rofiles The read-only analysis profile and the fast scout profile serve the graph subagents (codebase-memory-auditor, codebase-memory-scout). Their server instructions listed tools only. Like the default profile, they now state as facts which structural questions the graph answers (where a symbol is defined, who calls a function, what it calls, and for analysis also call chains, data flow and change impact), keywords first: analysis 190 -> 648 characters, scout 199 -> 427, well within Claude Code's 4,096-character cut. The profile names, check_index_coverage and the absence of index_repository are unchanged. Stacked on DeusData#2698. Refs DeusData#509 Signed-off-by: Martin Vogel <[email protected]>
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.
Why
Agents with codebase-memory-mcp installed often answer structural questions with grep and never call the graph (#509, discussion #2025). One documented cause is tool deferral. Claude Code defers every MCP tool by default: at session start the model sees only tool names and server instructions, while Grep, Read and Bash are always loaded. Codex does the same; its
tool_searchlists each server under itsinstructionstext (codex-rs/codex-mcp/src/rmcp_client.rs).What changes
search_graph,trace_pathandget_code_snippetcarry_meta["anthropic/alwaysLoad"]: true. This is the documented per-tool hint, and it follows Anthropic's guidance to keep the most-used tools loaded and defer the rest. The other 14 tools stay deferred. Clients that don't know the key ignore it, since MCP reserves_meta. No user configuration is written.Proof on real output
Main 354ccec against this branch, over MCP stdio and
hook-augment, using an isolated cache:_meta.anthropic/alwaysLoadsearch_graph,trace_path,get_code_snippetThe
mcp_metadata_byte_budgettest raises the initialize budget deliberately, from 512 B to 1.5 KiB, and its comment says why.mcp_initialize_responsenow checks for the new freshness wording ("refreshes automatically").Tests
mcp_tools_list_loads_structural_path_upfront(all three tool profiles),mcp_server_instructions_name_structural_questions,cli_hook_session_untrusted_label_covers_project_name_only.src/mcp/mcp.candsrc/cli/hook_augment.c, exactly the four tests that encode this change fail; with the change, all pass.mcp379 / 0 / 4 (the 4 skips are Windows-only),cli362 / 0,daemon_application74 / 0,agent_clients38 / 0.Not in this PR
Refs #509