Tool results only fit a runtime agent: split the message from the data at the bridge, and budget the size
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 0
- フォーク
- 1
- 平均マージ
- 13時間 28分
- マージ済み PR(30日)
- 51
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
developmentseed/mcp-toolsets-runtime のほかの issue
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
developmentseed/mcp-toolsets-runtime#195 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
developmentseed/mcp-toolsets-runtime の issue をすべて見る
似ている issue
-
00 - Bug component: numpy.linalg
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
521xueweihan/HelloGitHub#4543 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
emeryberger/CSrankings#15700 ·
メンテナーはふだん 2 日以内に返信
-
Bug | 工作不正常 Triage | 待检查
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
メンテナーはふだん 1 日以内に返信
-
Task select patterns with uppercase letters never match対応中かも @manobhisriram が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信