Convert one MCP tool into a LangChain tool.
The returned tool calls the MCP tool through client on every invocation.
FastMCP clients are reentrant, so the tool can open the client itself
whether or not a connection is already held elsewhere.
A server that needs input mid-call is answered with a LangGraph
interrupt() when client carries the interrupt-driving sentinel handler
that MCPAdapter installs — so a human answers and the call resumes, see
langchain.mcp.elicitation. A client that carries a different handler (a
caller's own) uses that handler instead, and one with no handler simply
never gets asked. Which path a call takes is read off the client, so the
behavior matches whatever it was armed with.
An MCP tool that runs and reports failure reaches the model as a
ToolMessage with status="error", carrying the server's own error
content, so an agent can correct itself and retry. Transport failures and
unconvertible content propagate instead, since a model cannot act on them.
Example:
from fastmcp import Client
from langchain.mcp import as_langchain_tool
client = Client("https://example.com/mcp")
async with client:
mcp_tools = await client.list_tools()
tools = [await as_langchain_tool(t, client) for t in mcp_tools]