feat(mcp)!: preload loop tools, trim schemas, and shorten errors

Merged
TH
3h ago
+551-192

Summary

Claude Code defers MCP tool schemas: each tool a run needs costs a tool-search turn, and a failed call to an unloaded tool gets its whole schema appended. This PR cuts both costs.

  • _meta["anthropic/alwaysLoad"] on the new 'loop' tier (part of 'core'): open, snapshot, press, fill, back, wait, scroll; screenshot stays on demand, since preloading it caused detours. Every tool gets _meta["anthropic/searchHint"] from its command text.
  • Extends #4468's operator rule to debug, cost, and responseLevel. A new alias audience sends tool calls to deviceTarget instead of target.
  • Loop tool descriptions carry the command help's usage guidance. batch documents its step shape with the help batch examples.
  • MCP errors show Error (CODE, reason) and one line, then the log path when one exists. MCP open drops Session state:.
tools/listbefore (80075b6)after
total, 62 tools148,296 B114,950 B
always-loaded27,872 B (8)21,377 B (7)

Breaking changes for MCP clients

MCP tool calls are refused for mcpOutputFormat (removed), includeCost, responseLevel, debug, and target; AI SDK calls refuse debug and target and drop the rest. For JSON text, set AGENT_DEVICE_RESPONSE_LEVEL or AGENT_DEVICE_COST; for a form factor, use deviceTarget.

Validation

Focused unit suites, typecheck and lint pass; byte counts come from the built server over stdio. Not device-facing; CI owns full validation.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.