refactor(mcp): dedupe tool descriptions against server instructions (~220 tokens/request)#775
Open
sebyx07 wants to merge 1 commit into
Open
refactor(mcp): dedupe tool descriptions against server instructions (~220 tokens/request)#775sebyx07 wants to merge 1 commit into
sebyx07 wants to merge 1 commit into
Conversation
The codegraph_node and codegraph_explore descriptions restated the playbook that already ships in SERVER_INSTRUCTIONS (emitted at initialize and surfaced in the agent's system prompt). Both texts sit in context every turn, so the duplication is paid twice per request. Keep the playbook in one place (server instructions) and cut the tool descriptions to the operational essentials: modes, params, and when to prefer the other tool. tools/list definitions drop from ~8.0KB to ~7.1KB (~220 tokens per request) with no schema or behavior change. Co-Authored-By: Claude Fable 5 <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.
What
Slims the
codegraph_nodeandcodegraph_exploredescriptions (andnode'sfileparam description) insrc/mcp/tools.ts. No schema, name, or behavior change — 3 strings edited.Why
These descriptions restate the playbook that already ships in
SERVER_INSTRUCTIONS(emitted atinitializeand surfaced in the agent's system prompt, per the header comment inserver-instructions.ts). Both texts sit in the model's context every turn, so the duplication is paid twice per request:codegraph_nodedescriptioncodegraph_exploredescriptiontools/listdefinitions≈220 tokens saved per request, forever, across every connected agent — with the steering content (explore-first, node-replaces-Read, overload handling) kept intact in the tool descriptions and the full playbook kept in one canonical place (server instructions).
This follows the guidance I keep in my Claude Code field notes (claude-code-bible, ch. 7 — "Building MCP Servers"): verbose schema descriptions repeated across tools are the most common silent context tax in MCP servers. I run Claude Code across 100+ projects, several of them with CodeGraph attached, so this overhead multiplies quickly.
Testing
npx tsc --noEmitclean.main, so they're pre-existing).I'll follow up with an issue collecting some larger (breaking) ideas in the same direction — parameterized tool merging and MCP resources — for you to pick from.
🤖 Generated with Claude Code