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
  • 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
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsOpenai Completions StreamProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
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

constructor
constructor→ MultiServerMCPClient

Create a new MultiServerMCPClient.

Properties

property
config: __type & __type & __type & __type

Methods

method
close→ Promise<void>

Close all connections.

method
getClient→ Promise<Client | undefined>

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

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

Get tools from specified servers as a flattened array.

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

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.

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

List resources from specified servers.

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

List resource templates from specified servers.

Resource templates are used for dynamic resources with parameterized URIs.

method
readResource→ Promise<MCPResourceContent[]>

Read a resource from a specific server.

method
setLoggingLevel→ Promise<void>

Set the logging level for all servers

View source on GitHub