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
  • Gateway
  • 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 CallingGatewayHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/mcp-adaptersMCPAdapter
Classā—Since v2.0

MCPAdapter

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

Copy
class MCPAdapter

Constructors

Properties

Methods

View source on GitHub
constructor
constructor→ MCPAdapter
property
config: __type
method
close→ Promise<void>
method
getClient→ Promise<Client | undefined>
method
listResources→ Promise<Record<string, __type[]>>
method
listResourceTemplates→ Promise<Record<string, __type[]>>
method
listTools→ Promise<DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>
method
listToolsets→ Promise<Record<string, DynamicStructuredTool<ToolInputSchemaBase, any, any, any, unknown, string>[]>>
method
readResource→ Promise<__type | __type[]>
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>

Create 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.