← Back to all tweets

Tweet by @cramforce

View original on X

Looking to ship an MCP server? Just drop this route.ts file into your Next.js app (or any other Node.js-based framework) and deploy to Vercel

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 };
129
Reply