How do I call an MCP server from LangGraph?
Connect and load tools
LangGraph itself does not speak MCP directly, so most projects use an adapter package such as langchain-mcp-adapters. You define the server connection, either as a local command or as a remote URL, and the adapter fetches the tool list from the server.
Once loaded, the tools look like normal LangChain tools. You pass them to your agent or graph node so the model can choose them during a run. Tool descriptions from the server guide the model, so clear server descriptions lead to better tool choices.
- Install the MCP adapter package
- Define the server connection in config
- Load tools from the connected client
- Pass the tools to your agent
Check the tool flow
Log tool calls while you build the graph. This shows whether the model picked the right tool and whether the arguments match the schema. Logs also reveal when the model keeps retrying a tool that never succeeds.
Handle server errors inside your graph so one failed tool does not stop the whole run. Return a clear error message to the model so it can try a different approach.
- Log each tool call and its arguments
- Handle server errors inside the graph
- Return clear error messages to the model
- Watch for repeated failing retries
Common mistakes
- Expecting LangGraph to connect to MCP without an adapter or client code.
- Ignoring tool schemas, which leads to malformed arguments.
- Leaving server connections open after the run finishes.
