@developmentseed/mcp-view

中文文档
0.14.0发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 3160

View-side bridge for MCP Apps UI views: the ui/* postMessage protocol as three small functions (onData / sendMessage / callTool).

原始使用文档
文档目录5 节
  1. Use
  2. Calling a tool from the view
  3. Hosts
  4. Serving the view
  5. Notes

@developmentseed/mcp-view

The view-side bridge for MCP Apps UI views: the ui/* postMessage protocol as three small functions.

An MCP tool can ship a UI view — an HTML bundle the server exposes as a ui://<toolset>/<id> resource, which the host renders inline in the chat instead of raw JSON. The bundle runs in a sandboxed iframe and talks to its host over ui/* JSON-RPC-over-postMessage. This package wraps the official SDK so your view never has to know which host it landed in.

npm install @developmentseed/mcp-view

Use

import { onData, sendMessage } from "@developmentseed/mcp-view";

// The tool's structuredContent, delivered by the host once the tool has run.
onData((data) => render(data));

// A user turn back into the conversation, so the model calls the next tool.
button.onclick = () => sendMessage("clip this to the Severn catchment");

onData registers your handler and connects to the host; sendMessage posts a message as if the user had typed it.

Calling a tool from the view

When the view needs more than the tool's result to draw itself — a boundary too large to put in the model's context, the next page of a table — it can call a tool itself:

import { callTool } from "@developmentseed/mcp-view";

try {
  const result = await callTool("places_get", {
    place_id: data.place_id,
    include: ["boundary"],
  });
  if (result.isError) showProblem(result.content);
  else drawOutline(result.structuredContent);
} catch (error) {
  // The host refused or could not deliver the call.
}

This is MCP Apps' tools/call, proxied by the host to the server the view came from. The result comes back to the view alone: nothing enters the conversation and no model turn is spent, which is the difference from sendMessage. A host only runs tools whose _meta.ui.visibility includes "app"; a tool that declares none is visible to both the model and views, as the spec says.

callTool resolves with the host's CallToolResult, including one with isError: true, as the SDK's callServerTool does, so check isError before drawing. It rejects when the host answers an error.

Optionally identify your view during the ui/initialize handshake — call it before the first onData, sendMessage or callTool:

import { configure } from "@developmentseed/mcp-view";

configure({ name: "dataset-gallery", version: "1.2.0" });

Hosts

The same bundle works unchanged in any MCP Apps host — Claude.ai, ChatGPT, Goose, VS Code — and in the web client bundled with mcp-toolsets-runtime, which implements the host end of this protocol.

Views are progressive enhancement: a tool's message and structured content still stand on their own in a plain MCP client that can't render them, so shipping a view never makes a tool unusable anywhere.

Serving the view

Building and serving the bundle is the server's job, not this package's. If you're using mcp-toolsets-runtime, declare VIEWS = {tool_name: view_id} in your toolset and ship the built bundle at <package>/views/<view_id>.html — see CONSUMING.md.

Notes

  • ESM only, with TypeScript types included.
  • Versioned in lockstep with the Python mcp-toolsets-runtime distribution, from the same repository.

MIT © Development Seed

版本与发布记录

@developmentseed/mcp-view 共发布 54 个版本,首次发布于 2026/07/30;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.14.0latest2026/11/12今天
0.13.32026/11/11今天
0.13.22026/11/11今天
0.13.12026/11/092 天前
0.13.02026/11/092 天前
0.12.62026/11/056 天前

关于 @developmentseed/mcp-view 的常见问题

@developmentseed/mcp-view 是什么?

View-side bridge for MCP Apps UI views: the ui/* postMessage protocol as three small functions (onData / sendMessage / callTool).

如何安装 @developmentseed/mcp-view?

在项目目录运行 npm install @developmentseed/mcp-view,或使用 pnpm add / yarn add / bun add。

@developmentseed/mcp-view 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@developmentseed/mcp-view 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@developmentseed/mcp-view 可以商用吗?

@developmentseed/mcp-view 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@developmentseed/mcp-view 的下载量有多少?

根据 npm 官方下载统计,@developmentseed/mcp-view 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,160 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@developmentseed/mcp-view 还在维护吗?

最新版本 0.14.0 发布于 2026/11/12(今天);至今共发布 54 个版本,其中过去 12 个月发布了 54 个;首次发布于 2026/07/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。