@@ -63,7 +63,10 @@ async def test_get_all_function_tools():
6363
6464 for idx , tool in enumerate (tools ):
6565 assert isinstance (tool , FunctionTool )
66- assert tool .params_json_schema == schemas [idx ]
66+ if schemas [idx ] == {}:
67+ assert tool .params_json_schema == snapshot ({"properties" : {}})
68+ else :
69+ assert tool .params_json_schema == schemas [idx ]
6770 assert tool .name == names [idx ]
6871
6972 # Also make sure it works with strict schemas
@@ -167,10 +170,7 @@ async def test_agent_convert_schemas_true():
167170
168171 # Checks that additionalProperties is set to False
169172 assert bar_tool .params_json_schema == snapshot (
170- {
171- "type" : "object" ,
172- "additionalProperties" : {"type" : "string" },
173- }
173+ {"type" : "object" , "additionalProperties" : {"type" : "string" }, "properties" : {}}
174174 )
175175 assert bar_tool .strict_json_schema is False , "bar_tool should not be strict"
176176
@@ -220,7 +220,9 @@ async def test_agent_convert_schemas_false():
220220 assert foo_tool .params_json_schema == strict_schema
221221 assert foo_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
222222
223- assert bar_tool .params_json_schema == non_strict_schema
223+ assert bar_tool .params_json_schema == snapshot (
224+ {"type" : "object" , "additionalProperties" : {"type" : "string" }, "properties" : {}}
225+ )
224226 assert bar_tool .strict_json_schema is False
225227
226228 assert baz_tool .params_json_schema == possible_to_convert_schema
@@ -255,8 +257,35 @@ async def test_agent_convert_schemas_unset():
255257 assert foo_tool .params_json_schema == strict_schema
256258 assert foo_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
257259
258- assert bar_tool .params_json_schema == non_strict_schema
260+ assert bar_tool .params_json_schema == snapshot (
261+ {"type" : "object" , "additionalProperties" : {"type" : "string" }, "properties" : {}}
262+ )
259263 assert bar_tool .strict_json_schema is False
260264
261265 assert baz_tool .params_json_schema == possible_to_convert_schema
262266 assert baz_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
267+
268+
269+ @pytest .mark .asyncio
270+ async def test_util_adds_properties ():
271+ """The MCP spec doesn't require the inputSchema to have `properties`, so we need to add it
272+ if it's missing.
273+ """
274+ schema = {
275+ "type" : "object" ,
276+ "description" : "Test tool" ,
277+ }
278+
279+ server = FakeMCPServer ()
280+ server .add_tool ("test_tool" , schema )
281+
282+ tools = await MCPUtil .get_all_function_tools ([server ], convert_schemas_to_strict = False )
283+ tool = next (tool for tool in tools if tool .name == "test_tool" )
284+
285+ assert isinstance (tool , FunctionTool )
286+ assert "properties" in tool .params_json_schema
287+ assert tool .params_json_schema ["properties" ] == {}
288+
289+ assert tool .params_json_schema == snapshot (
290+ {"type" : "object" , "description" : "Test tool" , "properties" : {}}
291+ )
0 commit comments