Skip to content

refactor(mcp): dedupe tool descriptions against server instructions (~220 tokens/request)#775

Open
sebyx07 wants to merge 1 commit into
colbymchenry:mainfrom
sebyx07:slim-mcp-tool-descriptions
Open

refactor(mcp): dedupe tool descriptions against server instructions (~220 tokens/request)#775
sebyx07 wants to merge 1 commit into
colbymchenry:mainfrom
sebyx07:slim-mcp-tool-descriptions

Conversation

@sebyx07

@sebyx07 sebyx07 commented Jun 10, 2026

Copy link
Copy Markdown

What

Slims the codegraph_node and codegraph_explore descriptions (and node's file param description) in src/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 at initialize and surfaced in the agent's system prompt, per the header comment in server-instructions.ts). Both texts sit in the model's context every turn, so the duplication is paid twice per request:

before after
codegraph_node description 941 chars ~530 chars
codegraph_explore description 609 chars ~350 chars
full tools/list definitions ~8.0KB ~7.1KB

≈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 --noEmit clean.
  • Full suite: 1213 passed, 2 skipped, 0 failed (the 2 tinypool "Worker exited unexpectedly" warnings reproduce identically on unmodified main, so they're pre-existing).
  • No test asserts on these description strings.

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant