Skip to content

MCPToolset does not accept tools with float inputs #1822

@averikitsch

Description

@averikitsch

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
MCPToolset has validation error when using Tools with input types "Float". The JSON Schema validator does not understand that for the JSON Schema "float" is a type of "number".
https://googleapis.github.io/python-genai/genai.html#module-genai.types

To Reproduce
Steps to reproduce the behavior:

  1. Install '...'
  2. Run '....'
  3. Open '....'
  4. See error
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/runners.py", line 132, in _invoke_run_async
    async for event in self.run_async(
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/runners.py", line 203, in run_async
    async for event in invocation_context.agent.run_async(invocation_context):
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/agents/base_agent.py", line 147, in run_async
    async for event in self._run_async_impl(ctx):
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/agents/llm_agent.py", line 275, in _run_async_impl
    async for event in self._llm_flow.run_async(ctx):
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 282, in run_async
    async for event in self._run_one_step_async(invocation_context):
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 302, in _run_one_step_async
    async for event in self._preprocess_async(invocation_context, llm_request):
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/flows/llm_flows/base_llm_flow.py", line 344, in _preprocess_async
    await tool.process_llm_request(
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/tools/base_tool.py", line 96, in process_llm_request
    if (function_declaration := self._get_declaration()) is None:
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/tools/mcp_tool/mcp_tool.py", line 105, in _get_declaration
    parameters = _to_gemini_schema(schema_dict)
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/google/adk/tools/_gemini_schema_util.py", line 156, in _to_gemini_schema
    json_schema=_ExtendedJSONSchema.model_validate(openapi_schema),
  File "/Users/akitsch/code/pyenvs/test-pg/lib/python3.10/site-packages/pydantic/main.py", line 705, in model_validate
    return cls.__pydantic_validator__.validate_python(
pydantic_core._pydantic_core.ValidationError: 2 validation errors for _ExtendedJSONSchema
properties.percent.type.enum[JSONSchemaType]
  Input should be 'null', 'boolean', 'object', 'array', 'number', 'integer' or 'string' [type=enum, input_value='float', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/enum
properties.percent.type.list[enum[JSONSchemaType]]
  Input should be a valid list [type=list_type, input_value='float', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/list_type

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Python version(python -V):
  • ADK version(pip show google-adk):

Model Information:
For example, which model is being used.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bot triaged[Bot] This issue is triaged by ADK bottools[Component] This issue is related to tools

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions