Skip to content

Commit 81b3b3b

Browse files
authored
Merge pull request #16 from UiPath/fix/update_retrieval_sample
chore: update mcp remote sample
2 parents c040d8b + f4a3f66 commit 81b3b3b

File tree

4 files changed

+113
-41
lines changed

4 files changed

+113
-41
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+

samples/simple-remote-mcp/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ async def make_graph():
1414
await client.connect_to_server_via_sse(
1515
server_name="hello-world-server",
1616
url=os.getenv("UIPATH_MCP_SERVER_URL"),
17-
headers={"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"},
17+
headers={
18+
"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"
19+
},
1820
timeout=60,
1921
)
2022

2123
tools = client.get_tools()
24+
print(tools)
2225
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
2326
graph = create_react_agent(model, tools=tools)
2427
yield graph

samples/simple-remote-mcp/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ version = "0.0.1"
44
description = "simple-remote-mcp"
55
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
66
dependencies = [
7-
"uipath-sdk==0.0.110",
8-
"uipath-langchain==0.0.81",
7+
"uipath-langchain==0.0.87",
98
"langchain>=0.1.0",
109
"langchain-anthropic>=0.0.1",
1110
"langgraph>=0.3.21",

samples/simple-remote-mcp/uv.lock

Lines changed: 35 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)