LangGraph
Connect Madgicx MCP to LangGraph agents using client credentials authentication.
LangGraph
Build ReAct agents with LangGraph and LangChain MCP Adapters that have access to all Madgicx MCP tools.
Prerequisites
- Python 3.10+
- Madgicx client credentials
- An LLM API key (e.g., OpenAI)
Installation
Setup
1. Configure environment variables
2. Add the auth helper
Copy the MadgicxConfidentialClientAuth helper into your project as auth.py. You can also create a custom auth handler if your setup requires different authentication logic.
3. Create the agent
How It Works
MadgicxConfidentialClientAuthobtains an access token using your client credentials- The
httpx_client_factoryinjects the Bearer token into every HTTP request made by the MCP client MultiServerMCPClientdiscovers all Madgicx tools and converts them to LangChain toolscreate_react_agentbuilds a ReAct agent that reasons about which tools to call
Auth injection pattern
LangGraph's MCP adapter uses httpx under the hood. The httpx_client_factory pattern ensures every request carries a fresh access token — the auth helper handles renewal automatically.
Conversational Mode
To maintain conversation history across multiple turns: