Adds langchain.mcp adapter for MCP servers
LangChain releases langchain.mcp, an adapter converting MCP servers into LangChain agent tools.
Alpha preview of `langchain.mcp` — a first-party adapter that turns any MCP server into LangChain tools you can hand straight to `create_agent`. Connection handling is FastMCP's, so its client features are available as-is rather than re-implemented behind a narrower interface. ```bash pip install "langchain[mcp]==1.4.0a2" ``` Connect `MCPAdapter` takes any target `fastmcp.Client` accepts — transport is inferred, so there is one entry point rather than one per protocol. ```python from langchain.agents import create_agent from langchain.mcp import MCPAdapter async with MCPAdapter("https://example.com/mcp") as adapter: agent = create_agent("anthropic:claude-sonnet-5", await adapter.get_tools()) result = await agent.ainvoke({"messages": [{"role": "user", "content": "..."}]}) ``` Valid targets: a URL, a local script path (launched over stdio), an in-process `FastMCP` server, a config naming several servers at once, or a `fastmcp.Client` you built yourself.
Tools returned by `get_tools()` hold the adapter's client, so they stay callable after the context exits — the `async with` block scopes discovery, not tool lifetime. Auth, caching, timeouts — build the client `MCPAdapter` takes two…