From 42a19ca815885fcfc9bc10e3228abcfd31ba1117 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 19 Sep 2026 00:02:27 +0000 Subject: [PATCH] V2 P0: MCP cortex_explain_memory tool (#77). Co-authored-by: Abhinaysai Kamineni --- mcp/server.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mcp/server.js b/mcp/server.js index 800548a..a3ea14f 100644 --- a/mcp/server.js +++ b/mcp/server.js @@ -165,6 +165,38 @@ server.tool( }, ); +server.tool( + "cortex_explain_memory", + { + description: + "Explain a claim: supporting/conflicting evidence, temporal validity, authority, confidence", + inputSchema: { + type: "object", + properties: { + claim_id: { type: "string" }, + workspace_id: { type: "string" }, + }, + required: ["claim_id", "workspace_id"], + }, + }, + async ({ claim_id, workspace_id }) => { + if (auth.blocked) { + throw new Error( + "Cortex MCP auth error: ENVIRONMENT=production requires CORTEX_API_KEY", + ); + } + const url = `${apiBaseUrl}/evidence/explain/${encodeURIComponent(claim_id)}?workspace_id=${encodeURIComponent(workspace_id)}`; + const response = await fetch(url, { headers: apiHeaders() }); + if (!response.ok) { + throw new Error(`Cortex API /evidence/explain failed with ${response.status}`); + } + const payload = await response.json(); + return { + content: [{ type: "text", text: JSON.stringify(payload, null, 2) }], + }; + }, +); + async function main() { const transport = new StdioServerTransport(); await server.connect(transport);