Skip to content

MCP tools output schema is not propagated to FunctionDeclaration #2828

@alan-anzenna

Description

@alan-anzenna

Describe the bug
In https://github.com/google/adk-python/blob/main/src/google/adk/tools/mcp_tool/mcp_tool.py#L107, the MCP input schema is passed on to FunctionDeclaration. However, the MCP output schema is not.

To Reproduce
Steps to reproduce the behavior:

  1. Create a LLM agent with a MCP tool added to it that has an output schema.
  2. Ask the LLM to describe the tool's output.

Currently, the LLM replies with something similar to:

The get_a_device tool returns a dictionary object representing a device. However, the specific fields and their descriptions within the dictionary are not provided in the tool's documentation.

Expected behavior

A response such as:

The get_a_device tool returns a GetADeviceResponse object, which contains detailed information about a specific device. The output includes the following attributes:

id: The unique identifier of the device.
...

Desktop (please complete the following information):

  • MacOS
  • Python version(python -V): 3.13.3
  • ADK version(pip show google-adk): 1.11, but verified the code to be unchanged in main as well

Model Information:
gemini-2.5-flash

Additional context

The "success" response above was created by adding the following code:

--- a/patches/mcp_tool.py
+++ b/patches/mcp_tool.py
@@ -108,8 +108,10 @@ class MCPTool(BaseAuthenticatedTool):
         """
         schema_dict = self._mcp_tool.inputSchema
         parameters = _to_gemini_schema(schema_dict)
+        output_schema_dict = self._mcp_tool.outputSchema
+        output_parameters = _to_gemini_schema(output_schema_dict)
         function_decl = FunctionDeclaration(
-            name=self.name, description=self.description, parameters=parameters
+            name=self.name, description=self.description, parameters=parameters, response=output_parameters
         )
         return function_decl

Metadata

Metadata

Assignees

Labels

mcp[Component] Issues about MCP support

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions