Share via


McpToolRegistrationService class

Discover MCP servers and list tools formatted for the LangChain Orchestrator. Uses listToolServers to fetch server configs and getTools to enumerate tools.

Methods

addToolServersToAgent(ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>, Authorization, string, TurnContext, string)

Registers MCP tool servers and updates agent options with discovered tools and server configs. Call this to enable dynamic LangChain tool access based on the current MCP environment.

Method Details

addToolServersToAgent(ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>, Authorization, string, TurnContext, string)

Registers MCP tool servers and updates agent options with discovered tools and server configs. Call this to enable dynamic LangChain tool access based on the current MCP environment.

function addToolServersToAgent(agent: ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>, authorization: Authorization, authHandlerName: string, turnContext: TurnContext, authToken: string): Promise<ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>>

Parameters

agent

ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>

The LangChain Agent instance to which MCP servers will be added.

authorization
Authorization

Authorization object for token exchange.

authHandlerName

string

The name of the auth handler to use for token exchange.

turnContext
TurnContext

The TurnContext of the current request.

authToken

string

Optional bearer token for MCP server access.

Returns

Promise<ReactAgent<Record<string, any>, undefined, AnyAnnotationRoot, readonly AgentMiddleware<any, any, any>[]>>

The updated Agent instance with registered MCP servers.