|
| 1 | +# LangGraph Agent with Claude and Tool MCP Servers |
| 2 | + |
| 3 | +This project demonstrates how to create an agent using LangGraph with Claude 3.5 Sonnet which connects to a Remote MCP Server. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The agent uses: |
| 8 | +- Claude 3.5 Sonnet as the language model |
| 9 | +- LangGraph for orchestration |
| 10 | +- Connects to a Remote MCP server |
| 11 | + |
| 12 | +## Architecture |
| 13 | + |
| 14 | +```mermaid |
| 15 | +--- |
| 16 | +config: |
| 17 | + flowchart: |
| 18 | + curve: linear |
| 19 | +--- |
| 20 | +graph TD; |
| 21 | + __start__([<p>__start__</p>]):::first |
| 22 | + agent(agent) |
| 23 | + tools(tools) |
| 24 | + __end__([<p>__end__</p>]):::last |
| 25 | + __start__ --> agent; |
| 26 | + tools --> agent; |
| 27 | + agent -.-> tools; |
| 28 | + agent -.-> __end__; |
| 29 | + classDef default fill:#f2f0ff,line-height:1.2 |
| 30 | + classDef first fill-opacity:0 |
| 31 | + classDef last fill:#bfb6fc |
| 32 | +``` |
| 33 | + |
| 34 | +The workflow follows a ReAct pattern: |
| 35 | +1. Query is sent to the agent (Claude) |
| 36 | +2. Agent decides whether to use tools or provide a final answer |
| 37 | +3. If tools are needed, the request is sent to the remote MCP server |
| 38 | +4. Results from tools are sent back to the agent |
| 39 | +5. Process repeats until the agent has enough information to provide a final answer |
| 40 | + |
| 41 | +## Prerequisites |
| 42 | + |
| 43 | +- Python 3.10+ |
| 44 | +- `langchain-anthropic` |
| 45 | +- `langchain-mcp-adapters` |
| 46 | +- `langgraph` |
| 47 | +- Anthropic API key set as an environment variable |
| 48 | + |
| 49 | +## Installation |
| 50 | + |
| 51 | +```bash |
| 52 | +uv venv -p 3.11 .venv |
| 53 | +.venv\Scripts\activate |
| 54 | +uv sync |
| 55 | +``` |
| 56 | + |
| 57 | +Set your API keys and MCP Remote Server URL as environment variables in .env |
| 58 | + |
| 59 | +```bash |
| 60 | +ANTHROPIC_API_KEY=your_anthropic_api_key |
| 61 | +UIPATH_MCP_SERVER_URL=https://alpha.uipath.com/account/tenant/mcp_/mcp/server_slug/sse |
| 62 | +``` |
| 63 | + |
| 64 | +## Debugging |
| 65 | + |
| 66 | +For debugging issues: |
| 67 | + |
| 68 | +1. Check logs for any connection or runtime errors: |
| 69 | + ```bash |
| 70 | + uipath run agent --debug '{"messages": [{"type": "human", "content": "What is 2+2"}]}' |
| 71 | + ``` |
| 72 | + |
| 73 | + |
0 commit comments