/** * Eddie's Brain MCP — Streamable HTTP entrypoint * * Serves the exact same tool set as the stdio server (see `server.ts`) over * HTTP, so the brain can be hosted as a *remote* MCP that any agent connects * to via a plain URL — no local install, no repo checkout. * * Two handlers, one behavior: * - `handleNodeMcpRequest(req, res)` — for a Node `http.Server` (the local * test server + `createHttpServer()`), using the SDK's * `StreamableHTTPServerTransport`. * - `handleWebMcpRequest(request)` — for Fetch-API runtimes (Netlify * Functions, Cloudflare Workers, Deno, Bun), using the SDK's Web-standard * sibling `WebStandardStreamableHTTPServerTransport`. * * Both run the transport in **stateless** mode (`sessionIdGenerator: undefined`) * with `enableJsonResponse: true`: every POST to `/mcp` gets a fresh server + * transport, does its work, and returns a single JSON response. Statelessness * is what makes this safe to run on serverless (no per-connection state to * pin to one instance). * * The knowledge graph is loaded once per process via `getSharedContext()` and * reused across warm invocations. */ import http from 'node:http'; import type { IncomingMessage, ServerResponse } from 'node:http'; import { type BrainContext } from './server.js'; /** MCP endpoint path. Kept in one place so the Netlify route and the local server agree. */ export declare const MCP_PATH = "/mcp"; /** * Usage-report ingestion path. Downstream products (the Eddie-reporter client) * POST a usage report here. It's a plain REST endpoint — separate from `/mcp` * — so products that don't speak MCP can beacon with a single `fetch`. */ export declare const REPORT_PATH = "/report"; /** * Load (and memoize) the BrainContext. On serverless this runs on the first * request of a cold start and is reused for every subsequent warm request. */ export declare function getSharedContext(): Promise; /** * Handle an MCP request on a Node `http.Server`. Stateless: a fresh server + * transport per request. Uses the SDK's `StreamableHTTPServerTransport`. */ export declare function handleNodeMcpRequest(req: IncomingMessage, res: ServerResponse): Promise; /** * Handle an MCP request using Web-standard `Request`/`Response`. Stateless. * Uses the SDK's `WebStandardStreamableHTTPServerTransport`. Buffers the JSON * response so the per-request server/transport can be closed before returning * (no leak across warm serverless invocations). */ export declare function handleWebMcpRequest(request: Request): Promise; /** Web-standard (Fetch API) handler for POST /report. */ export declare function handleWebReportRequest(request: Request): Promise; /** Node http.Server handler for POST /report. */ export declare function handleNodeReportRequest(req: IncomingMessage, res: ServerResponse): Promise; /** * Create a Node `http.Server` that serves the MCP endpoint at POST `/mcp` and a * tiny health page at `/`. Used by `npm run mcp:http` for local testing before * deploying. */ export declare function createHttpServer(): http.Server; //# sourceMappingURL=http.d.ts.map