Claude Desktop strips structuredContent from ui/notifications/tool-result — views built per SDK examples render blank

未关闭
#696 2 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
typescript
领域
api

调研方向

使用提供的服务器结果以及在 ontoolresult 中读取 structuredContent 的应用视图,通过 Claude Desktop 1.18286.2 重现该问题。跟踪 tools/call 和 resources/read 之后 ui/notifications/tool-result 的传递;当 structuredContent 按照指定到达视图,且不需要在 content 中重复时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Summary

Claude Desktop (macOS 1.18286.2, checked 2026-07-07) delivers the ui/notifications/tool-result notification to the app view without the structuredContent field, even when the server's CallToolResult includes it. Every SDK example and pattern reads the view's data from result.structuredContent in ontoolresult, so an app built exactly per the docs mounts, completes the handshake, receives the result, renders nothing, reports ~zero height via auto-resize and is collapsed to an invisible widget. There is no error anywhere: server logs look healthy and the chat just shows no widget.

Environment

  • Claude Desktop 1.18286.2, macOS (Darwin 25.5)
  • @modelcontextprotocol/ext-apps 1.7.4, @modelcontextprotocol/sdk 1.29.0
  • Local stdio server, pre-bundled with esbuild; view bundled with vite-plugin-singlefile
  • Tool registered via registerAppTool with _meta.ui.resourceUri, an inputSchema and an outputSchema; resource registered via registerAppResource with RESOURCE_MIME_TYPE

What the server returns

return {
  content: [{ type: "text", text: "…spec as fenced json…" }],
  structuredContent: { spec },
  _meta: { "weave/spec": spec },
};

tools/list advertises the matching outputSchema (declaring it made no difference, tested both ways).

Evidence

  1. Instrumented the view to print its lifecycle into the widget. In Claude Desktop it shows the handshake completing and then:

    tool result received but no structuredContent.spec attached

    So the sandbox runs the view, ui/initialize succeeds, the tool-result notification arrives — with structuredContent missing.

  2. The identical built view under an emulated host (iframe + postMessage, responding to ui/initialize and then sending ui/notifications/tool-result with the full CallToolResult) renders correctly and reports its size. The app side follows the protocol; the host delivery differs.

  3. Desktop's MCP server log shows the healthy half: tools/call returning normally and resources/read fetching the view HTML. The stripping happens between the host receiving the result and forwarding it to the view.

  4. A second app on the same machine (single-tool Mermaid viewer built from the SDK examples, verified working end-to-end in Claude Desktop in May 2026) now shows the same symptom for its structuredContent-dependent path. Its editor still fills via ui/notifications/tool-input, which suggests tool-input is forwarded intact while tool-result is stripped of structuredContent.

Expected

Per the spec's data-delivery section, results forwarded to the view include content and optionally structuredContent, with structuredContent/_meta being the channels that do not enter model context. The view should receive structuredContent when the server provided it.

Workaround

Duplicate the payload into the content text (e.g. a fenced JSON block) and parse it in the view when structuredContent is absent. Ugly, but it renders on current Desktop while staying compatible with spec-following hosts.

Possibly related

  • #380 (clarifying content vs structuredContent vs _meta visibility)
  • #646 (basic-host not forwarding tool-result _meta)

🤖 Generated with Claude Code

主要语言
TypeScript
星标
2.9k
派生
387
平均合并
3 小时 21 分钟
30 天内合并 PR
6

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/ext-apps 的其他 Issue

查看 modelcontextprotocol/ext-apps 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。