Tool results only fit a runtime agent: split the message from the data at the bridge, and budget the size
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing the MCP bridge that builds tool results and tools/list; the issue names the ToolResult contract, StateCaptureMiddleware, and the visibility: ["app"] mechanism. Check the SDK response shape and existing bridge tests, then measure serialized result and definition sizes against the proposed budgets. Done means the ordered bridge changes preserve state and view behavior while returning only message as text.
Written by the indexing model from the issue text.
Description
Toolsets built on this runtime return results that only a runtime agent can take. The agent's StateCaptureMiddleware moves every data field out of the transcript and the model reads message alone. Over plain MCP there is no middleware: the model receives every field, twice (the SDK's indented JSON text and structuredContent), and a result over 1 MiB does not arrive at all.
A tool that returns a large payload, such as a country outline as GeoJSON or a base64 image, passes 1 MiB easily, and a toolset with long docstrings can send a tools/list of 40k characters or more. The runtime agent connects over the same SDK, so a result over 1 MiB most likely fails in the agent too.
What clients allow
| Client | Limit on one tool result |
|---|---|
| Any client on the Python MCP SDK | 1 MiB per response (SSE stream failed: Server-sent event exceeded the 1048576 byte limit), then the call fails |
| Claude Code | warns above 10,000 tokens, cuts off at 25,000 (MAX_MCP_OUTPUT_TOKENS) |
| Gemini CLI | cuts off at 40,000 characters (tools.truncateToolOutputThreshold), rest kept in a temp file |
| ChatGPT | no published figure; cuts silently at a line boundary ("truncated … to fit the tool response budget") and shows the model both the text and structuredContent. A forum report puts the cap on all tool definitions together at 5,000 tokens; unverified |
| Gemini Enterprise | no figure; Google's guidance is to filter and summarise on the server |
So structuredContent is not a place to put what the model should not read, and the strictest published budget is 40,000 characters. A result of about 20,000 characters, text and structured together, fits everywhere with room.
Three readers, one dict
A ToolResult serves the model (message), the agent (data fields captured into state) and a view (large payloads such as a geometry or an image). Over plain MCP all three land on the model. The runtime can keep the dict contract and split the readers at the bridge, so a toolset is written once and works in both places.
Proposed changes
-
contentcarries themessageonly. The bridge emitsTextContent(message)instead of leaving the SDK to serialise the whole dict as indented JSON; data stays instructuredContent. The spec says a server should include a text form for older clients; what the text says is ours. Every result shrinks by half or more (3.6× for nested data such as GeoJSON), with no toolset change. -
A result budget at the bridge.
MCP_RESULT_BUDGET, default about 20,000 characters overcontentplusstructuredContent: a warning in the log when a result exceeds it, and a test helper so a toolset's tests can assert its worst case fits. Today an oversized tool is found by a client failing. -
Large payloads leave the result, through what exists. A view fetches its payload (a full geometry, an image) with an app-only tool (
visibility: ["app"], #220); the model gets a small result:message, an ID, the few values it needs. No new runtime feature.A
Linked[...]field annotation, emitting an MCPresource_linkresolved byresources/read, was considered and dropped: it duplicates@state:handles (a reference instead of a value) with a second mechanism to maintain. Worth reopening if several toolsets in different repos each write the same fetch tool, or a host we care about supports resources but not view-initiated tool calls. -
@state:references optional, not the only form.NotAuthoredstays as the agent's guard against a model-invented value, and a toolset also accepts the literal, validated by shape. Over plain MCP there is no agent-side guard either way; what makes a literal safe is the producing tool putting the value in itsmessage, so the model copies a value it has seen. -
Each docstring once in
tools/list. The bridge sends a tool's docstring as itsdescriptionand again asinputSchema.description, copied from the args model. That can be close to a third of a toolset's definitions. Drop the copy. -
A definitions budget on
tools/list, the same warning for the size of a toolset's tool definitions.
Change 1 needs toolsets ready first
A tool whose message is a stub ("Found 6 records.") and whose answer is only in its data fields works in a plain client today only because the whole dict travels as text. With change 1 a text-only client loses the answer. Such tools already cost the runtime agent a round trip: its model must call inspect_state to read what the tool found. The ToolResult contract should say it plainly: the message alone answers the question; data fields are for state, views and other tools. The authoring skill should say the same, and the result budget's test helper can check that a message is not a stub (for example, a minimum length when data fields are present), as a warning.
Order
Consumers fix stub messages first. Then 1, 2 and 5 in one PR, released with a note that the text part is now the message; 4 and 6 after. 3 is toolset work.
🤖 Generated with Claude Code
- Dominant language
- Python
- Stars
- 0
- Forks
- 1
- Avg merge
- 13h 28m
- Merged PRs (30d)
- 51
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from developmentseed/mcp-toolsets-runtime
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
developmentseed/mcp-toolsets-runtime#195 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in developmentseed/mcp-toolsets-runtime
Similar issues
-
Task select patterns with uppercase letters never matchPossibly taken @manobhisriram claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
app: scripts status: backlog type: housekeeping
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
netbox-community/netbox-scripts#239 ·
Maintainers usually reply within 1 day
-
Lambda deploys fail once the bundle grows by about 254 KBPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
developmentseed/titiler-cmr#341 ·
Maintainers usually reply within 1 day
-
Card tables add "..." to every value in a DataFrame column when any value is longer than 30 charactersPossibly taken @omkarbandikatte claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day