1010)
1111from uipath .eval .mocks import mockable
1212
13- from uipath_langchain .agent .tools .base_uipath_structured_tool import (
14- BaseUiPathStructuredTool ,
13+ from uipath_langchain .agent .tools .structured_tool_with_argument_properties import (
14+ StructuredToolWithArgumentProperties ,
1515)
1616
1717from ..utils import sanitize_tool_name
@@ -73,6 +73,8 @@ async def create_mcp_tools(
7373 f"(dynamic_tools={ dynamic_tools .value } )"
7474 )
7575
76+ config_tools_by_name = {t .name : t for t in config .available_tools }
77+
7678 if dynamic_tools in (DynamicToolsMode .SCHEMA , DynamicToolsMode .ALL ):
7779 logger .info (f"Fetching tools from MCP server '{ config .slug } ' via list_tools" )
7880 result = await mcpClient .list_tools ()
@@ -96,37 +98,45 @@ async def create_mcp_tools(
9698 f"Filtered to { len (server_tools )} tools matching availableTools"
9799 )
98100
99- mcp_tools = [
100- AgentMcpTool (
101- name = tool .name ,
102- description = tool .description or "" ,
103- input_schema = tool .inputSchema ,
104- output_schema = tool .outputSchema ,
101+ mcp_tools = []
102+ for tool in server_tools :
103+ config_tool = config_tools_by_name .get (tool .name )
104+ argument_properties = config_tool .argument_properties if config_tool else {}
105+ mcp_tools .append (
106+ AgentMcpTool (
107+ name = tool .name ,
108+ description = tool .description or "" ,
109+ input_schema = tool .inputSchema ,
110+ output_schema = tool .outputSchema ,
111+ argument_properties = argument_properties ,
112+ )
105113 )
106- for tool in server_tools
107- ]
108114 else :
109115 mcp_tools = config .available_tools
110116 logger .info (
111117 f"Using { len (mcp_tools )} tools from resource config for "
112118 f"server '{ config .slug } '"
113119 )
114120
115- return [
116- BaseUiPathStructuredTool (
117- name = sanitize_tool_name (mcp_tool .name ),
118- description = mcp_tool .description ,
119- args_schema = mcp_tool .input_schema ,
120- coroutine = build_mcp_tool (mcp_tool , mcpClient ),
121- metadata = {
122- "tool_type" : "mcp" ,
123- "display_name" : mcp_tool .name ,
124- "folder_path" : config .folder_path ,
125- "slug" : config .slug ,
126- },
121+ tools : list [BaseTool ] = []
122+ for mcp_tool in mcp_tools :
123+ tools .append (
124+ StructuredToolWithArgumentProperties (
125+ name = sanitize_tool_name (mcp_tool .name ),
126+ description = mcp_tool .description ,
127+ args_schema = mcp_tool .input_schema ,
128+ coroutine = build_mcp_tool (mcp_tool , mcpClient ),
129+ output_type = Any ,
130+ metadata = {
131+ "tool_type" : "mcp" ,
132+ "display_name" : mcp_tool .name ,
133+ "folder_path" : config .folder_path ,
134+ "slug" : config .slug ,
135+ },
136+ argument_properties = mcp_tool .argument_properties ,
137+ )
127138 )
128- for mcp_tool in mcp_tools
129- ]
139+ return tools
130140
131141
132142def build_mcp_tool (mcp_tool : AgentMcpTool , mcpClient : McpClient ) -> Any :
0 commit comments