Skip to content

Unable to integrate Mongodb mcp with google adk #3401

Description

@Ateeb626

Describe the bug
When using MCPToolset with MongoDB MCP in an LlmAgent, some function parameters have enum values that are integers (e.g., [256, 512, 1024, ...]) while the schema specifies type: string. This causes google.genai.errors.ClientError: 400 INVALID_ARGUMENT when the agent is loaded or tools are called, with messages like:

Invalid value at 'tools[0].function_declarations[13].parameters.properties[2].value.items.any_of[1].properties[0].value.properties[7].value.properties[0].value.enum[0]' (TYPE_STRING), 256

To Reproduce
Steps to reproduce the behavior:

  1. Install the latest google-adk and 'MongoDB mcp server'
  2. Start the MongoDB MCP server before running the agent:
npx -y mongodb-mcp-server \
  --connectionString "mongodb://localhost:27018?directConnection=true" \
  --transport http \
  --httpHost=0.0.0.0 \
  --httpPort=8080
  1. Create an agent using MongoDB MCP:
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool import MCPToolset, StreamableHTTPConnectionParams

mcp_server_url = "http://127.0.0.1:8080/mcp"

root_agent = LlmAgent(
    model="gemini-2.5-flash",
    name="mongo_mcp_agent",
    instruction="Help with MongoDB data access",
    tools=[MCPToolset(connection_params=StreamableHTTPConnectionParams(url=mcp_server_url))]
)
  1. Run adk web . from the agent folder.
  2. Observe errors related to TYPE_STRING and enum integer values.

Expected behavior
Integer enum values returned by MongoDB MCP should either:

  • Be automatically cast to strings when the schema type is string, or
  • The schema itself should use type: integer, so ADK can validate properly.

Desktop

  • OS: macOS 13.5
  • Python version: 3.13
  • ADK version: [latest]

Model Information:

  • Using LiteLLM: No
  • Model: gemini-2.5-flash

Additional context
This breaks integration of MongoDB MCP with LlmAgent in ADK. Guidance on proper schema handling or automatic enum type normalization is needed.

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

mcp[Component] This issues is related to MCP supportneeds review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions