prism-mcp-server 7.6.0 → 7.7.0

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.
@@ -20,6 +20,8 @@ import * as http from "http";
20
20
  import * as path from "path";
21
21
  import * as os from "os";
22
22
  import * as fs from "fs";
23
+ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
24
+ import { createServer } from "../server.js";
23
25
  import { getStorage } from "../storage/index.js";
24
26
  import { PRISM_USER_ID, SERVER_CONFIG } from "../config.js";
25
27
  import { renderDashboardHTML } from "./ui.js";
@@ -89,6 +91,8 @@ export async function startDashboardServer() {
89
91
  maxAttempts: 5,
90
92
  windowMs: 60 * 1000,
91
93
  });
94
+ // Track active SSE transports for MCP
95
+ const activeSSETransports = new Map();
92
96
  /** Render a styled login page matching the Mind Palace theme */
93
97
  function renderLoginPage() {
94
98
  return `<!DOCTYPE html>
@@ -204,7 +208,7 @@ return false;}
204
208
  // ─── v5.1: Auth gate — block unauthenticated requests ───
205
209
  if (AUTH_ENABLED && !isAuthenticated(req, authConfig)) {
206
210
  // For API calls, return 401 JSON
207
- if (reqUrl.pathname.startsWith("/api/")) {
211
+ if (reqUrl.pathname.startsWith("/api/") || reqUrl.pathname === "/sse" || reqUrl.pathname === "/messages") {
208
212
  res.writeHead(401, { "Content-Type": "application/json" });
209
213
  return res.end(JSON.stringify({ error: "Authentication required" }));
210
214
  }
@@ -214,6 +218,39 @@ return false;}
214
218
  }
215
219
  try {
216
220
  const url = new URL(req.url || "/", `http://${req.headers.host}`);
221
+ // ─── SSE: MCP Transport Endpoint ───
222
+ if (url.pathname === "/sse" && req.method === "GET") {
223
+ const transport = new SSEServerTransport("/messages", res);
224
+ await transport.start();
225
+ activeSSETransports.set(transport.sessionId, transport);
226
+ transport.onclose = () => {
227
+ activeSSETransports.delete(transport.sessionId);
228
+ };
229
+ try {
230
+ const mcpServer = createServer();
231
+ await mcpServer.connect(transport);
232
+ }
233
+ catch (err) {
234
+ console.error("[Dashboard] SSE Connection failed:", err);
235
+ activeSSETransports.delete(transport.sessionId);
236
+ }
237
+ return; // SSEServerTransport handles keeping the response open
238
+ }
239
+ // ─── SSE: MCP Message Receiver ───
240
+ if (url.pathname === "/messages" && req.method === "POST") {
241
+ const sessionId = url.searchParams.get("sessionId");
242
+ if (!sessionId) {
243
+ res.writeHead(400, { "Content-Type": "text/plain" });
244
+ return res.end("Missing sessionId");
245
+ }
246
+ const transport = activeSSETransports.get(sessionId);
247
+ if (!transport) {
248
+ res.writeHead(404, { "Content-Type": "text/plain" });
249
+ return res.end("Session not found");
250
+ }
251
+ await transport.handlePostMessage(req, res);
252
+ return;
253
+ }
217
254
  // ─── Serve the Dashboard UI ───
218
255
  if (url.pathname === "/" || url.pathname === "/index.html") {
219
256
  res.writeHead(200, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prism-mcp-server",
3
- "version": "7.6.0",
3
+ "version": "7.7.0",
4
4
  "mcpName": "io.github.dcostenco/prism-mcp",
5
5
  "description": "The Mind Palace for AI Agents — adversarial evaluation (PLAN_CONTRACT→EVALUATE anti-sycophancy), fail-closed Dark Factory autonomous pipelines (3-gate parse→type→scope), persistent memory (SQLite/Supabase), ACT-R cognitive retrieval, behavioral learning & IDE rules sync, multi-agent Hivemind, time travel, visual dashboard. Zero-config local mode.",
6
6
  "module": "index.ts",