@mgsoftwarebv/mg-dashboard-mcp 2.3.1 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2958,8 +2958,42 @@ async function main() {
2958
2958
  if (httpMode) {
2959
2959
  console.error(`API key validated. Starting Streamable HTTP transport on port ${httpPort}...`);
2960
2960
  const transports = /* @__PURE__ */ new Map();
2961
+ const REST_TOOL_MAP = {
2962
+ "/api/report-coverage": "agent-report-coverage",
2963
+ "/api/report-finding": "agent-report-finding",
2964
+ "/api/save-documentation": "agent-save-documentation",
2965
+ "/api/list-findings": "agent-list-findings",
2966
+ "/api/get-documentation": "agent-get-documentation"
2967
+ };
2961
2968
  const httpServer = createServer(async (req, res) => {
2962
2969
  const url = new URL(req.url ?? "/", `http://localhost:${httpPort}`);
2970
+ const restToolName = REST_TOOL_MAP[url.pathname];
2971
+ if (restToolName && req.method === "POST") {
2972
+ const chunks = [];
2973
+ for await (const chunk of req) chunks.push(chunk);
2974
+ let toolArgs;
2975
+ try {
2976
+ toolArgs = JSON.parse(Buffer.concat(chunks).toString());
2977
+ } catch {
2978
+ res.writeHead(400, { "Content-Type": "application/json" });
2979
+ res.end(JSON.stringify({ error: "Invalid JSON" }));
2980
+ return;
2981
+ }
2982
+ try {
2983
+ const result = await handleAgentTool(restToolName, toolArgs, { supabase, workspaceId: agentWorkspaceId });
2984
+ res.writeHead(200, { "Content-Type": "application/json" });
2985
+ res.end(JSON.stringify({ ok: true, result }));
2986
+ } catch (err) {
2987
+ res.writeHead(500, { "Content-Type": "application/json" });
2988
+ res.end(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
2989
+ }
2990
+ return;
2991
+ }
2992
+ if (url.pathname === "/api/tools" && req.method === "GET") {
2993
+ res.writeHead(200, { "Content-Type": "application/json" });
2994
+ res.end(JSON.stringify({ tools: Object.keys(REST_TOOL_MAP) }));
2995
+ return;
2996
+ }
2963
2997
  if (url.pathname !== "/mcp") {
2964
2998
  res.writeHead(404, { "Content-Type": "text/plain" });
2965
2999
  res.end("Not found");