You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,3 +138,51 @@ async with MultiServerMCPClient(
138
138
math_response =await agent.ainvoke({"messages": "what's (3 + 5) x 12?"})
139
139
weather_response =await agent.ainvoke({"messages": "what is the weather in nyc?"})
140
140
```
141
+
142
+
## Using with LangGraph API Server
143
+
144
+
> [!TIP]
145
+
> Check out [this guide](https://langchain-ai.github.io/langgraph/tutorials/langgraph-platform/local-server/) on getting started with LangGraph API server.
146
+
147
+
If you want to run a LangGraph agent that uses MCP tools in a LangGraph API server, you can use the following setup:
148
+
149
+
```python
150
+
# graph.py
151
+
from contextlib import asynccontextmanager
152
+
from langchain_mcp_adapters.client import MultiServerMCPClient
153
+
from langgraph.prebuilt import create_react_agent
154
+
from langchain_anthropic import ChatAnthropic
155
+
156
+
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
157
+
158
+
@asynccontextmanager
159
+
asyncdefmake_graph():
160
+
asyncwith MultiServerMCPClient(
161
+
{
162
+
"math": {
163
+
"command": "python",
164
+
# Make sure to update to the full absolute path to your math_server.py file
165
+
"args": ["/path/to/math_server.py"],
166
+
"transport": "stdio",
167
+
},
168
+
"weather": {
169
+
# make sure you start your weather server on port 8000
In your [`langgraph.json`](https://langchain-ai.github.io/langgraph/cloud/reference/cli/#configuration-file) make sure to specify `make_graph` as your graph entrypoint:
0 commit comments