File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ def to_function_tool(
5959 """Convert an MCP tool to an Agents SDK function tool."""
6060 invoke_func = functools .partial (cls .invoke_mcp_tool , server , tool )
6161 schema , is_strict = tool .inputSchema , False
62+
63+ # MCP spec doesn't require the inputSchema to have `properties`, but OpenAI spec does.
64+ if "properties" not in schema :
65+ schema ["properties" ] = {}
66+
6267 if convert_schemas_to_strict :
6368 try :
6469 schema = ensure_strict_json_schema (schema )
Original file line number Diff line number Diff line change @@ -260,3 +260,28 @@ async def test_agent_convert_schemas_unset():
260260
261261 assert baz_tool .params_json_schema == possible_to_convert_schema
262262 assert baz_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
263+
264+
265+ @pytest .mark .asyncio
266+ async def test_util_adds_properties ():
267+ """The MCP spec doesn't require the inputSchema to have `properties`, so we need to add it
268+ if it's missing.
269+ """
270+ schema = {
271+ "type" : "object" ,
272+ "description" : "Test tool" ,
273+ }
274+
275+ server = FakeMCPServer ()
276+ server .add_tool ("test_tool" , schema )
277+
278+ tools = await MCPUtil .get_all_function_tools ([server ], convert_schemas_to_strict = False )
279+ tool = next (tool for tool in tools if tool .name == "test_tool" )
280+
281+ assert isinstance (tool , FunctionTool )
282+ assert "properties" in tool .params_json_schema
283+ assert tool .params_json_schema ["properties" ] == {}
284+
285+ assert tool .params_json_schema == snapshot (
286+ {"type" : "object" , "description" : "Test tool" , "properties" : {}}
287+ )
You can’t perform that action at this time.
0 commit comments