1010from llama_index .llms .openai import OpenAI
1111from llama_index .tools .mcp import McpToolSpec
1212from 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" ,
0 commit comments