Token导航 LogoToken导航TokenDH.com
MCP App Shim logo
开发工具stdio官方级别未说明来源级核验

MCP App Shim

MCP Server

tsx

MCP应用桥接器是一个标准输入/输出(stdio)MCP代理,用于将基于命令行界面(CLI)的MCP客户端(如GitHub Copilot CLI)桥接到具有交互式浏览器界面的MCP应用服务器。

工具数

4

提示词数

0

GitHub Stars

0

资源数

0
开发工具JavaScriptClaude浏览器自动化Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ncosentino

提供方

ncosentino

最后核验

2026/5/17 20:21

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx tsx test/integration.ts

详细介绍

MCP应用程序垫片

一个桥接基于CLI的MCP客户端的stdio MCP代理(如 )to MCP应用程序 具有基于浏览器的交互式UI的服务器。

建造于 尼克·科森蒂诺 支持发展 BrandGhost 的 平台。

示例

通过以下方式在浏览器中呈现的Excalidraw架构图 mcp-app-shim,由Copilot CLI工具调用触发:

Excalidraw diagram rendered via mcp-app-shim

问题

MCP应用服务器(如 排除MCP)使用 registerAppTool() 展示带有交互式HTML小部件的工具。像Claude Desktop或ChatGPT这样的主机会内联渲染这些内容。但是像Copilot CLI这样的基于stdio的客户端不支持MCP Apps UI扩展——它们只看到文本结果,并默默地丢弃交互式内容。

解决方案

mcp-app-shim 位于CLI客户端和上游MCP App服务器之间:

┌──────────────┐   stdio    ┌───────────────┐   HTTP/SSE    ┌──────────────────┐
│  Copilot CLI  │◄─────────►│  mcp-app-shim  │◄────────────►│  MCP App Server  │
│  (or any      │           │                │              │  (Excalidraw,    │
│   MCP client) │           │  ┌──────────┐  │              │   Playground,    │
└──────────────┘           │  │ Browser  │  │              │   custom, etc.)  │
                            │  │ Host     │  │              └──────────────────┘
                            │  └──────────┘  │
                            └───────────────┘
  1. 透明地代理所有工具 --标准工具保持不变
  2. 检测应用程序工具 --工具与 _meta.ui.resourceUri 触发浏览器渲染
  3. 获取HTML资源 从上游服务器
  4. 打开浏览器 包括完整的AppBridge协议支持(工具输入/结果传递, callServerTool 代理)
  5. 返回文本结果 正常连接到CLI客户端

快速开始

先决条件

  • Node.js 18+
  • npm

安装

git clone https://github.com/ncosentino/mcp-app-shim.git
cd mcp-app-shim
npm install
npm run build

与Copilot CLI一起使用

将垫片添加为Copilot CLI配置中任何MCP App服务器的包装器(~/.copilot/mcp-config.json):

{
  "servers": {
    "excalidraw": {
      "command": "node",
      "args": [
        "/path/to/mcp-app-shim/dist/index.js",
        "https://mcp.excalidraw.com/mcp"
      ]
    }
  }
}

就是这样。现在,当Copilot CLI调用Excalidraw工具时,就像 create_view,图表会自动在浏览器中打开。

与Claude Desktop一起使用

添加到您的Claude桌面配置(claude_desktop_config.json):

{
  "mcpServers": {
    "excalidraw": {
      "command": "node",
      "args": [
        "/path/to/mcp-app-shim/dist/index.js",
        "https://mcp.excalidraw.com/mcp"
      ]
    }
  }
}

从命令行使用

# Run directly
node dist/index.js https://mcp.excalidraw.com/mcp

# Or if installed globally / via npx
mcp-app-shim https://mcp.excalidraw.com/mcp

集成示例

垫片适用于任何使用 registerAppTool()@modelcontextprotocol/ext-apps。以下是一些你可以尝试的:

排除MCP

交互式绘图和白板。工具: create_view, export_to_excalidraw, save_checkpoint, read_checkpoint.

