Skip to content

feat(coding-agent): per-server maxOutputBytes for MCP tool results - #3

Closed
yummybomb wants to merge 1 commit into
mainfrom
hypeship/mcp-output-limit
Closed

yummybomb wants to merge 1 commit into
mainfrom
hypeship/mcp-output-limit

Conversation

@yummybomb

@yummybomb yummybomb commented Oct 9, 2026 •

Copy link
Copy Markdown

Problem

pi cuts the model-facing text of every MCP tool result at a fixed 20KB and saves the full text to a file the model is told to read with offset/limit. Without a tool that can read files, the model never sees the middle.

Example: a session started with --no-builtin-tools and only an MCP server's tools. A tool that lists a browser page's site tools returns about 43KB (10.9k tokens) for four tools. The model gets the start and end of that list. In the cut-out middle are the names and refs it needs to call those tools. It cannot open the saved file, so it re-lists the tools, gets the same cut list, and falls back to other tools.

Change

MCP servers accept maxOutputBytes in mcp.json: the bytes of tool-result text the model sees before the middle is cut. The default stays 20480.

{ "mcpServers": { "browser": { "url": "https://example.com/mcp", "maxOutputBytes": 65536 } } }
  • validateMcpServerConfig rejects values that are not positive integers.
  • createMcpToolDefinition passes the value to convertMcpResult, which passes it to limitMcpContent.
  • read_mcp_resource and the resource list tools keep the 20KB default.
  • docs/mcp.md lists the key.

Testing

  • test/mcp-extension.test.ts: 29 pass. New tests:
    • The config keeps a valid value and rejects 0 and 1.5.
    • A tool definition with maxOutputBytes: 65536 returns 28KB of text whole. With the limit ignored, this test fails.
    • convertMcpResult with maxOutputBytes: 1024 cuts to about 1KB.
  • npm run check: biome passes. tsc errors only on the generated model data, which this checkout does not have, and reports nothing in the changed files.

@yummybomb

Copy link
Copy Markdown
Author

Closing: the bench may move off pi.

@yummybomb yummybomb closed this Oct 9, 2026
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