← Back to all tweets

Tweet by @cramforce

View original on X

One interesting nuance here is that the adapter we built doesn't have a particular dependency on Vercel. That's why it just works in local dev AND if you manage your own hosting with multiple node processes or machines, it also routes the stateful MCP traffic properly. So this gives you scalable MCP operation without sticky load balancing or proprietary tech like durable objects

Vercel
Vercel
@vercel

MCP allows you to build integrations for AI models. Deploy your Model Context Protocol (MCP) server on Vercel and connect to it from clients like Claude, Cursor, and more. Learn more and get started with our updated template. vercel.com/changelog/mcp-…

Code snippet: // app/api/[transport]/route.ts

import { createMcpHandler } from '@vercel/mcp-adapter';

const handler = createMcpHandler(server => {
  server.tool(
    'roll_dice',
    'Rolls an N-sided die',
    { sides: z.number().int().min(2) },
    async ({ sides }) => {
      const value = 1 + Math.floor(Math.random() * sides);
      return { content: [{ type: 'text', text: `🎲 You rolled a ${value}!` }] };
    }
  );
});

export { handler as GET, handler as POST, handler as DELETE };
28
Reply