Create a new MultiServerMCPClient.
Configuration object
Returns clone of server config for inspection purposes.
Client does not support config modifications.
Optional
additionalAn additional prefix to add to the tool name Prefixes are separated by double underscores
(example: mcp__add
).
A map of server names to their configuration
Optional
outputDefines where to place each tool output type in the LangChain ToolMessage. Can be overridden on a per-server basis.
Can be set to content
or artifact
to send all tool output into the ToolMessage.content or
ToolMessage.artifact array, respectively, or you can assign an object that maps each content type
to content
or artifact
.
Items in the content
field will be used as input context for the LLM, while the artifact field is
used for capturing tool output that won't be shown to the model, to be used in some later workflow
step.
For example, imagine that you have a SQL query tool that can return huge result sets. Rather than
sending these large outputs directly to the model, perhaps you want the model to be able to inspect
the output in a code execution environment. In this case, you would set the output handling for the
resource
type to artifact
(its default value), and then upon initialization of your code
execution environment, you would look through your message history for ToolMessage
s with the
artifact
field set to resource
, and use the content
field during initialization of the
environment.
Optional
prefixWhether to prefix tool names with the server name. Prefixes are separated by double
underscores (example: calculator_server_1__add
).
Optional
throwWhether to throw an error if a tool fails to load
Optional
useIf true, the tool will use LangChain's standard multimodal content blocks for tools that output
image or audio content, and embedded resources will be converted to StandardFileBlock
objects.
When false
, all artifacts are left in their MCP format, but embedded resources will be
converted to StandardFileBlock
objects if ClientConfig#outputHandling causes embedded resources to
be treated as content, as otherwise ChatModel providers will not be able to interpret them.
Get a the MCP client for a specific server. Useful for fetching prompts or resources from that server.
The name of the server
The client for the server, or undefined if the server is not connected
Get tools from specified servers as a flattened array.
Rest
...servers: string[]Optional array of server names to filter tools by. If not provided, returns tools from all servers.
A flattened array of tools from the specified servers (or all servers)
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.
A map of server names to arrays of tools
Client for connecting to multiple MCP servers and loading LangChain-compatible tools.