tambahan
This commit is contained in:
@@ -19,30 +19,52 @@ const MCPRoute = new Elysia()
|
|||||||
.post("/mcp", async ({ body, set }) => {
|
.post("/mcp", async ({ body, set }) => {
|
||||||
set.headers["Content-Type"] = "application/json; charset=utf-8";
|
set.headers["Content-Type"] = "application/json; charset=utf-8";
|
||||||
|
|
||||||
const { id, method, params } = body as { id: string; method: string; params: any };
|
const { id, method, params } = body as any;
|
||||||
|
|
||||||
if (method === "getTools") {
|
if (method === "tools/list") {
|
||||||
return {
|
return {
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
id,
|
id,
|
||||||
result: {
|
result: {
|
||||||
tools: [
|
tools: [
|
||||||
{ name: "sayHello", description: "Returns a greeting" },
|
{
|
||||||
{ name: "getTime", description: "Current server time" },
|
name: "pengajuan-pembuatan-ktp",
|
||||||
|
description: "untuk melakukan pengajuan pembuatan ktp",
|
||||||
|
inputSchema: {
|
||||||
|
type: "object",
|
||||||
|
properties: {
|
||||||
|
JSON: { type: "object" },
|
||||||
|
},
|
||||||
|
required: ["JSON"],
|
||||||
|
additionalProperties: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// ... tambahkan tool lain
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default jika method salah
|
if (method === "tools/call") {
|
||||||
|
// contoh sederhana
|
||||||
|
const { tool, arguments: args } = params;
|
||||||
|
if (tool === "pengajuan-pembuatan-ktp") {
|
||||||
|
return {
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id,
|
||||||
|
result: { message: "Berhasil menerima pengajuan KTP", data: args },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
id,
|
id,
|
||||||
error: {
|
error: {
|
||||||
code: -32601,
|
code: -32601,
|
||||||
message: `Method ${method} not found`,
|
message: `Method ${method} tidak dikenali`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
})
|
||||||
|
|
||||||
export default MCPRoute;
|
export default MCPRoute;
|
||||||
Reference in New Issue
Block a user