|
| 1 | +--- |
| 2 | +title: Testing MCP Apps |
| 3 | +--- |
| 4 | + |
| 5 | +# Test Your MCP App |
| 6 | + |
| 7 | +This guide covers two approaches for testing your MCP App: using the `basic-host` reference implementation for local development, or using an MCP Apps-compatible host like Claude\.ai or VS Code. |
| 8 | + |
| 9 | +## Test with basic-host |
| 10 | + |
| 11 | +The [`basic-host`](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-host) example in this repository is a reference host implementation that lets you select a tool, call it, and see your App UI rendered in a sandboxed iframe. |
| 12 | + |
| 13 | +**Prerequisites:** |
| 14 | + |
| 15 | +- Node.js installed |
| 16 | +- Your MCP server running locally (e.g., at `http://localhost:3001/mcp`) |
| 17 | + |
| 18 | +**Steps:** |
| 19 | + |
| 20 | +1. Clone the repository and install dependencies: |
| 21 | + |
| 22 | + ```bash |
| 23 | + git clone https://github.com/modelcontextprotocol/ext-apps.git |
| 24 | + cd ext-apps/examples/basic-host |
| 25 | + npm install |
| 26 | + ``` |
| 27 | + |
| 28 | +2. Start basic-host, pointing it to your MCP server: |
| 29 | + |
| 30 | + ```bash |
| 31 | + SERVERS='["http://localhost:3001/mcp"]' npm start |
| 32 | + ``` |
| 33 | + |
| 34 | + To connect to multiple servers, list them in the array: |
| 35 | + |
| 36 | + ```bash |
| 37 | + SERVERS='["http://localhost:3001/mcp", "http://localhost:3002/mcp"]' npm start |
| 38 | + ``` |
| 39 | + |
| 40 | +3. Open http://localhost:8080 in your browser. |
| 41 | + |
| 42 | +4. Select your server from the dropdown, then select a tool with UI support. |
| 43 | + |
| 44 | +5. Enter any required tool input as JSON and click "Call Tool" to see your App render. |
| 45 | + |
| 46 | +### Debugging with basic-host |
| 47 | + |
| 48 | +The basic-host UI includes collapsible panels to help you debug your App: |
| 49 | + |
| 50 | +- **Tool Input** — The JSON input sent to your tool |
| 51 | +- **Tool Result** — The result returned by your tool |
| 52 | +- **Messages** — Messages sent by your App to the model |
| 53 | +- **Model Context** — Context updates sent by your App |
| 54 | + |
| 55 | +For additional observability, open your browser's developer console. Basic-host logs key events with a `[HOST]` prefix, including server connections, tool calls, App initialization, and App-to-host requests. |
| 56 | + |
| 57 | +## Test with an MCP Apps-compatible host |
| 58 | + |
| 59 | +To test your App in a real conversational environment, install your MCP server in a host that supports MCP Apps: |
| 60 | + |
| 61 | +- Claude\.ai |
| 62 | + - [Remote MCP servers (over HTTP)](https://claude.ai/docs/connectors/custom/remote-mcp) |
| 63 | + - [Local MCP servers (over stdio)](https://claude.ai/docs/connectors/custom/desktop-extensions) |
| 64 | +- [VS Code Copilot](https://code.visualstudio.com/docs/copilot/customization/mcp-servers) |
| 65 | + |
| 66 | +Once your server is configured, ask the agent to perform a task related to your App-enhanced tool. For example, if you have a weather App, ask the agent "Show me the current weather." |
| 67 | + |
| 68 | +## Expose local servers with `cloudflared` |
| 69 | + |
| 70 | +Remote hosts like Claude\.ai cannot reach `localhost`. To test a local HTTP server with a remote host, use [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-local-tunnel/) to create a publicly accessible tunnel: |
| 71 | + |
| 72 | +1. Start your MCP server locally (e.g., at `http://localhost:3001/mcp`). |
| 73 | + |
| 74 | +2. Run `cloudflared` to expose your server: |
| 75 | + |
| 76 | + ```bash |
| 77 | + npx cloudflared tunnel --url http://localhost:3001 |
| 78 | + ``` |
| 79 | + |
| 80 | +3. Copy the generated URL from the `cloudflared` output (e.g., `https://random-name.trycloudflare.com`). |
| 81 | + |
| 82 | +4. Add that URL as a remote MCP server in your host, appending your MCP endpoint path (e.g., `https://random-name.trycloudflare.com/mcp`). |
| 83 | + |
| 84 | +> [!NOTE] |
| 85 | +> The tunnel URL changes each time you restart `cloudflared`. |
0 commit comments