tambahan
This commit is contained in:
49
src/server/routes/mcp_route.ts
Normal file
49
src/server/routes/mcp_route.ts
Normal 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",
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user