Skip to content

Commit 3d52ede

Browse files
authored
Merge pull request #90 from UiPath/fix/simple_remote_agent_sample
samples: update simple remote agent
2 parents 27b82c1 + e160b50 commit 3d52ede

3 files changed

Lines changed: 706 additions & 117 deletions

File tree

samples/simple-remote-mcp/main.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1+
import dotenv
2+
import os
13
from contextlib import asynccontextmanager
2-
from langchain_mcp_adapters.client import MultiServerMCPClient
34
from langgraph.prebuilt import create_react_agent
45
from langchain_anthropic import ChatAnthropic
5-
import dotenv
6-
import os
6+
from langchain_mcp_adapters.tools import load_mcp_tools
7+
from mcp import ClientSession
8+
from mcp.client.sse import sse_client
79

810
dotenv.load_dotenv()
911

10-
1112
@asynccontextmanager
1213
async def make_graph():
13-
async with MultiServerMCPClient() as client:
14-
await client.connect_to_server_via_sse(
15-
server_name="hello-world-server",
16-
url=os.getenv("UIPATH_MCP_SERVER_URL"),
17-
headers={
18-
"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"
19-
},
20-
timeout=60,
21-
)
22-
23-
tools = client.get_tools()
24-
print(tools)
25-
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
26-
graph = create_react_agent(model, tools=tools)
27-
yield graph
14+
async with sse_client(
15+
url=os.getenv("UIPATH_MCP_SERVER_URL"),
16+
headers={"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"},
17+
timeout=60,
18+
) as (read, write):
19+
async with ClientSession(read, write) as session:
20+
await session.initialize()
21+
tools = await load_mcp_tools(session)
22+
print(tools)
23+
model = ChatAnthropic(model="claude-3-5-sonnet-latest")
24+
agent = create_react_agent(model, tools=tools)
25+
yield agent

samples/simple-remote-mcp/pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ version = "0.0.1"
44
description = "simple-remote-mcp"
55
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
66
dependencies = [
7-
"uipath-langchain==0.0.100",
8-
"langchain>=0.1.0",
9-
"langchain-anthropic>=0.0.1",
10-
"langgraph>=0.3.21",
7+
"uipath-langchain==0.0.110",
8+
"langchain>=0.3.25",
9+
"langchain-anthropic>=0.3.13",
10+
"langgraph>=0.4.5",
1111
"python-dotenv>=1.0.0",
12-
"requests>=2.31.0",
13-
"anthropic>=0.8.0",
14-
"langchain-mcp-adapters>=0.0.3"
12+
"anthropic>=0.51.0",
13+
"langchain-mcp-adapters>=0.1.0"
1514
]
1615
requires-python = ">=3.10"

0 commit comments

Comments
 (0)