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

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
UniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/mcp-adaptersMultiServerMCPClient
Classā—Since v1.0

MultiServerMCPClient

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

Copy
class MultiServerMCPClient

Used in Docs

  • Model Context Protocol (MCP)

Constructors

Properties

Methods

View source on GitHub
constructor
constructor→ MultiServerMCPClient
property
config: __type & __type & __type & __type
method
close→ Promise<void>
method
getClient→ Promise<Client | undefined>
method
getTools→ Promise<DynamicStructuredTool<ToolInputSchemaBase, any, any, any, string>[]>
method
initializeConnections→ Promise<Record<string, DynamicStructuredTool<ToolInputSchemaBase, any, any, any, string>[]>>
method
listResources→ Promise<Record<string, MCPResource[]>>
method
listResourceTemplates→ Promise<Record<string, MCPResourceTemplate[]>>
method
readResource→ Promise<MCPResourceContent[]>
method
setLoggingLevel→ Promise<void>

Create a new MultiServerMCPClient.

Close all connections.

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

Get tools from specified servers as a flattened array.

Proactively initialize connections to all servers. This will be called automatically when methods requiring an active connection (like getTools or getClient) are called, but you can call it directly to ensure all connections are established before using the tools.

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.

List resources from specified servers.

List resource templates from specified servers.

Resource templates are used for dynamic resources with parameterized URIs.

Read a resource from a specific server.

Set the logging level for all servers