feat(mcp): emit server-level instructions in initialize response#143
Merged
Conversation
Adds a universal tool-selection playbook surfaced by MCP clients (Claude Code, Cursor, opencode, LangChain, OpenAI Agent SDK) in the agent's system prompt automatically. Without this, agents have to infer tool composition from individual tool descriptions and tend to walk callers manually instead of reaching for codegraph_impact, etc. Scoped tight: only the 9 tools that exist on main today (search/context/callers/callees/impact/node/explore/files/status), no "(when present)" references to unmerged tools, no per-language guidance. ~40 lines of useful guidance. Salvaged from #121, which bundled the instructions with #117's MCP tool-registry refactor and referenced many tools that don't exist on main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
src/mcp/server-instructions.ts(~40 lines of guidance) wired into theinitializeresponse so MCP clients surface it in the agent's system prompt automatically.search/context/callers/callees/impact/node/explore/files/status). No "(when present)" references to unmerged tools.Salvaged from #121, which bundled the instructions with #117's tool-registry refactor and referenced many tools that don't exist on main.
Why this matters
Agents reach for
codegraph_searchthen walk callers manually because that's the most general-sounding tool name. The playbook redirects "what would changing this break?" tocodegraph_impact(one call instead of recursive caller-walks), and "what's the deal with this feature?" tocodegraph_context(one round-trip instead of search+node).Test plan
npx tsc --noEmitcleannpm test— 416/416 pass (no test changes — initialize response is structurally compatible)🤖 Generated with Claude Code