React MCP SPA
React MCP SPA
1つのHTMLブロブにバンドルされ、MCP Appsサーバーによって提供される最小限のReactシングルページアプリケーションです。このSPAはURLパスルーティングを使用せず、MCPホストコンテキストから現在のツール名を読み取ることで、どのページをレンダリングするかを決定します。
レイアウト
packages/ui/ — React + Vite SPA。
vite-plugin-singlefileを使用して単一ファイルのHTMLブロブにビルドされます。packages/mcp/ —
@modelcontextprotocol/ext-apps/serverを使用したMCPサーバー。すべて同じui://リソースを指すツール(show-home、show-counter、show-profile)を登録します。packages/playground/ —
hostContextとtoolResultのJSON入力を備えたモックチャットUI内でSPAをレンダリングする開発専用のハーネス。MCPホストなしでページを試すことができます。
Related MCP server: routine-mcp
インストール
Node.js ≥ 20 および pnpm ≥ 9 が必要です。
pnpm installUIを分離して開発する
pnpm run dev:ui表示されたURL(例: http://localhost:5173)を開きます。SPAはMCPホストが存在しないことを検出し、各ページをプレビューできるようにルートピッカーを表示します。
プレイグラウンド — MCPなしでレンダリングをテストする
pnpm run dev:playgroundhttp://localhost:5174 で開きます。プレイグラウンドはSPAの実際のルートレンダラー(packages/ui/src/Router.tsx の RouteRenderer)を再利用し、モックチャットUIでラップします。ヘッダーには2つのJSONテキストエリアがあります。1つは hostContext(toolInfo.tool.name を介してどのページをレンダリングするかを制御)、もう1つはページに渡される toolResult 用です。プリセットボタンで、登録済みの各ツール用に用意されたコンテキストと結果のペアを読み込むことができます。テキストエリアを編集すると、アシスタントのツール出力バブルがライブで再レンダリングされます。
MCPサーバーのビルドと実行
pnpm run build # builds packages/ui → dist/index.html, then packages/mcp
pnpm run serve:mcp # starts Streamable HTTP server on http://localhost:3001/mcpstdioトランスポートの場合:
pnpm --filter @react-mcp-spa/mcp run serve:stdiocloudflaredによるサーバーの公開
一部のMCPクライアント(ホスト型を含む)はlocalhostに到達できません。 cloudflared を使用して、パブリックHTTPS URLを割り当てるクイックトンネルを開きます。
OSのパッケージマネージャーを使用してcloudflaredをインストールします:
# macOS (Homebrew)
brew install cloudflared
# Linux (Debian/Ubuntu)
# See https://pkg.cloudflare.com/ for the apt repo, or grab the .deb from
# https://github.com/cloudflare/cloudflared/releases
# Windows (winget)
winget install --id Cloudflare.cloudflaredローカルでサーバーを起動します:
pnpm run serve:mcp別のターミナルで以下を実行します:
cloudflared tunnel --url http://localhost:3001
# or: pnpm run tunnelcloudflared は https://<random>.trycloudflare.com のようなURLを出力します。末尾に /mcp を追加し、それをMCPサーバーのURLとして使用します:
https://<random>.trycloudflare.com/mcpトンネルは cloudflared を終了するまで維持されます。安定したホスト名が必要な場合は、クイックトンネルではなく 名前付きCloudflareトンネル を設定してください。
Claude Desktop拡張機能(.mcpb)としてのパッケージ化
このリポジトリには、Claude Desktop用のインストール可能な MCP Bundle を生成するパッカーが同梱されています。この拡張機能はサーバーをstdio経由で実行するため、トンネルは不要です。
pnpm run pack:mcpbこれにより両方のパッケージがビルドされ、コンパイル済みのサーバー + UI HTML + プロダクション用 node_modules が build/mcpb-staging/ 配下にステージングされ、mcpb pack が呼び出されて以下が生成されます:
build/react-mcp-spa.mcpbインストールするには、Finder/エクスプローラーで .mcpb をダブルクリック(またはClaude Desktopにドラッグ)します。Claudeがマニフェストを検証してサーバーを登録します。インストール後、3つのツール(show-home、show-counter、show-profile)が利用可能になり、それぞれがインラインReact UIとしてページをレンダリングします。
バンドルマニフェストは mcpb/manifest.json にあります。新しい拡張機能をリリースする際は、そこで(および packages/mcp/package.json で)version を更新してください。
ルーティングの仕組み
SPAは window.location を読み取りません。代わりに、packages/ui/src/App.tsx が @modelcontextprotocol/ext-apps/react の useApp() を使用して以下を行います:
app.getHostContext().toolInfo.tool.nameを読み取り、ホストがどのツールを呼び出したか(これが「ルート」になります)を把握します。app.ontoolresultをサブスクライブしてサーバーからCallToolResultを受け取り、データとしてページに渡します。app.onhostcontextchangedを監視し、テーマ、セーフエリア、ロケールの更新が正しく再レンダリングされるようにします。
新しいページを追加するには、2段階の変更が必要です:
packages/mcp/src/server.ts で、
_meta.ui.resourceUriが共有リソースui://react-mcp-spa/app.htmlを指すようにツールを登録します。packages/ui/src/App.tsx 内の
renderRoute()に、そのツール名のケースを追加します。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceA framework for building interactive UI applications and React-based widgets for ChatGPT and Claude using the Model Context Protocol. It enables developers to create custom tools and visual components that facilitate rich, bidirectional interaction between AI models and users.3MIT
- Flicense-qualityDmaintenanceA Model Context Protocol (MCP) server built with the mcp-framework for developing and managing custom tools. It provides a structured foundation for building and integrating modular components like data processors and API clients into Claude Desktop.7
- FlicenseAqualityDmaintenanceAn MCP App that renders an interactive dashboard in Claude conversations to unify calendar events, emails, and documents into a single interface. It enables users to manage their daily schedule and perform actions like meeting preparation through bidirectional communication between the UI and the model.2
- Alicense-qualityDmaintenanceAn MCP bridge server that allows AI tools to call functions and execute code directly within a web browser tab. It enables developers to register custom browser-side tools with full access to the DOM, web APIs, and local application state.11Apache 2.0
Related MCP Connectors
Hosted Amazon Seller Central and Amazon Ads MCP server for Claude, ChatGPT, Cursor, and agents.
Hosted Amazon Seller and Vendor MCP server for Claude, ChatGPT, Cursor, Codex, Gemini, Copilot.
Build, deploy, and operate hosted web apps on VibeKit (vibekit.bot) from any MCP client.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/billy-yoyo/McpReactSpa'
If you have feedback or need assistance with the MCP directory API, please join our Discord server