diff --git a/src/server/routes/mcp_route.ts b/src/server/routes/mcp_route.ts index 6e12ea1..6fb017d 100644 --- a/src/server/routes/mcp_route.ts +++ b/src/server/routes/mcp_route.ts @@ -1,48 +1,42 @@ import { Elysia } from "elysia"; -const MCPRoute = new Elysia({ prefix: "" }) // tanpa prefix agar langsung /mcp - .get("/mcp", ({ set }) => { - 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 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 { id, method, params } = body as { id: string; method: string; params: any }; +const MCPRoute = new Elysia() + .post("/mcp", async ({ body, set }) => { + set.headers["Content-Type"] = "application/json; charset=utf-8"; - if (method === "getTools") { - return { - jsonrpc: "2.0", - id, - result: { - tools: [ - { name: "sayHello", description: "Returns a greeting" }, - { name: "getTime", description: "Current server time" }, - ], - }, - }; - } + const { methodName } = body as { methodName: string }; - // Default jika method salah - return { - jsonrpc: "2.0", - id, - error: { - code: -32601, - message: `Method ${method} not found`, - }, - }; - }); + if (methodName === "getTools") { + return { data: tools }; // ✅ sesuai format yang n8n minta + } + + return { error: "Unsupported method" }; + }); export default MCPRoute; \ No newline at end of file