Skip to content

MCP Tool Response Role Incorrectly Set as "user" #599

@pansusu

Description

@pansusu

Issue: MCP Tool Response Role Incorrectly Set as "user"

Description

When using ADK to call MCP server through MCPToolset, the tool response's role is incorrectly set as "user" instead of "assistant". This appears to be inconsistent with the expected behavior of tool responses.

Current Behavior

# Example response format
{
    "parts": [
        {
            "function_response": {
                "id": "call_xxx",
                "name": "read_query",
                "response": {
                    "result": {
                        "content": [...],
                        "isError": false
                    }
                }
            }
        }
    ],
    "role": "user"  # <-- This should be "assistant"
}

Expected Behavior

Tool responses should have "role": "assistant" to properly indicate that they are responses from the agent/tool rather than user input.

Environment

  • ADK version: [version]
  • MCP server: SQLite implementation
  • Python version: [version]

Steps to Reproduce

  1. Initialize MCPToolset with SQLite server
  2. Make a tool call through the agent
  3. Observe the response format

Impact

This issue might affect:

  • Message flow tracking
  • Response handling logic
  • UI rendering of conversation history

Additional Context

The issue occurs when using MCPToolset.from_server() to connect to the MCP server. The response format suggests there might be a mismatch between MCP server's response format and ADK's expected format.

Questions

  1. Is this the intended behavior of MCPToolset?
  2. Are there configuration options to control the response role?
  3. Should this be handled at the MCP server level or ADK level?

Related Code

local_tools, _ = await MCPToolset.from_server(
    connection_params=StdioServerParameters(
        command='uv',
        args=[...],
    ),
    async_exit_stack=self._exit_stack
)

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions