How to build an MCP App
Learn how to build an MCP app using xmcp out-of-the-box support.
MCP Apps is an extension to the Model Context Protocol that enables MCP servers to deliver interactive user interfaces to clients.
xmcp supports building MCP apps natively. Get started by running:
And select the template:
? Select a template: (Use arrow keys)
Default
GPT App
❯ MCP App
This will kickstart your MCP server with the configuration for building an MCP app. You can optionally choose to include Tailwind CSS. By default, widgets are scaffolded using React.
You can also scaffold this template by running npx create-xmcp-app@latest --example mcp-app.
Project Structure
The final project structure will be as follows:
All your widgets will be placed in the src/tools directory. You can scaffold new widgets by running:
npx xmcp create widget <widget-name>Creating a widget
Handler
Compared to the ext-apps approach, xmcp handles resource creation for you. That means you can focus entirely on writing the tool logic that returns a UI to the client, without worrying about any additional setup.
This implies a custom syntax for the tool that will behave as a widget:
Metadata
There are small differences between usual tools and widgets. You’ll notice the metadata now includes a ui property, which guides xmcp to detect it as an MCP app–compatible component.
Resource-specific properties:
csp.connectDomains– Origins for fetch/XHR/WebSocket connectionscsp.resourceDomains– Origins for images, scripts, stylesheets, fonts, and mediadomain– Optional dedicated subdomain for the widget's sandbox origin
For more information on widget metadata, see the MCP Apps Widget Metadata documentation.
The handler function is responsible for rendering the widget UI. By default, it uses React, but you can also use template literals to generate HTML markup.
Read more about the different Tool Handlers here.
Next Steps
- Test your MCP app with MCPJam
- Deploy with Vercel