import type { RegistryAgnosticEngine } from '../core/engine.ts'; import { type Principal } from '../server/principal.ts'; import { McpSessionManager } from './session.ts'; /** * Options for handling one Streamable HTTP MCP request. * * @example * ```ts * import { createMcpSessionManager, type McpHttpRequestOptions } from '@lostgradient/weft/mcp'; * import { Engine, MemoryStorage } from '@lostgradient/weft'; * * await using storage = new MemoryStorage(); * await using engine = new Engine({ storage }); * await using sessionManager = createMcpSessionManager(engine); * * const request = new Request('http://localhost/mcp', { method: 'GET' }); * const options: McpHttpRequestOptions = { * request, * engine, * sessionManager, * authRequired: false, * }; * void options; * ``` */ export type McpHttpRequestOptions = { readonly request: Request; /** * Typed as {@link RegistryAgnosticEngine} (see its JSDoc) rather than the * plain default `Engine`, so both `new Engine({ storage })` and * `Engine.create({ workflows })` type-check here directly. */ readonly engine: RegistryAgnosticEngine; readonly sessionManager: McpSessionManager; readonly principal?: Principal; readonly authRequired: boolean; readonly maxBodyBytes?: number; readonly publicOrigin?: string; readonly trustedHosts?: ReadonlyArray; }; /** * Handle one MCP Streamable HTTP request. * * Most applications should use `serve({ engine })`, which mounts `/mcp` * automatically. Use this helper when embedding the MCP transport in a custom * Bun server. * * @example * ```ts * import { createMcpSessionManager, handleMcpHttpRequest } from '@lostgradient/weft/mcp'; * import { Engine, MemoryStorage } from '@lostgradient/weft'; * * await using storage = new MemoryStorage(); * await using engine = new Engine({ storage }); * await using sessionManager = createMcpSessionManager(engine); * * Bun.serve({ * fetch(request) { * return handleMcpHttpRequest({ * request, * engine, * sessionManager, * authRequired: false, * }); * }, * }); * ``` */ export declare function handleMcpHttpRequest(options: McpHttpRequestOptions): Promise;