Skip to content

Commit e6fc7fd

Browse files
authored
Merge pull request #52 from UiPath/fix/update_remote_mcp_sample
2 parents 9c91df7 + 373e3a0 commit e6fc7fd

3 files changed

Lines changed: 1151 additions & 737 deletions

File tree

samples/simple-remote-mcp-agent/main.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from llama_index.llms.openai import OpenAI
1111
from llama_index.tools.mcp import McpToolSpec
1212
from mcp import ClientSession
13-
from mcp.client.sse import sse_client
13+
from mcp.client.streamable_http import streamablehttp_client
1414

1515

1616
# Define events
@@ -35,16 +35,31 @@ async def process_query(self, ev: UserQueryEvent) -> AgentResponseEvent:
3535
"""Process the user query using the MCP-enabled agent."""
3636

3737
# Initialize MCP client and tools
38-
async with sse_client(
38+
async with streamablehttp_client(
3939
url=os.getenv("UIPATH_MCP_SERVER_URL"),
4040
headers={"Authorization": f"Bearer {os.getenv('UIPATH_ACCESS_TOKEN')}"},
4141
timeout=60,
42-
) as (read, write):
42+
) as (read, write, _get_session_id_callback):
4343
async with ClientSession(read, write) as client_session:
4444
await client_session.initialize()
4545
mcp_tool_spec = McpToolSpec(client=client_session)
4646
tools = await mcp_tool_spec.to_tool_list_async()
4747

48+
# Print name and input schema for each tool
49+
print(f"Available MCP tools: {len(tools)}")
50+
for i, tool in enumerate(tools, 1):
51+
print(f"{i}. {tool.metadata.name}")
52+
if tool.metadata.fn_schema:
53+
fn_schema = tool.metadata.fn_schema
54+
if fn_schema.model_fields:
55+
params = list(fn_schema.model_fields.keys())
56+
else:
57+
params = []
58+
print(f" Parameters: {params}")
59+
else:
60+
print(" Parameters: None")
61+
print("-" * 40)
62+
4863
# Initialize the agent
4964
self.agent = FunctionAgent(
5065
name="UiPath MCP Agent",
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[project]
22
name = "llama-simple-remote-mcp-agent"
3-
version = "0.0.6"
3+
version = "0.0.1"
44
description = "UiPath LlamaIndex Remote MCP Agent"
55
authors = [{ name = "John Doe", email = "john.doe@myemail.com" }]
66
readme = { file = "README.md", content-type = "text/markdown" }
77
requires-python = ">=3.10"
88
dependencies = [
9-
"uipath-llamaindex>=0.0.22",
10-
"llama-index-llms-openai>=0.4.4",
11-
"llama-index-tools-mcp>=0.2.5"
9+
"uipath-llamaindex>=0.0.30",
10+
"llama-index-llms-openai>=0.4.7",
11+
"llama-index-tools-mcp>=0.2.6"
1212
]

0 commit comments

Comments
 (0)