feat(mcp): advertise maxResultSizeChars on every tool#380
Merged
Conversation
Injects an `anthropic/maxResultSizeChars` annotation into the `_meta` field of every tool returned by tools/list. Claude Code (and any other client that honors this annotation) raises its inline-response ceiling from the default 50k chars up to the declared value — so large upstream responses (multi-file reads, command output, query results) flow through inline instead of being spilled to disk as a 2KB preview, forcing the agent to waste 3-5 calls recovering the content. Implemented as a single `OnAfterListTools` hook registered in NewMCPProxyServer — zero touches at the tool definition sites, applies uniformly to built-in tools and forwarded upstream tools, and covers every routing mode (default, /mcp/call, direct, code execution). Configurable via the new `max_result_size_chars` field in `mcp_config.json`: - default: 500000 (Claude Code's documented hard max, `IU6=500000`) - 0 : annotation disabled entirely Context: spotted via luutuankiet/mcp-proxy-shim, which solves the same problem client-side by rewriting tools/list responses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
27079ce
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e9b8b70c.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-max-result-size-chars.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 24285979676 --repo smart-mcp-proxy/mcpproxy-go
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Injects an
anthropic/maxResultSizeCharsannotation into the_metafield of every tool returned bytools/list. Claude Code (and any client that honors this annotation) raises its inline-response ceiling from the default 50k chars up to the declared value, so large upstream responses (multi-file reads, command output, query results) flow through inline instead of being spilled to disk as a 2KB preview that forces the agent to burn 3-5 extra calls recovering the content.Why
Claude Code has a hardcoded ~50,000 char ceiling (
Vb_=50000) for MCP tool results. Responses exceeding this are persisted to disk and replaced with a 2KB preview. Tools that declare_meta.anthropic/maxResultSizeCharsget the ceiling raised (Claude Code's own max isIU6=500000).Surfaced via luutuankiet/mcp-proxy-shim, which solves the same problem client-side by rewriting tools/list responses. This brings the fix server-side so every mcpproxy user benefits without running a shim.
Design
Single
OnAfterListToolshook registered inNewMCPProxyServer:/mcp,/mcp/call, direct, code execution — they all share the same Hooks)result.Toolsslice; idempotent and safeConfiguration
New
max_result_size_charsfield inmcp_config.json:500000(default) — Claude Code's documented hard max0— annotation disabled entirelyTests
New
internal/server/mcp_max_result_size_test.go:_metaon every tool, preserves existing fields, no-op when disabled, does not leak Meta pointers across invocations, survives JSON round-tripTest plan
go test ./internal/server/ -run 'TestAnnotateToolsWithMaxResultSize|TestRegisterMaxResultSizeHook'— 11 assertions passgo test ./internal/config/— config field picked upgo vet ./internal/...cleantools/listcarries_meta.anthropic/maxResultSizeChars: 500000on both/mcpand/mcp/callroutesmax_result_size_chars: 0): annotation absent🤖 Generated with Claude Code