Convert an MCP tool to a LangChain tool.
NOTE: this tool can be executed only in a context of an active MCP client session.
convert_mcp_tool_to_langchain_tool(
session: ClientSession | None,
tool: MCPTool,
*,
connection: Connection | None = None,
callbacks: Callbacks | None = None,
tool_interceptors: list[ToolCallInterceptor] | None = None,
server_name: str | None = None,
tool_name_prefix: bool = False
) -> BaseTool| 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: NoneOptional callbacks for handling notifications and events |
tool_interceptors | list[ToolCallInterceptor] | None | Default: NoneOptional list of interceptors for tool call processing |
server_name | str | None | Default: NoneName of the server this tool belongs to |
tool_name_prefix | bool | Default: FalseIf |