Client for connecting to multiple MCP servers and loading LC tools/resources.
This module provides the MultiServerMCPClient class for managing connections
to multiple MCP servers and loading tools, prompts, and resources from them.
Load MCP prompt and convert to LangChain messages.
Load MCP resources and convert them to LangChain Blob objects.
Create a new session to an MCP server.
Load all available MCP tools and convert them to LangChain tools.
LangChain MCP client callback context.
Callbacks for the LangChain MCP client.
Protocol for tool call interceptors using handler callback pattern.
Interceptors wrap tool execution to enable request/response modification, retry logic, caching, rate limiting, and other cross-cutting concerns. Multiple interceptors compose in "onion" pattern (first is outermost).
The handler can be called multiple times (retry), skipped (caching/short-circuit), or wrapped with error handling. Each handler call is independent.
Similar to LangChain's middleware pattern but adapted for MCP remote tools.
Protocol for creating httpx.AsyncClient instances for MCP connections.
Configuration for Server-Sent Events (SSE) transport connections to MCP.
Configuration for stdio transport connections to MCP servers.
Connection configuration for Streamable HTTP transport.
Configuration for WebSocket transport connections to MCP servers.
Client for connecting to multiple MCP servers.
Loads LangChain-compatible tools, prompts and resources from MCP servers.