Copy link to headingHow to Add an MCP Server to an Express API
Make your Express API accessible to AI assistants through the Model Context Protocol.

Copy link to headingIntroduction
Your Express API holds valuable data. AI assistants like Claude or Cursor can't access it directly. The Model Context Protocol (MCP) solves this problem by exposing your API as tools that AI models can discover and use.
This guide shows you how to add MCP to Express without rewriting your code. MCP tools will call your existing endpoints internally. Your API structure stays the same. The setup deploys to Vercel as serverless functions.
Testing dividers
Copy link to headingHello world
Copy link to headingWhat You'll Build
You will:
- Create an Express API using Vercel's CLI
- Add a weather endpoint
- Build an MCP server with four specialized tools
- Test with the MCP Inspector
- Connect to Cursor IDE
Topics covered:
- Initialize Express with
vc init - Build REST endpoints
- Add MCP with
mcp-handler - Convert Express req/res to Web API format
- Test MCP tools
- Deploy to Vercel
Copy link to heading1. Initialize an Express Project
Create a new Express project with Vercel's CLI:
Copy link to heading2. Build the Weather API Endpoint
Replace src/index.ts with a weather endpoint:
Copy link to headingAPI Reference
📊 Table:
- Parameter | Description | Next.js | Other Frameworks
- request | An instance of the Request object | NextRequest | Request
- context | Deprecated, use @vercel/functions instead | N/A | waitUntil
Copy link to headingConclusion
You added MCP capabilities to Express. Your server has two interfaces: a REST API and an MCP server for AI assistants. Both share the same business logic.
Key patterns:
- MCP tools wrap existing endpoints
- Adapters bridge Express and Web APIs
- Zod schemas provide validation and documentation
- MCP error format helps AI assistants recover
- MCP Inspector speeds development
Copy link to headingNext steps
- Add tools for more endpoints
- Implement OAuth authentication
- Create tools that combine API calls
- Explore the MCP specification