LangChain 1.4.0a3

1.4.0a3
Added 6
  • Introduce langchain.mcp namespace for adapting MCP servers into LangChain tools
  • Add MCPAdapter class to adapt fastmcp.Client targets including URLs, local scripts, in-process servers, MCPConfig, pre-built clients, and FastMCP ClientGroup
  • Add MCPAdapter.list_tools() method with cache_mode parameter supporting 'use', 'refresh', and 'bypass' options for client-side response caching
  • Add as_langchain_tool() function to convert individual MCP tools for callers managing their own client
  • Add tool metadata grouping under mcp namespace including tool annotations, _meta, and serving server identity
  • Add elicitation='interrupt' parameter to surface server mid-call questions as LangGraph interrupts for human response and run resumption

From LangChain

Third alpha of the 1.4.0 line. This release focuses on the new langchain.mcp namespace for adapting MCP servers into LangChain tools.

langchain.mcp highlights
  • MCPAdapter adapts any target fastmcp.Client accepts — a URL, a local script, an in-process server, an MCPConfig naming several servers, or a pre-built client — as well as a FastMCP ClientGroup for a fleet of servers behind one client.
  • MCPAdapter.list_tools(*, cache_mode="use") discovers and adapts tools, with optional client-side response caching (SEP-2549): use serves a cached list within the server's TTL hint, refresh repopulates it, bypass skips it.
  • as_langchain_tool(tool, client, *, elicitation=None) converts a single MCP tool for callers managing their own client.
  • Tool metadata is grouped under an mcp namespace on each tool: the tool's annotations (snake_case) and _meta under metadata["mcp"]["tool"], and the serving server's identity under metadata["mcp"]["server"].
  • elicitation="interrupt" surfaces a server's mid-call questions as LangGraph interrupts, so a human answers and the run resumes.
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.list_tools())

Requires the mcp extra: pip install "langchain[mcp]" (and fastmcp>=4.0.0).

Install
pip install --pre "langchain==1.4.0a3"

This is a pre-release; install with --pre.


Release notes curated with the assistance of an AI agent.

View original

Upgraded? How did it go?

Discussion