Hosting Model Context Protocol Servers on Vercel?

Hi everyone :waving_hand:,

I’m exploring the idea of building a server for the Model Context Protocol, and I’ve been researching various hosting strategies. In a recent discussion, the debate between long-lived and short-lived connections was highlighted, which has significant implications for server architecture.

Given that Vercel offers fluid serverless compute, I’m curious about whether it can effectively support a Model Context Protocol server. Specifically, I’m wondering:

  • Connection Handling: Can Vercel’s serverless platform manage the specific connection patterns (long-lived vs. short-lived) required by the protocol?
  • Performance & Scalability: Are there any performance or scalability concerns when running such a server on Vercel compared to using a traditional server environment?
  • Best Practices: Have others experimented with similar setups, and what insights can you share regarding potential pitfalls or optimizations?

Any insights, experiences, or recommendations would be greatly appreciated. Thanks in advance for your help!

1 Like

Hi @alexbjorlig, that’s a really thoughtful discussion you bring up.

I’ll have to dig in further into the discussion to answer other things but Performance & Scalability wise Vercel should be perfect.

I think [RFC] Replace HTTP+SSE with new "Streamable HTTP" transport by jspahrsummers · Pull Request #206 · modelcontextprotocol/specification · GitHub will open the possibility for Vercel functions.

Let me try making a simple MCP server and host on Vercel. In the meantime, I’m eager to see what others have to pitch in.

Hi @alexbjorlig, I tried building a simple MCP server. It was my first time and had much fun learnings. It worked fine locally but didn’t work as expected once hosted on Vercel.

I think the reason is that the TS SDK is currently on the way to support Server implementation of Streamable HTTP transport by ihrpr · Pull Request #266 · modelcontextprotocol/typescript-sdk · GitHub, which will then open the way for Stateless MCP servers.

I’ll watch the PR and try again once this has been merged.

1 Like

That’s amazing @anshumanb - thank you so much for looking into this.

Things are moving fast, seems like the PR is already merged :face_with_peeking_eye:

1 Like

Hi @alexbjorlig, you’re right. I got the merge notification today. Will take a look as soon as possible.

Hi @alexbjorlig, I tried in the SDK and checked it’s changelog. I think there are more tasks in the follow up: Client implementation of Streamable HTTP transport by ihrpr · Pull Request #290 · modelcontextprotocol/typescript-sdk · GitHub.

1 Like

Ok, let’s await the PR and see what happens then

2 Likes

The PR got merged. But the docs and examples are not updated to explain how to use HTTP without SSE.

I’m keeping an eye on the docs and the repository to see if something comes up.

I’m also super excited to showcase my MCP server hosted on Vercel!

2 Likes

Could be epic - would love to see a guide in sveltekit on Vercel :slight_smile:

1 Like

Have you seen this example?

Hi @jacobparis, yes. It is a good starting point. I made something similar for BMI calculation. But this still uses SSE. I’m waiting for the docs update about serverless hosting so it works just with POST HTTP requests without keeping the connections open.

yeah the lack of stateless streamable HTTP in the initial spec was a big miss, super happy to see they’re coming around on that

It’ll take a bit for all the MCP clients to support streamables but then I think this ecosystem will really take off

2 Likes

Hi @alexbjorlig, we’ve released a new package to support creating MCP servers with stateless HTTP transport. You can learn more about it in our changelog: MCP server support on Vercel - Vercel.

1 Like

@anshumanb this looks very interesting.

The changelog is very short :sweat_smile:

We are currenlty using Svetlekit, so waiting for an adapter there.

Does Vercel imagine this package would wrap everything related to MCP - or are anthropic imports still needed?

I see. I think the package provides abstraction for creating a serverless function route handler for your MCP server so you should be able to use it in any serverless function (TS/JS) hosted on Vercel.

I can try making an example app when I get a chance.

Edit: Currently this package has out of the box support for Next.js. Other frameworks to follow.

Hi @anshumanb - if you have the time/energi to make a POC with Sveltekit it would be amazing :confetti_ball: