feat(mcp)!: advertise only agent inputs in MCP tool schemas

Merged
TH
2d ago
+109-60

Summary

tools/list cost ~268 KB. Clients that defer tool schemas then call tools without them, and clients that compact schemas above ~5 KB drop their structure. This cuts the advertised input schemas at their owners (common input fields, MCP control fields, flag inputDescriptions); no per-tool schemas.

  • Breaking (MCP and AI SDK tools): tenant, runId, leaseId, androidDeviceAllowlist become operator-owned. Explicit input is refused with the operator path. Env/config defaults still reach the route (test added).
  • Trimmed repeated property descriptions (device selectors, MCP controls, proxy lease spec, settleQuietMs, open waitMs/metroPort).
  • Server instructions: one sentence to load a deferred tool's schema before its first call.
  • Gate: every input schema ≤ 5 KB, and no declared operator key is advertised, both derived from listCommandTools().
tools/list (62 tools)beforeafter
total268,371 B216,362 B
input schemas168,497 B116,488 B
largest input schema7,109 B (open)4,757 B (open)
repeated common props115,537 B71,066 B
output schemas (untouched)75,699 B75,699 B

12 files. The proxy lease device spec stays advertised (#3864 decided it is agent-visible); only its descriptions shrank.

Validation

validation: CI. At 5d4ac57: focused vitest --project unit-core on src/mcp, src/ai-sdk, packages/command-surface, packages/command-registry, packages/contracts passed (192 files, 1408 tests); pnpm typecheck and oxlint clean. Bytes measured from the built server over stdio.

šŸ¤– Generated with Claude Code