tambahan
This commit is contained in:
@@ -1,42 +1,48 @@
|
|||||||
import { Elysia } from "elysia";
|
import { Elysia } from "elysia";
|
||||||
|
|
||||||
const tools = [
|
|
||||||
{
|
|
||||||
name: "pengajuan-pembuatan-ktp",
|
|
||||||
value: "pengajuan-pembuatan-ktp",
|
|
||||||
description: "untuk melakukan pengajuan pembuatan ktp\nmembutuhkan :\n- jenis\n- name\n- deskripsi",
|
|
||||||
inputSchema: {
|
|
||||||
type: "object",
|
|
||||||
properties: { JSON: {} },
|
|
||||||
required: ["JSON"],
|
|
||||||
additionalProperties: true,
|
|
||||||
$schema: "http://json-schema.org/draft-07/schema#"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "list-layanan-desa-darmasaba",
|
|
||||||
value: "list-layanan-desa-darmasaba",
|
|
||||||
description: "mendapatkan list layanan desa darmasaba",
|
|
||||||
inputSchema: {
|
|
||||||
type: "object",
|
|
||||||
properties: {},
|
|
||||||
additionalProperties: true,
|
|
||||||
$schema: "http://json-schema.org/draft-07/schema#"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const MCPRoute = new Elysia()
|
const MCPRoute = new Elysia()
|
||||||
.post("/mcp", async ({ body, set }) => {
|
.get("/mcp", ({ set }) => {
|
||||||
set.headers["Content-Type"] = "application/json; charset=utf-8";
|
set.headers["Content-Type"] = "application/json; charset=utf-8";
|
||||||
|
return {
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id: null,
|
||||||
|
result: {
|
||||||
|
protocol: "2024-11-05",
|
||||||
|
capabilities: {
|
||||||
|
"tools/list": true,
|
||||||
|
"tools/call": true,
|
||||||
|
},
|
||||||
|
status: "MCP Server Ready",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.post("/mcp", async ({ body, set }) => {
|
||||||
|
set.headers["Content-Type"] = "application/json; charset=utf-8";
|
||||||
|
|
||||||
const { methodName } = body as { methodName: string };
|
const { id, method, params } = body as { id: string; method: string; params: any };
|
||||||
|
|
||||||
if (methodName === "getTools") {
|
if (method === "getTools") {
|
||||||
return { data: tools }; // ✅ sesuai format yang n8n minta
|
return {
|
||||||
}
|
jsonrpc: "2.0",
|
||||||
|
id,
|
||||||
|
result: {
|
||||||
|
tools: [
|
||||||
|
{ name: "sayHello", description: "Returns a greeting" },
|
||||||
|
{ name: "getTime", description: "Current server time" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return { error: "Unsupported method" };
|
// Default jika method salah
|
||||||
});
|
return {
|
||||||
|
jsonrpc: "2.0",
|
||||||
|
id,
|
||||||
|
error: {
|
||||||
|
code: -32601,
|
||||||
|
message: `Method ${method} not found`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
export default MCPRoute;
|
export default MCPRoute;
|
||||||
Reference in New Issue
Block a user