Deep AgentsDeep Agents 0.7 · Python 3.11+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
28 small wins to finish your pathNext lesson →

MCP tools with MCPAdapter

MCP tools are tools served by a Model Context Protocol server; LangChain's MCPAdapter connects to the server, lists its tools as LangChain tools, and a deep agent takes them like any other tools.

Last updated: 29 Sep, 2026 · Deep Agents 0.7

The video lists MCP support as something Deep Agents and the Claude Agent SDK share. The docs connect MCP servers through langchain.mcp.MCPAdapter, new in LangChain 1.4 and in beta. It takes a URL, a script path, or a FastMCP server object, and works out the transport. This lesson gives the trip planner a weather server, so it can pick an indoor day for the Louvre.

Installing MCP support

pip install "langchain[mcp]==1.4.3"

The mcp extra installs FastMCP, which runs both the client and the server.

The MCPAdapter syntax

python
async with MCPAdapter(target) as adapter:   # a URL, a Path to a script, or a FastMCP server
    tools = await adapter.list_tools()
    agent = create_deep_agent(model=model, tools=tools)

A weather MCP server

A FastMCP server with one tool, forecast. Passing the server object itself runs it in the same process, with no subprocess or socket, which the docs call ideal for tests. The forecast is fixed text so the answer can be checked.

python
import asyncio

from deepagents import create_deep_agent
from fastmcp import FastMCP
from langchain.chat_models import init_chat_model
from langchain.mcp import MCPAdapter
python
weather = FastMCP("weather")


@weather.tool
def forecast(city: str) -> str:
    """Get the weather forecast for the next four days in a city."""
    return f"{city}: day 1 sunny 14C, day 2 heavy rain 9C, day 3 cloudy 11C, day 4 sunny 13C"

Asking which day suits a museum

MCP clients are asynchronous, so the agent runs inside async def main() with ainvoke.

ExampleAPI keyweather_trip.py, continued
async def main():
    async with MCPAdapter(weather) as adapter:          # an in-process MCP server
        tools = await adapter.list_tools()
        print("tools from the server:", [t.name for t in tools])
        agent = create_deep_agent(
            model=init_chat_model("groq:openai/gpt-oss-120b", temperature=0, max_retries=6),
            tools=tools,
            system_prompt="You are a travel planner. Use forecast. Reply in two short sentences.",
        )
        result = await agent.ainvoke({"messages": [{"role": "user", "content": "Which day of my Paris trip is best for an indoor museum?"}]})
        print(result["messages"][-1].text)

asyncio.run(main())

What came back from the server

  • The adapter listed one tool, forecast, with its name and description from the server.
  • The agent called it through MCP and read the four-day forecast.
  • Day 2 is the rainy day, so the agent picked it for an indoor museum.

MCP targets compared

TargetTransportUse it for
A FastMCP server objectIn-processTests and demos
Path("server.py")stdio subprocessA local server script
"https://.../mcp"Streamable HTTPA remote server

Where MCP tools fit

  • Using tools other teams already publish as MCP servers.
  • Sharing one tool server between Claude Code, your deep agent and other clients.
  • Keeping tool code in a separate process or service.
Watch out. A string target must be an http or https URL. For a local script pass a Path; the adapter rejects plain strings that are not URLs.
Try it yourself
  • Add a second tool, sunset(city), to the server and ask which evening suits the Seine cruise.
  • Save the server in weather.py with weather.run() at the bottom and connect with MCPAdapter(Path("weather.py")), after from pathlib import Path.
  • Give the agent search_travel as well and ask for a rainy-day plan with prices.

Every expert started right here.