Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions samples/simple-remote-mcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# LangGraph Agent with Claude and Tool MCP Servers

This project demonstrates how to create an agent using LangGraph with Claude 3.5 Sonnet which connects to a Remote MCP Server.

## Overview

The agent uses:
- Claude 3.5 Sonnet as the language model
- LangGraph for orchestration
- Connects to a Remote MCP server

## Architecture

```mermaid
---
config:
flowchart:
curve: linear
---
graph TD;
__start__([<p>__start__</p>]):::first
agent(agent)
tools(tools)
__end__([<p>__end__</p>]):::last
__start__ --> agent;
tools --> agent;
agent -.-> tools;
agent -.-> __end__;
classDef default fill:#f2f0ff,line-height:1.2
classDef first fill-opacity:0
classDef last fill:#bfb6fc
```

The workflow follows a ReAct pattern:
1. Query is sent to the agent (Claude)
2. Agent decides whether to use tools or provide a final answer
3. If tools are needed, the request is sent to the remote MCP server
4. Results from tools are sent back to the agent
5. Process repeats until the agent has enough information to provide a final answer

## Prerequisites

- Python 3.10+
- `langchain-anthropic`
- `langchain-mcp-adapters`
- `langgraph`
- Anthropic API key set as an environment variable

## Installation

```bash
uv venv -p 3.11 .venv
.venv\Scripts\activate
uv sync
```

Set your API keys and MCP Remote Server URL as environment variables in .env

```bash
ANTHROPIC_API_KEY=your_anthropic_api_key
UIPATH_MCP_SERVER_URL=https://alpha.uipath.com/account/tenant/mcp_/mcp/server_slug/sse
```

## Debugging

For debugging issues:

1. Check logs for any connection or runtime errors:
```bash
uipath run agent --debug '{"messages": [{"type": "human", "content": "What is 2+2"}]}'
```


5 changes: 4 additions & 1 deletion samples/simple-remote-mcp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ async def make_graph():
await client.connect_to_server_via_sse(
server_name="hello-world-server",
url=os.getenv("UIPATH_MCP_SERVER_URL"),
headers={"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"},
headers={
"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"
},
timeout=60,
)

tools = client.get_tools()
print(tools)
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
graph = create_react_agent(model, tools=tools)
yield graph
3 changes: 1 addition & 2 deletions samples/simple-remote-mcp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ version = "0.0.1"
description = "simple-remote-mcp"
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
dependencies = [
"uipath-sdk==0.0.110",
"uipath-langchain==0.0.81",
"uipath-langchain==0.0.87",
"langchain>=0.1.0",
"langchain-anthropic>=0.0.1",
"langgraph>=0.3.21",
Expand Down
73 changes: 35 additions & 38 deletions samples/simple-remote-mcp/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading