Skip to content

MCP Server with adk - 400 INVALID_ARGUMENT Invalid JSON payload received #1172

Open
@JonaZzz0815

Description

@JonaZzz0815

Description

When using google-adk version < 1.1.0, I’m able to load tools from the MCP server using MCPToolset.from_server(...). However, when sending a request with the loaded tools, the response returns an unexpected format or error.

Screenshot / Error

Image

Code Snippet

from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, SseServerParams
from contextlib import AsyncExitStack

async def get_tools_async(user_id: str=None, async_exit_stack: AsyncExitStack=None):
    print("Attempting to connect to MCP Filesystem server...")
    url = os.getenv('Server-URL')
    if user_id:
        headers['X-User-Id'] = user_id
        print("Setting user_id to ", user_id)

    tools, exit_stack = await MCPToolset.from_server(
        connection_params=SseServerParams(
            url=f"{url}/sse",
            headers=headers
        ),
        async_exit_stack=async_exit_stack
    )
    print(f"MCP Toolset created successfully. Retrieved from {url}")
    return tools, exit_stack

async def create_agent(user_id: str="test-bot", async_exit_stack: AsyncExitStack=None):
    mcp_tools, exit_stack = await get_tools_async(user_id, async_exit_stack)
    tools_list = [tool for tool in mcp_tools]
    print(tools_list[0])
    agent_coordinator = Agent(
        name='agent_coordinator',
        model='gemini-2.0-flash',
        description="",
        instruction=prompt.AGENT_COORDINATOR_PROMPT,
        tools=mcp_tools
    )
    return agent_coordinator, exit_stack

agent_coordinator = create_agent("test-bot")
root_agent = agent_coordinator

Expected Behavior

Expected the request using tools loaded from the MCP server to return a valid response format (e.g., structured JSON or proper LLM-compatible tool metadata).

Actual Behavior

The response seems to contain malformed or unexpected data, despite the tools loading successfully.

Environment

  • google-adk version: < 1.1.0
  • Python: 3.13.2
  • Server: MCP local server

Metadata

Metadata

Assignees

Labels

toolsIssues related to tools

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions