/** * The managed `connectors/` declaration primitive. * * A Managed Deep Agent declares the remote MCP servers whose tools it wants in * `connectors/mcp.ts` with `connectors.mcp(...)`. MDA discovers that * declaration, creates the `@langchain/mcp-adapters` client, loads the tools, * and adds them to the Deep Agent at runtime — the author never imports the MCP * client or calls `getTools()`. * * Only remote MCP servers over HTTP/SSE are supported. Stdio MCP servers are * intentionally out of scope: they introduce process management, packaging, and * sandboxing concerns beyond this POC. * * By default, all tools loaded from each declared server are exposed. Use * `includeTools` or `excludeTools` inside a server config to select a subset by * raw MCP tool name, before any managed `{server}__` prefix is applied. * * @example * ```ts * // connectors/mcp.ts * import { connectors } from "managed-deepagents"; * * export const connector = connectors.mcp({ * mcpServers: { * docs: { * transport: "http", * url: "https://docs.example.com/mcp", * }, * }, * }); * ``` */ import type { Connector } from "../../runtime/connector.js"; /** Per-server MCP tool selection. Names are raw, unprefixed MCP tool names. */ export interface McpToolSelectionConfig { /** * Raw MCP tool names to expose from this server. Names are matched before any * managed `{server}__` prefix is applied. */ includeTools?: string[]; /** * Raw MCP tool names to hide from this server. Names are matched before any * managed `{server}__` prefix is applied. */ excludeTools?: string[]; } /** Shared options for all remote MCP server connections. */ export interface RemoteMcpServerBaseConfig extends McpToolSelectionConfig { /** URL of the remote MCP server endpoint. */ url: string; /** Optional static headers sent when connecting to the MCP server. */ headers?: Record; /** Default timeout, in milliseconds, for tools loaded from this server. */ defaultToolTimeout?: number; } /** Streamable HTTP MCP server connection. */ export interface HttpMcpServerConfig extends RemoteMcpServerBaseConfig { /** Remote transport. `"http"` selects Streamable HTTP. */ transport: "http"; /** * Whether the client may fall back to SSE if the server does not support * Streamable HTTP. Defaults to the behavior of `@langchain/mcp-adapters`. */ automaticSSEFallback?: boolean; } /** Legacy SSE MCP server connection. */ export interface SseMcpServerConfig extends RemoteMcpServerBaseConfig { /** Remote transport. `"sse"` selects legacy SSE. */ transport: "sse"; /** Reconnection behavior for SSE MCP servers. */ reconnect?: { enabled: boolean; maxAttempts?: number; delayMs?: number; }; } /** A remote MCP server connection. Stdio servers are intentionally excluded. */ export type RemoteMcpServerConfig = HttpMcpServerConfig | SseMcpServerConfig; /** Configuration accepted by `connectors.mcp`. */ export interface McpServersConfig { /** * MCP servers to connect to. Each key is the logical server name MDA uses * for validation, tracing metadata, and tool-name prefixing. */ mcpServers: Record; /** * Whether tool names should be prefixed with the MCP server name (e.g. * `docs__search`). Defaults to `true`, which avoids collisions between * authored tools and common MCP tool names like `search` or `read`. */ prefixToolNameWithServerName?: boolean; /** * Whether tool loading should fail if a tool cannot be loaded. Defaults to * `true` — a managed deployment should fail rather than start with a * partially loaded tool surface. */ throwOnLoadError?: boolean; /** * Whether MCP tool outputs should be converted to LangChain standard content * blocks. Defaults to `true` for new managed agents. */ useStandardContentBlocks?: boolean; /** * Behavior when an MCP server cannot be connected. Only `"throw"` is * supported for the POC — a failed connection fails the deployment. */ onConnectionError?: "throw"; } /** * The connector exported from a `connectors/` module for MCP. It is a branded * managed {@link Connector} whose `tools` hook loads the declared MCP tools at * runtime, plus the raw config the loader reads. */ export interface McpServersDefinition extends McpServersConfig, Connector { /** Internal discriminator used by the MDA loader. */ readonly kind: "mcp_servers"; } /** * Declare the MCP servers whose tools should be loaded and added to the managed * Deep Agent at runtime. * * The tools hook runs at agent-graph construction time (inside the managed * runtime), so the MCP client loader is imported lazily — authoring-only * installs never pull in `@langchain/mcp-adapters`. */ export declare const mcpConnector: (config: McpServersConfig) => McpServersDefinition; //# sourceMappingURL=index.d.ts.map