mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
basic mcp working
This commit is contained in:
30
src/app/api/mcp/[transport]/route.ts
Normal file
30
src/app/api/mcp/[transport]/route.ts
Normal 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 };
|
||||
Reference in New Issue
Block a user