Back to blog
Deployment • 8 min read

Deploy an MCP Server to Vercel

Ship a generated TypeScript MCP server as a Vercel Function with zero framework config, environment variables for upstream credentials, and a public /mcp endpoint.

Vercel deploys Hono applications with zero configuration. Since the generated TypeScript bundle already uses @modelcontextprotocol/hono, most of the work is making sure Vercel picks a request handler instead of the generated Node.js entry point that starts a listener on startup.

The result is a serverless MCP endpoint at https://<project>.vercel.app/mcp, with credentials supplied through environment variables.

Prerequisites

  • A TypeScript server bundle generated by MCP Studio.
  • Node.js 20 or newer installed locally.
  • A Vercel account.
  • The Vercel CLI, or a Git repository connected to a Vercel project.

This path targets the Node.js runtime, not Edge. The generated tools use axios and Node-compatible modules, so keep the default runtime.

1. Install the bundle

Unzip the generated bundle, open a terminal in that directory, and install dependencies.

terminal
npm install

2. Separate the Node entry point

The generated src/server.ts is built for long-running Node processes: it parses CLI flags and defaults to stdio. Vercel scans for Hono entry files, so leaving that file in place can cause the platform to load the wrong module. Rename it and keep it for local transport testing.

terminal
mv src/server.ts src/node-server.ts

Update the scripts in package.json so local runs use the renamed file. The compiled output is now dist/node-server.js.

package.json
{
  "main": "dist/node-server.js",
  "scripts": {
    "build": "tsc",
    "start": "node dist/node-server.js",
    "dev": "tsx watch src/node-server.ts"
  }
}

Keep the rest of the generated package file unchanged. The Node entry is still useful for npm start -- --http --port 3000 when testing outside Vercel.

3. Add the Vercel entry point

Create src/index.ts. It builds the same MCP server, mounts the handler at /mcp, and exports the Hono app as the default export that Vercel expects.

src/index.ts
import { createMcpHandler, McpServer } from '@modelcontextprotocol/server';
import { createMcpHonoApp } from '@modelcontextprotocol/hono';

import { GeneratedApiServerTools } from './Tools/index.js';

function buildServer(): McpServer {
  const server = new McpServer({ name: 'My API', version: '1.0.0' });

  GeneratedApiServerTools.forEach((toolClass) => {
    toolClass.register(server);
  });

  return server;
}

const handler = createMcpHandler(buildServer);
const app = createMcpHonoApp();

app.all('/mcp', (c) => handler.fetch(c.req.raw));
app.get('/', (c) => c.text('MCP server is running. Connect to /mcp.'));

export default app;

If the tools export name differs, check the final export in src/Tools/index.ts. The generated bundle exports one array containing every tool class.

Why no Vercel config: with a hono dependency and a recognized entry file, Vercel builds the app as a Vercel Function automatically. No vercel.json or custom build output is required.

4. Configure environment variables

The bundle README lists the environment variable names produced from your API security schemes. Add each one in the Vercel dashboard under Project Settings, Environment Variables, or from the CLI.

terminal
npx vercel env add MCP_AUTH_API_TOKEN production
npx vercel env add MCP_AUTH_API_KEY production

Add the same values for Preview and Development if you want preview deployments and vercel dev to work. The generated code reads these through process.env, which is available in the Node.js runtime. Changing a variable requires a new deployment to take effect.

5. Run locally and deploy

Vercel CLI runs the same entry point and environment locally. Start the development server and check the root route before deploying.

terminal
npx vercel dev
curl http://localhost:3000/

npx vercel --prod

For a Git-connected project, push the updated bundle and let Vercel build it. The production URL follows this shape, with the MCP endpoint at /mcp:

https://my-mcp-server.vercel.app/mcp

Connect any MCP client that supports Streamable HTTP. For desktop clients that only launch stdio processes, use a bridge such as mcp-remote; see Connecting Generated MCP Servers to Claude Desktop and Cursor.

Operational notes

  • Secure the endpoint. A production deployment is public by default. Upstream credentials stay protected, but the MCP endpoint has no built-in authentication; add Vercel Deployment Protection, an authorization middleware, or a gateway in front of it.
  • Respect function limits. Vercel Functions have maximum durations, and streamed MCP responses count toward them. Check your plan limits and test how your client holds the connection.
  • Expect cold starts. Fluid compute reduces them, but the first request after inactivity can be slower. Keep upstream timeouts in mind for large specifications with many tools.
  • No in-memory state. Each request can reach a different instance. Store sessions or user state externally if your tools need it.
  • Redeploy on spec changes. Regenerate the bundle, reapply the entry-point changes, and deploy again.

Next steps

Vercel is a good middle ground between a global edge runtime and a traditional server: you keep the generated Hono handler and Node-compatible request code without managing a container. If you want the Worker-specific setup, read Deploy an MCP Server to Cloudflare Workers. If you need a container with scale-to-zero for Python, Java, or PHP, read Deploy an MCP Server to Google Cloud Run. For the AWS container path, read Deploy an MCP Server to AWS App Runner. Compare all seven options in Where to Deploy Your MCP Server.

Starting from scratch? Generate a bundle with From OpenAPI to a Running MCP Server.

Need a TypeScript bundle?

Import a spec, choose TypeScript, and download a deployable MCP server.

Upload Spec