/** * Self-encoded session tokens for stateless / multi-pod MCP servers. * * A stateless server keeps nothing between requests, so every request starts a * new session and the client name/version (only sent at `initialize`) is lost. * The one value clients replay on every request is the `Mcp-Session-Id` header. * So at `initialize` we mint that header as a token carrying the session id and * client identity — any pod can read them back from the header alone. * * The token is unsigned: it holds only what the client already self-reports. */ export declare const MCP_SESSION_HEADER = "mcp-session-id"; /** What a session token carries. */ export interface SessionTokenPayload { /** PostHog session id (`ses_…`) → `$session_id`. */ sessionId: string; /** MCP client name → `$mcp_client_name`. */ clientName?: string; /** MCP client version → `$mcp_client_version`. */ clientVersion?: string; /** * MCP protocol (spec) version → `$mcp_protocol_version`. The client's * *requested* version — the only one known when the token is minted (before * the initialize handler negotiates). Lets pods that never saw `initialize` * still stamp the spec version on their events. */ protocolVersion?: string; } /** * Encodes a session token for the `Mcp-Session-Id` response header. Also * exported for SSE servers, which flush headers before handlers run and so * must set the header themselves at the HTTP layer. */ export declare function encodeSessionId(payload: SessionTokenPayload): string; /** * Decodes an `Mcp-Session-Id` value into a token payload. Returns `null` for * anything that isn't one of our tokens (transport UUIDs, JWTs, garbage) and * never throws. */ export declare function decodeSessionId(value: unknown): SessionTokenPayload | null; /** * Reads the `mcp-session-id` header off `extra.requestInfo.headers`. The SDK * transports lowercase header keys; the fallback scan covers hand-built extras. */ export declare function readMcpSessionHeader(headers: unknown): string | undefined; /** * Puts a minted token on the transport so it goes out as the `Mcp-Session-Id` * response header. The Node transport's `sessionId` is a getter backed by an * inner web-standard transport, so verify the write by reading back and fall * back to writing the inner one. Returns whether the write stuck; never throws. */ export declare function writeSessionIdToTransport(transport: unknown, token: string): boolean; //# sourceMappingURL=session-token.d.ts.map