File tree 2 files changed +30
-0
lines changed
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(
59
59
"""Convert an MCP tool to an Agents SDK function tool."""
60
60
invoke_func = functools .partial (cls .invoke_mcp_tool , server , tool )
61
61
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
+
62
67
if convert_schemas_to_strict :
63
68
try :
64
69
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():
260
260
261
261
assert baz_tool .params_json_schema == possible_to_convert_schema
262
262
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