LangChainMCPAgent connects LangChain chat models and callbacks to MCP tools. Import it from @mcp-use/agent/langchain.
When to use LangChainMCPAgent
UseLangChainMCPAgent when you need at least one of these capabilities:
- an existing LangChain chat model or custom LangChain tool;
- Zod structured-output conversion after an agent run;
- LangChain
StreamEventoutput orprettyStreamEvents(); - Server Manager for on-demand access to one MCP server’s tools; or
- LangChain callbacks, Langfuse tracing, metadata, and tags.
Install LangChainMCPAgent
Install the agent package, LangChain core packages, and the provider package for your model.zod for structured output. Add langfuse and langfuse-langchain for built-in Langfuse tracing.
Run a LangChain agent
SetOPENAI_API_KEY, then run:
package.json. LangChainMCPAgent defaults to 5 model-call steps.
Next steps
Structured output
Convert final text into validated Zod data.
Server Manager
Load one server’s tools on demand.
Observability
Trace runs with Langfuse or custom callbacks.