Build Custom MCP Servers
Copy page
Build your own custom MCP servers
When to Build Custom MCP Servers
Build custom MCP servers when:
- Native servers don't exist for your specific APIs
- You need custom business logic beyond what existing servers provide
- You have proprietary systems that require custom integration
If pre-built servers meet your needs, consider Native MCP servers or Composio's platform instead.
Getting Started
The Quick Start workspace includes a Next.js app in the apps/mcp/app/ directory that you can use to expose your MCP servers.
Each MCP server you create will be exposed on a separate route on this app.
Creating from a template
You can add a custom MCP server template from our template library for common use cases using the CLI.
This will automatically add a custom MCP server template to your Quick Start workspace. After customizing and deploying it, you can register it.
Using Vercel's Template
If you want to create a custom MCP server, you can use Vercel's Next.js MCP template as a starting point.
Create a new directory in your project's apps/mcp/app/ directory with your desired server name (e.g. apps/mcp/app/my-email-mcp/mcp).
Copy the template route.ts file from the Vercel MCP template into apps/mcp/app/[server-name]/mcp/route.ts.
Modify the template route.ts file with your desired tools and resources.
Set the basePath of the createMcpHandler to /[server-name].
Running locally
This will start the server on port 3006.
Deploying to Vercel
Follow the instructions in Deploy to Vercel. If you have already deployed to Vercel, you can simply update the deployment by pushing to the same repository.
Enable Fluid compute and set maxDuration to 800 in apps/mcp/app/[server-name]/[transport]/route.ts if you're on a Pro or Enterprise plan and have long-running operations.