Client for connecting to multiple MCP servers and loading LangChain-compatible tools.
class MCPAdapterCreate an MCP adapter. Construction does not open connections.
Close all connections and clear the discovery caches.
Cancels the current epoch, so in-flight requests reject and a reconnect waiting on its backoff wakes and gives up instead of resurrecting a connection. Concurrent calls share one teardown.
The adapter stays usable afterwards: the server configuration survives, so
a later listTools() discovers again and builds fresh clients rather than
restoring the closed ones. A discovery that arrives mid-close waits for
teardown and then runs in the new epoch.
Get a the MCP client for a specific server. Useful for fetching prompts or resources from that server.
List resources from specified servers.
List resource templates from specified servers.
Resource templates are used for dynamic resources with parameterized URIs.
Get tools from specified servers as a flattened array.
Discover executable LangChain tools grouped by server name. Opens connections as needed and honors the SDK discovery cache.
When a server fails to connect, the client will throw an error if onConnectionError is "throw",
otherwise it will skip the server and continue with the remaining servers.
Read a resource from a specific server.