-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.
Describe the bug
My agent is using the MCPToolset, simple as
MCPToolset( connection_params=SseServerParams(url=os.getenv("MCP_SERVER")) )
The tool parser is not parsing the tool input schema correctly.
From the agent prompt, I see the following:
10:40:44 adk.1 | Functions: 10:40:44 adk.1 | query_domains: {'payload': {'type': <Type.OBJECT: 'OBJECT'>}} -> None 10:40:44 adk.1 | -----------------------------------------------------------
where the payload
is not deep dive defined.
Hence the LLM is trying some arbitrary key in the payload dict definition. Things like:
args: payload: identifiers: 0: "yahoo.com" identifier_type: "domain_name" name: "query_domains"
This tool is picked up from a FastMCP server.
When I use MCP Inspector to list tools on the same server, the tool input schema is correctly defined using the $def
and $ref
keys.
Here is a snippet of the tool definitions from listing tools on the MCP Inspector:
{ "tools": [ { "name": "query_domains", "description": "Some description.", "inputSchema": { "type": "object", "properties": { "payload": { "$ref": "#/$defs/DomainPayload" } }, "required": [ "payload" ], "$defs": { "DomainPayload": { "properties": { "adDomain": { "description": "List of one or many domains.", "items": { "type": "string" }, "title": "Addomain", "type": "array" }, "device": { "default": "GLOBAL", "description": "Filter by device. All devices are returned by default.", "enum": [ "GLOBAL", "desktop", "mobile" ], "title": "Device", "type": "string" }, ..... .....
I think the issue arises from this line of code
https://github.com/google/adk-python/blob/main/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py#L51
which is being used in the to_gemini_schema
function
https://github.com/google/adk-python/blob/main/src/google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py#L107
OpenAPI specs
https://swagger.io/specification/
Going to Specifications > Schema > Path Item Object
To Reproduce
Steps to reproduce the behavior:
You'll need access to some MCP that defines tools using $ref
and $def
notation.
And create an agent that uses that tool.
Expected behavior
I expect the definiton of the inputSchema in the LLM prompt to be correctly defined.
Experimenting the same with LangChain, I managed to include the raw inputSchema definition as they come from the MCP. LLMs already know OpenAPI specs.
Desktop (please complete the following information):
- OS: Sequoia 15.5
- Python version(python -V): 3.11.11
- ADK version(pip show google-adk): 1.1.0