@@ -63,7 +63,10 @@ async def test_get_all_function_tools():
63
63
64
64
for idx , tool in enumerate (tools ):
65
65
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 ]
67
70
assert tool .name == names [idx ]
68
71
69
72
# Also make sure it works with strict schemas
@@ -167,10 +170,7 @@ async def test_agent_convert_schemas_true():
167
170
168
171
# Checks that additionalProperties is set to False
169
172
assert bar_tool .params_json_schema == snapshot (
170
- {
171
- "type" : "object" ,
172
- "additionalProperties" : {"type" : "string" },
173
- }
173
+ {"type" : "object" , "additionalProperties" : {"type" : "string" }, "properties" : {}}
174
174
)
175
175
assert bar_tool .strict_json_schema is False , "bar_tool should not be strict"
176
176
@@ -220,7 +220,9 @@ async def test_agent_convert_schemas_false():
220
220
assert foo_tool .params_json_schema == strict_schema
221
221
assert foo_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
222
222
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
+ )
224
226
assert bar_tool .strict_json_schema is False
225
227
226
228
assert baz_tool .params_json_schema == possible_to_convert_schema
@@ -255,8 +257,35 @@ async def test_agent_convert_schemas_unset():
255
257
assert foo_tool .params_json_schema == strict_schema
256
258
assert foo_tool .strict_json_schema is False , "Shouldn't be converted unless specified"
257
259
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
+ )
259
263
assert bar_tool .strict_json_schema is False
260
264
261
265
assert baz_tool .params_json_schema == possible_to_convert_schema
262
266
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