@ 开发种子/ mcp- 视图
风景桥 MCP 应用程序
UI 视图: ui/* 后Message协议作为三个小函数.
一个 MCP 工具可以传送一个 UI 视图—— 服务器曝光的 HTML 捆绑
ui://<toolset>/<id> 资源,主机在聊天中进行内入
而不是生的JSON。 捆绑在沙箱里 和主机交谈
结束 ui/* JSON - RPC - 后传Message. 此软件包包
官方 SDK
所以你的视野就不用知道 它落在哪个主机了.
npm install @developmentseed/mcp-view
使用
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 登记您的处理器并连接到主机; sendMessage 员额
如用户输入了信息.
从视图中调用工具
当视图比工具的结果更需要绘制自己时——边界 在模型的上下文,一个表格的下一页——它可以 调用工具本身 :
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.
}
这是MCP Apps的 tools/call在服务器主机的代理下,视图来了
从. 结果只回到了观点:没有进入对话
没有模型转弯, 这是区别于 sendMessage。东道主
只运行工具 _meta.ui.visibility 包含 "app"; 一个工具
如spec说.
callTool 与主机解析 CallToolResult,包括一个
isError: true作为SDK的 callServerTool 是的,所以检查 isError 在此之前
画画. 它拒绝当主机回答错误时.
期间可选择识别您的观点 ui/initialize 握个手,叫它
第一次选举之前 onData, (中文(简体) ), sendMessage 或者说 callTool数字 :
import { configure } from "@developmentseed/mcp-view";
configure({ name: "dataset-gallery", version: "1.2.0" });
主机
同样的捆绑在任何MCP Apps主机——克洛德.ai,ChatGPT,
Goose, VS 代码——和网络客户端捆绑在一起
mcp-toolsets-runtime, (中文(简体) ),
它执行本协议的主机端.
观点是渐进增强:工具的 message 和结构化内容
仍然站在自己的一个普通的 MCP客户端 不能让他们,所以
传送一个视图从不会使工具在任何地方无法使用.
为观众服务
构建和提供捆绑是服务器的工作,而不是这个包的工作. 若为
你用着 mcp-toolsets-runtime,声明 VIEWS = {tool_name: view_id} 内
您的工具箱和船运 已建成的捆绑在 <package>/views/<view_id>.html 看到了吗
协商。 。 。 .
页:1
- 仅限无害环境管理,包含类型脚本.
- 与 Python 一起锁定版本
mcp-toolsets-runtime分发,从 同一个仓库.
MIT 发展种子