LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
  • Tools
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Decisions
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Compat
  • Event
  • Llms
  • Openai Completions Stream
  • Profile
  • Stream
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Gateway
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

Chat LangChain

What can I help with?

Enter to sendĀ·Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextDecisionsBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsOpenai Completions StreamProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingGatewayHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/mcp-adaptersMultiServerMCPClient
Classā—Since v2.0

MultiServerMCPClient

Client for connecting to multiple MCP servers and loading LangChain-compatible tools.

Copy
class MCPAdapter

Used in Docs

  • Connect an MCP client to a tool kit
  • Connect MCP clients to a Managed Deep Agent
  • Model Context Protocol (MCP) with @langchain/mcp-adapters 1.x
  • Tool Gateway traces and audit log
  • Migrate to @langchain/mcp-adapters 2.0

Constructors

constructor
constructor→ MCPAdapter

Create an MCP adapter. Construction does not open connections.

Properties

property
config: __type

Methods

method
close→ Promise<void>

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.

method
getClient→ Promise<Client | undefined>

Get a the MCP client for a specific server. Useful for fetching prompts or resources from that server.

method
listResources→ Promise<Record<string, __type[]>>

List resources from specified servers.

method
listResourceTemplates→ Promise<Record<string, __type[]>>

List resource templates from specified servers.

Resource templates are used for dynamic resources with parameterized URIs.

method
listTools→ Promise<DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>

Get tools from specified servers as a flattened array.

method
listToolsets→ Promise<Record<string, DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>>

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.

method
readResource→ Promise<__type | __type[]>

Read a resource from a specific server.

deprecatedmethod
getTools→ Promise<DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>
deprecatedmethod
initializeConnections→ Promise<Record<string, DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>>
deprecatedmethod
setLoggingLevel→ Promise<void>
View source on GitHub