basic mcp working

This commit is contained in:
2025-07-16 15:30:20 -06:00
parent bc2008f455
commit 31ab49ed16
5 changed files with 660 additions and 17 deletions

View File

@@ -0,0 +1,30 @@
import { createMcpHandler } from "mcp-handler";
import { z } from "zod";
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}!` }],
};
}
);
},
{
// Optional server options
},
{
// Optional redis config
redisUrl: process.env.REDIS_URL,
basePath: "/api/mcp", // this needs to match where the [transport] is located.
maxDuration: 60,
verboseLogs: true,
}
);
export { handler as GET, handler as POST };