#!/usr/bin/env node /** * Hippo Memory MCP Server * * Exposes hippo memory as MCP tools over stdio transport. * Uses the programmatic API directly (no child process spawning). * * Usage: hippo mcp (or npx hippo-memory mcp) */ import { type ResolveProjectIdentityOpts } from '../project-identity.js'; /** Test-only: reset the module-level recall-history Map. Call from beforeEach. */ export declare function __resetSessionRecallHistoryMcp(): void; /** Same bounded walk as the CLI (ends at home, so HIPPO_HOME wins over ~/.hippo); cwd/opts are the test seam. */ export declare function findHippoRoot(cwd?: string, opts?: ResolveProjectIdentityOpts): string | null; interface McpRequest { jsonrpc: '2.0'; id: number | string; method: string; params?: Record; } interface McpResponse { jsonrpc: '2.0'; id: number | string; result?: unknown; error?: { code: number; message: string; }; } export type { McpRequest, McpResponse }; /** * Optional execution context threaded from a non-stdio transport. When the * HTTP transport in src/server.ts calls handleMcpRequest, it knows the * server's bound hippoRoot and the auth-resolved tenantId/actor. Passing * those through here lets executeTool skip the findHippoRoot() walk and * the env-based resolveTenantId({}) fallback — both of which would * otherwise produce the wrong store and the wrong tenant for HTTP callers. * * Stdio callers pass nothing; behavior stays unchanged for that path. */ export interface McpContext { hippoRoot: string; tenantId: string; actor: string; /** * Per-client key for state isolation under HTTP-MCP. For stdio: 'stdio-${pid}' * (one process = one client). For HTTP-SSE / HTTP MCP: hash(bearer + remoteAddr) * built by src/server.ts when constructing McpContext for the request. * Optional for backwards compatibility; defaults to `${tenantId}:default`. */ clientKey?: string; } type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue; }; /** * Transport-agnostic MCP dispatcher. Both the stdio loop (below) and the * HTTP/SSE transport in src/server.ts route every incoming JSON-RPC message * through this single function. Returns null for notifications (no response * expected) and a McpResponse otherwise. Errors thrown by `executeTool` are * the caller's problem — wrap with try/catch on the transport side. */ export declare function handleMcpRequest(req: McpRequest, ctx?: McpContext): Promise; /** * Wire stdin/stdout to the dispatcher. Idempotent — only the entrypoint * (cli.ts `hippo mcp`, or running this file directly) should call this. * src/server.ts imports `handleMcpRequest` without invoking this, so the * HTTP daemon does not steal stdin or exit when its parent closes a pipe. */ export declare function startStdioLoop(): void; //# sourceMappingURL=server.d.ts.map