convert_mcp_tool_to_langchain_tool(
session: ClientSession | None,
tool: MCPTool,
*,
connection: Connection | None | Name | Type | Description |
|---|---|---|
session* | ClientSession | None | MCP client session |
tool* | MCPTool | MCP tool to convert |
connection | Connection | None | Default: NoneOptional connection config to use to create a new session
if a |
callbacks | Callbacks | None | Default: None |
tool_interceptors | list[ToolCallInterceptor] | None | Default: None |
server_name | str | None | Default: None |
tool_name_prefix | bool | Default: False |
Convert an MCP tool to a LangChain tool.
NOTE: this tool can be executed only in a context of an active MCP client session.
Optional callbacks for handling notifications and events
Optional list of interceptors for tool call processing
Name of the server this tool belongs to
If True and server_name is provided, the tool name will be
prefixed w/ server name (e.g., "weather_search" instead of "search")