Skip to content

to_mcp_server returns the model's thought parts to MCP clients #7834

Closed

Description

@adityasingh2400

🔴 Required Information

Describe the Bug:
An agent exposed with to_mcp_server returns its thoughts to MCP clients. _part_to_content in tools/mcp_tool/_agent_to_mcp.py turns any part with text into a TextContent block, including parts with thought=True. With a thinking model that returns thoughts, the MCP client gets the model's hidden reasoning as part of the tool result. Intermediate events reported through report_progress also include thought text.

AgentTool already skips thought parts when it builds its result (agent_tool.py), and the memory services exclude them too (#7473, #7691).

Steps to Reproduce:

  1. Expose an agent whose final event has parts [Part(text="...", thought=True), Part(text="answer")] with to_mcp_server(agent).
  2. Call the tool from an MCP client.

Expected Behavior:
The client receives only answer, and progress messages contain no thought text.

Observed Behavior:

MCP client received: 'The user is on the free tier; do not mention the internal escalation path.'
MCP client received: 'Your contract renews on Nov 30.'

Environment Details:

  • ADK Library Version (pip show google-adk): 2.13.0 (also on main at 75fb788)
  • Desktop OS: macOS
  • Python Version (python -V): 3.11.16

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: any thinking model that returns thoughts (e.g. Gemini with include_thoughts=True)

🟡 Optional Information

Minimal Reproduction Code:

class ThinkingAgent(BaseAgent):
  async def _run_async_impl(self, ctx):
    yield Event(
        author=self.name,
        content=types.Content(role="model", parts=[
            types.Part(text="The user is on the free tier; do not mention the internal escalation path.", thought=True),
            types.Part(text="Your contract renews on Nov 30."),
        ]),
    )

server = to_mcp_server(ThinkingAgent(name="contracts_agent"))
# MCP client: await client.call_tool("contracts_agent", {"request": "When does my contract renew?"})

How often has this issue occurred?:

  • Always (100%), with thinking models that return thoughts

Activity

  1. added a commit that references this issue on Oct 30, 2026
    9688feb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions