Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

from langchain_mcp_adapters.tools import load_mcp_tools
from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent

server_params = StdioServerParameters(
command="python",
Expand All @@ -77,7 +77,7 @@ async with stdio_client(server_params) as (read, write):
tools = await load_mcp_tools(session)

# Create and run the agent
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
agent_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
```

Expand Down Expand Up @@ -114,7 +114,7 @@ python weather_server.py

```python
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent

client = MultiServerMCPClient(
{
Expand All @@ -132,7 +132,7 @@ client = MultiServerMCPClient(
}
)
tools = await client.get_tools()
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
math_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
weather_response = await agent.ainvoke({"messages": "what is the weather in nyc?"})
```
Expand Down Expand Up @@ -169,7 +169,7 @@ To use it with Python MCP SDK `streamablehttp_client`:
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent
from langchain_mcp_adapters.tools import load_mcp_tools

async with streamablehttp_client("http://localhost:3000/mcp/") as (read, write, _):
Expand All @@ -179,7 +179,7 @@ async with streamablehttp_client("http://localhost:3000/mcp/") as (read, write,

# Get tools
tools = await load_mcp_tools(session)
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
math_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
```

Expand All @@ -188,7 +188,7 @@ Use it with `MultiServerMCPClient`:
```python
# Use server from examples/servers/streamable-http-stateless/
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent

client = MultiServerMCPClient(
{
Expand All @@ -199,7 +199,7 @@ client = MultiServerMCPClient(
}
)
tools = await client.get_tools()
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
math_response = await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
```

Expand All @@ -214,7 +214,7 @@ When connecting to MCP servers, you can include custom headers (e.g., for authen

```python
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent

client = MultiServerMCPClient(
{
Expand All @@ -229,7 +229,7 @@ client = MultiServerMCPClient(
}
)
tools = await client.get_tools()
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
response = await agent.ainvoke({"messages": "what is the weather in nyc?"})
```

Expand Down Expand Up @@ -291,7 +291,7 @@ If you want to run a LangGraph agent that uses MCP tools in a LangGraph API serv
# graph.py
from contextlib import asynccontextmanager
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain.agents import create_agent

async def make_graph():
client = MultiServerMCPClient(
Expand All @@ -310,7 +310,7 @@ async def make_graph():
}
)
tools = await client.get_tools()
agent = create_react_agent("openai:gpt-4.1", tools)
agent = create_agent("openai:gpt-4.1", tools)
return agent
```

Expand Down
Loading