What you’ll build
This guide creates a local server with:- an MCP endpoint at
http://localhost:3000/mcp - an Inspector at
http://localhost:3000/mcp/inspector - a
search-fruitstool that returns a view - a React view at
views/product-search-result/view.tsx
Prerequisites
- Node.js 22.22.2 or higher
- Basic TypeScript and React knowledge
Create the project
Run the MCP Apps template:Run the server
Start the development server:Inspect the view tool
Openindex.ts and find the search-fruits tool. The template includes server branding, 16 fruits, and a second get-fruit-details tool. This excerpt shows the view-bound path you need to understand first.
view.name must match the folder under views/. In this template, product-search-result maps to views/product-search-result/view.tsx.
The structuredContent object becomes view rendering data via useToolContext(). The content array is the short text result the model can read.
Inspect the React view
Openviews/product-search-result/view.tsx. The view reads the tool result with useToolContext().
The generated view includes a carousel, detail panel, display-mode controls, favorites, and tool calls. This excerpt shows the core data access pattern.
status === "pending" before reading toolOutput.
Verify in the Inspector
Use the Inspector to confirm that the server and view work.- Open
http://localhost:3000/mcp/inspector. - Go to the Tools tab.
- Select
search-fruits. - Run the tool with
{ "query": "a" }or{}. - Confirm that the view renders below the tool result.
view.name exactly matches the folder under views/ and that the handler returns structuredContent.
Next steps
- Use
useToolContext()to read tool input, output, and lifecycle status. - Use
useCallTool()when a view needs to call another MCP tool. - Configure Content Security Policy before loading external APIs, images, scripts, embeds, or static assets.