/** * In-Memory MCP Server Factory * * Creates an in-memory FrontMCP server that can be consumed by MCP SDK Client. * Useful for testing, embedding in applications, and LangChain integration. */ import { type AuthInfo, type Transport } from '@frontmcp/protocol'; import { type Scope } from '../scope/scope.instance'; /** * Options for creating an in-memory MCP server. */ export interface CreateInMemoryServerOptions { /** Auth info to inject on all client requests */ authInfo?: Partial; /** Custom session ID (auto-generated if not provided) */ sessionId?: string; } /** * Result from creating an in-memory server. */ export interface InMemoryServerResult { /** Transport to pass to MCP Client.connect() */ clientTransport: Transport; /** Set auth info for subsequent requests */ setAuthInfo: (authInfo: Partial) => void; /** Disconnect the in-memory server */ close: () => Promise; } /** * Create an in-memory FrontMCP server that can be consumed by MCP SDK Client. * * This is useful for: * - Testing MCP tools, resources, and prompts * - Embedding FrontMCP in other applications * - Integration with LangChain MCP adapters * - Avoiding HTTP overhead in single-process scenarios * * @example * ```typescript * import { Client } from '@frontmcp/protocol'; * import { FrontMcpInstance, createInMemoryServer } from '@frontmcp/sdk'; * * // Create a FrontMCP instance * const frontMcp = await FrontMcpInstance.createForGraph(config); * const scope = frontMcp.getScopes()[0]; * * // Create in-memory server * const { clientTransport, setAuthInfo, close } = await createInMemoryServer(scope, { * authInfo: { token: 'test-token', user: { sub: 'user-123' } } * }); * * // Connect MCP client * const client = new Client({ name: 'test-client', version: '1.0.0' }); * await client.connect(clientTransport); * * // Use the client * const tools = await client.listTools(); * const result = await client.callTool({ name: 'my-tool', arguments: { foo: 'bar' } }); * * // Change auth context * setAuthInfo({ token: 'new-token', user: { sub: 'other-user' } }); * * // Cleanup * await close(); * ``` * * @example * ```typescript * // With LangChain MCP adapters * import { createInMemoryServer } from '@frontmcp/sdk'; * * const { clientTransport, setAuthInfo } = await createInMemoryServer(scope); * * // LangChain's MCP adapter can use the transport directly * const client = new MultiServerMCPClient({ * servers: [{ * name: 'frontmcp', * transport: clientTransport, * }] * }); * ``` */ export declare function createInMemoryServer(scope: Scope, options?: CreateInMemoryServerOptions): Promise; //# sourceMappingURL=in-memory-server.d.ts.map