File tree Expand file tree Collapse file tree
samples/simple-remote-mcp Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import dotenv
2+ import os
13from contextlib import asynccontextmanager
2- from langchain_mcp_adapters .client import MultiServerMCPClient
34from langgraph .prebuilt import create_react_agent
45from 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
810dotenv .load_dotenv ()
911
10-
1112@asynccontextmanager
1213async 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
Original file line number Diff line number Diff line change @@ -4,13 +4,12 @@ version = "0.0.1"
44description = " simple-remote-mcp"
55authors = [{ name = " John Doe" , email = " john.doe@myemail.com" }]
66dependencies = [
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]
1615requires-python = " >=3.10"
You can’t perform that action at this time.
0 commit comments