McpServer: let a tool choose its structuredContent together with its content
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 47/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- api
调研方向
Start by reading the implementations and tests for McpServer.registerToolkit and toModelOutput, along with the behavior introduced by issues #10733 and #10740. Trace how content mappers produce CallToolResult values and how structuredContent and outputSchema are handled. Done means a mapper can provide both media content and structured data while preserving the output schema, with existing array mapper behavior unchanged.
由索引模型根据 Issue 内容生成。
描述
Note: everything below was written by an AI agent working on the author's behalf and may not have been reviewed by a human.
This is AI-generated; I don't have strong opinions on the API or developer experience and am glad to take whatever shape you prefer, but I do need the functionality.
Problem
#10733 and #10740 let a toolkit tool choose its result content, which covers most of what I needed. One case is left: a result that holds both structured data and media.
My tools return a JSON value that can contain images and audio (base64, as the MCP wire encoding has them). I want the client to get:
- the media as
image/audiocontent blocks, so the model sees them, and - the rest of the value as
structuredContent, without the media, so the bytes are not sent twice and do not count against a client's text limits twice.
Today neither option gives that:
toModelOutputsetscontent, butstructuredContentis always the whole encoded result, media included.- A
contentmapper setscontent, but thenstructuredContentandoutputSchemaare dropped.
What I do today
I carry a patch adding a tool annotation, McpServer.ResultContent, a function from the encoded success value to { content, structuredContent? }. The server decodes what it returns as a CallToolResult, so it uses the wire encoding, and a block that does not decode is an internal tool error. Declared failures, and tools without the annotation, keep the default result.
Proposal
The smallest change that covers it: let the content mapper of registerToolkit (or toModelOutput) return structuredContent as well:
McpServer.registerToolkit(tools, {
content: {
run: (value) => ({
content: mediaBlocks(value),
structuredContent: withoutMedia(value)
})
}
})
Returning an array, as today, keeps the current behaviour. When a mapper returns structuredContent, the tool would keep its outputSchema, and the mapper is then responsible for matching it.
Would you take this, or would you prefer another place for it? I can open a PR.
- 主要语言
- TypeScript
- 星标
- 16.7k
- 派生
- 808
- 平均合并
- 21 小时 22 分钟
- 30 天内合并 PR
- 486
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Effect-TS/effect 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
`@effect/ui-native` (Effect-TS/ui): `kit/VirtualList` `list` part widens `R` to `any`, poisoning enclosing components可能已有人在做 @effect-bot 今天认领。 未关闭
Effect-TS/effect#11097 · 已指派 1 人 ·
维护者通常 1 天内回复
-
`@effect/ui-native` (Effect-TS/ui): Controlled `input` rejected-edit restore never calls `host.commit()`可能已有人在做 @effect-bot 今天认领。 未关闭
Effect-TS/effect#11096 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
agentic-workflows
难度 1/5 1 小时以内 新手友好度 75/100
opencollective/opencollective-frontend#12789 ·
维护者通常 1 天内回复
-
Web download page shows a file as Completed when its download from S3 fails with an error response未关闭bug
难度 2/5 1-3 小时 新手友好度 77/100
awslabs/visual-asset-management-system#2097 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
openwatersio/slackwater#591 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
compiler-explorer/compiler-explorer#9738 ·
维护者通常 2 天内回复