PM

pomerium/mcp-app-typescript-template

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 6 forks 质量 79 趋势 30Apache-2.0

一个使用 Pomerium、模型上下文协议(MCP)TypeScript SDK 的 MCP 应用模板,配有 Node.js 服务器和由 Activate 服务的 React 控件。

概览

一个架构良好的入门模板,展示了使用模型上下文协议(MCP)搭配React小部件构建MCP应用的最佳实践。它利用了TypeScript、Tailwind CSS v4、Pino日志、Storybook和Vitest,打造了强大的开发体验。 - - Node.js服务器,配备 McpServer 和 MCP 应用辅助工具 - - 示例工具,支持 Zod 验证和 UI 绑定 - - 交互式 Echo 组件,含 MCP 应用 API 演示 - - 通过 requestDisplayMode() 实现内联、画中画和全屏,运行时切换 - - Echo 控件中展示 callServerTool、openLink、sendMessage、updateModelContext - - 无传输会话或会话亲和力的按请求服务器工厂 - - 控件通过 Claude 中的 HMR 从 Vite 开发服务器实时加载。

概述(AI 翻译)

一个架构良好的入门模板,展示了使用模型上下文协议(MCP)搭配React小部件构建MCP应用的最佳实践。它利用了TypeScript、Tailwind CSS v4、Pino日志、Storybook和Vitest,打造了强大的开发体验。

特色

  • MCP 服务器 - Node.js 服务器,配备 McpServer 和 MCP 应用辅助工具
  • Echo 工具 - 带有 Zod 验证和 UI 绑定的示例工具
  • React 控件 - 带有 MCP 应用的交互式 Echo 组件 App API 演示
  • 显示模式 - 在线、画中画和全屏,运行时可通过[[T2]切换]
  • App API 演示 - callServerTool、openLink、sendMessage、[[T6]在Echo小部件中展示
  • 无状态MCP HTTP - 无传输会话或会话亲和力的按请求服务器工厂
  • 无构建开发循环 - Widget 从 Vite 开发服务器实时加载,带有 HMR in Claude.ai 和 ChatGPT
  • 容器尺寸 - 利用主机提供的containerDimensions进行响应式控件大小调整
  • 模拟应用 - 无需实时MCP连接的测试和Storybook辅助createMockApp()

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Apps Template

A well-architected starter template demonstrating best practices for building MCP Apps using the Model Context Protocol (MCP) with React widgets. It leverages TypeScript, Tailwind CSS v4, Pino logging, Storybook, and Vitest for a robust development experience.

Features

  • MCP Server - Node.js server with McpServer and MCP Apps helpers
  • Echo Tool - Example tool with Zod validation and UI binding
  • React Widgets - Interactive Echo component with MCP Apps App API demo
  • Display Modes - Inline, picture-in-picture, and fullscreen with runtime toggling via requestDisplayMode()
  • App API Demo - callServerTool, openLink, sendMessage, updateModelContext showcased in the Echo widget
  • Stateless MCP HTTP - Per-request server factories with no transport sessions or session affinity
  • No-Build Dev Loop - Widgets load live from the Vite dev server with HMR in Claude.ai and ChatGPT
  • Container Dimensions - Responsive widget sizing using host-provided containerDimensions
  • Mock App - Drop-in createMockApp() helper for testing and Storybook without a live MCP connection
  • Pino Logging - Structured logging with pretty printing in development
  • TypeScript - Strict mode with ES2023 target
  • Tailwind CSS v4 - Modern styling with dark mode support
  • Storybook - Component development with a11y addon
  • Testing - Vitest for server and widgets with accessibility checks
  • Build Optimizations - Parallel builds, content hashing, compression
  • Docker - Multi-stage builds with health checks
  • Production Ready - Stateless transport, graceful shutdown, and error handling

Architecture

graph TD
    A[MCP Host] -->|HTTPStreamable| B[MCP ServerNode.js + Express]
    B -->|_meta.ui.resourceUri| C[App ViewReact in iframe]

    B -.-> B1[Echo Tool]
    B -.-> B2[Resource Registration]
    B -.-> B3[text/html;profile=mcp-appMIME type]

    C -.-> C1[Receives App.ontoolresult]
    C -.-> C2[callServerTool, openLink,sendMessage, updateModelContext]
    C -.-> C3[Theme, displayMode, safeArea,containerDimensions]

    style A fill:#e1f5ff
    style B fill:#fff4e6
    style C fill:#f3e5f5

Quick Start

Setup time: ~5 minutes (first time)

Prerequisites

  • Node.js 24+ (required for ES2023 support and native type stripping)
    • Verify: node -v (should show v24.0.0 or higher)
  • npm 11+ (ships with Node 24)
    • Verify: npm -v (should show v10.0.0 or higher)

Supported platforms: macOS, Linux, Windows (via WSL2)

Installation & Setup

git clone https://github.com/pomerium/mcp-app-typescript-template your-mcp-app
cd your-mcp-app
npm install
npm run dev
在 GitHub 查看完整 README

安装

npx playwright install --with-deps chromium`.
新手?先看 mcpskill.org 教程 →