greet tool at /api/mcp in your existing TanStack Start app. TanStack Start serves your application and the MCP endpoint together.
Prerequisites
- A working TanStack Start app using React, Vite 8, and TypeScript. Upgrade apps on older Vite majors before installing mcp-use, which requires Vite
^8.0.0. - Node.js 22.22.2 or later. This recipe configures Nitro for a Node.js server deployment.
Add the integration
Install the canary release of mcp-use, which includes the TanStack Start adapter, and Zod in your project:src/mcp. Add a catch-all server route inside your existing src/routes directory:
Define the server
Createsrc/mcp/server.ts. Register a tool that accepts a name and returns a greeting:
src/mcp/server.ts
server.listen(). Configure CORS on MCPServer to allow browser clients such as the Inspector to connect.
Configure the adapter
AddmcpUseTanStackStart before the Start and React plugins in your existing Vite configuration. Keep your application’s other options and plugins:
vite.config.ts
basePath must match the one on MCPServer.
Mount the endpoint
Create the handler insrc/mcp/handler.server.ts. The Vite plugin loads the authored server in its dedicated MCP environment, so this route module does not import server.ts:
src/mcp/handler.server.ts
src/routes/api.mcp.$.ts. Forward all HTTP methods to the handler so it can serve the MCP endpoint and nested asset paths:
src/routes/api.mcp.$.ts
Try it
Start your TanStack Start app with its usual command:Hello, Ada!.
Use your app’s port if it differs from 3000. MCP views share the application’s browser environment for React Fast Refresh and CSS HMR. Server edits replace the MCP instance and interrupt active requests; failed edits retain the last working instance. View registrations and skills refresh without restarting Vite. Configure React, CSS and aliases in the main Vite config.
See the complete TanStack Start example for a runnable application with a shared UI card, an OAuth discovery route, and production build instructions.