tambahannnya

This commit is contained in:
bipproduction
2025-11-14 10:24:49 +08:00
parent e0bef23eab
commit 77cbb6062b
2 changed files with 49 additions and 68 deletions

View File

@@ -1,5 +1,6 @@
import { Elysia } from "elysia";
import { getMcpTools } from "../lib/mcp_tool_convert";
import _ from "lodash";
var tools = [] as any[];
const OPENAPI_URL = process.env.BUN_PUBLIC_BASE_URL + "/docs/json";
@@ -118,16 +119,16 @@ async function handleMCPRequestAsync(
const baseUrl =
process.env.BUN_PUBLIC_BASE_URL || "http://localhost:3000";
const result = await executeTool(tool, params?.arguments || {}, baseUrl);
const isObject = typeof result === "object" && result !== null;
const data = result.data.data;
const isObject = _.isObject(data);
return {
jsonrpc: "2.0",
id,
result: {
content: [
isObject
? { type: "json", data: result } // prefer JSON jika client support
: { type: "text", text: String(result) },
? { type: "json", data: data }
: { type: "text", text: String(data) },
],
},
};