{
  "excalidraw": {
    "command": "node",
    "args": ["/path/to/mcp-app-shim/dist/index.js", "https://mcp.excalidraw.com/mcp"]
  }
}

MCP应用游乐场

一个带有交互式工具的演示服务器,如拖放列表排序器、火焰图可视化和特征标志仪表板。

{
  "playground": {
    "command": "node",
    "args": ["/path/to/mcp-app-shim/dist/index.js", "https://playground.mcpapps.dev/mcp"]
  }
}

您自己的MCP应用服务器

如果您使用以下方式构建MCP服务器 registerAppTool(),您可以用垫片包裹它:

{
  "my-app": {
    "command": "node",
    "args": ["/path/to/mcp-app-shim/dist/index.js", "http://localhost:3000/mcp"]
  }
}

一个最小的MCP应用服务器看起来像:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { registerAppTool, registerAppResource } from "@modelcontextprotocol/ext-apps/server";
import { z } from "zod";

const server = new McpServer({ name: "my-app", version: "1.0.0" });

// Register a UI resource (HTML that runs in the browser)
registerAppResource(server, "widget", "ui://my-app/widget", {}, async () => ({
  contents: [{
    uri: "ui://my-app/widget",
    mimeType: "text/html;profile=mcp-app",
    text: `
      
My Widget

      
        import { App } from "https://esm.sh/@modelcontextprotocol/ext-apps";
        const app = new App({ name: "widget", version: "1.0.0" });
        app.ontoolinput = (params) => {
          document.body.innerHTML += "
" + JSON.stringify(params.input) + "
";
        };
        await app.connect();
      
    `
  }]
}));

// Register a tool linked to the UI
registerAppTool(server, "show_widget", {
  description: "Show an interactive widget",
  inputSchema: { query: z.string() },
  _meta: { ui: { resourceUri: "ui://my-app/widget" } }
}, async ({ query }) => {
  return { content: [{ type: "text", text: `Query: ${query}` }] };
});

运作原理

建筑

垫片运行两个本地HTTP服务器:

  • 主页 (端口9271)-渲染外框,管理与填充程序的WebSocket连接,实现 MCP应用程序主机协议
  • 沙盒页面 (端口9272)-安全隔离的不同来源,通过以下方式将应用程序HTML加载到嵌套的iframe中 document.write()

协议流

1. CLI calls tool          →  shim forwards to upstream server
2. Upstream returns result  →  shim checks for _meta.ui.resourceUri
3. If app tool:
   a. Fetch HTML resource from upstream
   b. Start local host/sandbox servers (if not running)
   c. Serve HTML, open browser
   d. WebSocket pushes tool input + result to browser
   e. AppBridge initializes (ui/initialize handshake)
   f. App renders with full interactivity
4. Text result returned to CLI as normal

AppBridge支持

主机页面实现了MCP Apps AppBridge协议:

  • ui/initialize --回应如下 hostInfo, hostCapabilities,以及 hostContext
  • tools/call --代理人 callServerTool 来自应用程序的请求通过垫片返回到上游服务器
  • 工具输入/结果交付 --通过推送 ui/notifications/tool-inputui/notifications/tool-result

发展

# Build
npm run build

# Watch mode
npm run dev

# Run integration tests
npx tsx test/integration.ts

项目结构

src/
  index.ts              # Stdio MCP proxy (main entry point)
  app-host-server.ts    # Express servers + WebSocket + HTML host/sandbox pages
test/
  integration.ts        # Full integration test
  test-server.ts        # Mock MCP server with normal + app tools
  test-client.ts        # Direct client connection test

许可证

麻省理工学院

______________________________________________________________________

由...创建 尼克·科森蒂诺 为了 BrandGhost 的 --人工智能驱动的社交媒体管理平台。

目录标签

目录标签

开发工具JavaScriptClaude浏览器自动化MCP代理本地部署CLI桥接交互式UI

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

tsx

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP