This commit is contained in:
bipproduction
2025-10-26 20:22:19 +08:00
parent 17004cc835
commit 89809199d3

View File

@@ -0,0 +1,49 @@
import Elysia from "elysia";
import { t } from "elysia";
const MCPRoute = new Elysia({
prefix: "mcp",
tags: ["mcp"],
})
.post("/tools/hello", ({ body }) => {
const { id, method, params } = body;
if (method === "tools/sayHello") {
return {
jsonrpc: "2.0",
id,
result: { message: `Hello from Bun, ${params?.name}` },
};
}
if (method === "tools/list") {
return {
jsonrpc: "2.0",
id,
result: [
{
name: "sayHello",
description: "Greets a user",
},
],
};
}
return {
jsonrpc: "2.0",
id,
error: { code: -32601, message: "Method not found" },
};
}, {
body: t.Object({
method: t.String(),
params: t.Object({
name: t.String(),
}),
id: t.Number(),
}),
detail: {
summary: "hello",
description: "hello world",
}
})