SIGN IN SIGN UP

feat(mcp): cut tool-definition context cost 61%; compact tool responses

MCP clients load the tools/list payload into the model's context every
session; ours was 22.3 KB (~5.6k tokens) for nine tools, 53% of it
outputSchema. Following current tool-design guidance (Anthropic's
writing-tools-for-agents, MCP token-optimization practice):

- Stop advertising outputSchema — the projection layer + leak-guard
  suites are the output contract (src/output/schemas.js deleted; the
  SDK-side validation it fed was passthrough anyway). structuredContent
  is still returned alongside text.
- Verb-first, terse descriptions and parameter docs; shared steering
  moves to the server-level `instructions` string clients inject once.
- Compact JSON serialization for every tool/resource response (the
  2-space indentation cost ~20% extra tokens per call for zero gain).
- Leaner agent defaults: search_docs limit 25 (CLI keeps 100), browse
  bounded at 100 via defaultLimit (an unbounded wwdc listing could dump
  thousands of pages into context); browse gains the year arg.
- A budget test pins the whole surface under 10 KB so bloat can't creep
  back; pagination tests retuned to compact-serialization geometry.

tools/list: 22,319 -> 8,806 bytes (~2.2k tokens).
G
Gigi committed
10c3ce1960efbb816a696749acd737a2c16d3423
Parent: d89ea2d