import express from 'express'; import http from 'node:http'; import type { FastMCP } from 'fastmcp'; import type { CorsOptions } from 'cors'; import type { IncomingMessage } from 'node:http'; type JsonRpcRequestBody = { jsonrpc?: string; method?: string; id?: unknown; params?: Record; }; export interface LoggerLike { info?(message: string): void; warn?(message: string): void; error?(message: string, error?: unknown): void; } export interface StartFastMcpHttpProxyOptions { server: FastMCP; listenPort: number; host?: string; logger?: LoggerLike; corsOptions?: CorsOptions; proxyPath?: string; httpModule?: typeof http; startPort?: number; portSearchDirection?: 'up' | 'down'; configureApp?: (app: any) => void; loopbackPort?: number; allowLoopbackFallback?: boolean; /** * Optional callback to inject authenticated context into MCP request body. * Called before forwarding the request to FastMCP. * Use this to extract userId from Authorization header and inject it into params. * * @param headers - Request headers (e.g., for Authorization token) * @param parsedBody - Parsed JSON-RPC request body * @returns Modified body with injected auth context, or original body if no changes */ injectAuthContext?: (headers: IncomingMessage['headers'], parsedBody: JsonRpcRequestBody) => Promise; } export interface StartFastMcpHttpProxyResult { app: express.Express; expressServer: http.Server; mcpPort: number; } /** * Start a FastMCP server using the HTTP stream transport and expose it via an Express proxy. * By default, uses random port selection for the internal FastMCP server (45000-45100 range). * Override with FASTMCP_LOOPBACK_PORT env var or loopbackPort parameter if needed. */ export declare function startFastMcpHttpProxy({ server, listenPort, host, logger, corsOptions, proxyPath, httpModule, startPort, portSearchDirection, configureApp, loopbackPort, allowLoopbackFallback, // Changed default to true for random port behavior injectAuthContext }: StartFastMcpHttpProxyOptions): Promise; export {}; //# sourceMappingURL=startFastMcpHttpProxy.d.ts.map