mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Undo adding MCP tools output schema to FunctionDeclaration
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 827557144
This commit is contained in:
committed by
Copybara-Service
parent
a02f321f1b
commit
92a7d19573
@@ -121,13 +121,10 @@ class McpTool(BaseAuthenticatedTool):
|
|||||||
"""
|
"""
|
||||||
input_schema = self._mcp_tool.inputSchema
|
input_schema = self._mcp_tool.inputSchema
|
||||||
parameters = _to_gemini_schema(input_schema)
|
parameters = _to_gemini_schema(input_schema)
|
||||||
output_schema = self._mcp_tool.outputSchema
|
|
||||||
response = _to_gemini_schema(output_schema)
|
|
||||||
function_decl = FunctionDeclaration(
|
function_decl = FunctionDeclaration(
|
||||||
name=self.name,
|
name=self.name,
|
||||||
description=self.description,
|
description=self.description,
|
||||||
parameters=parameters,
|
parameters=parameters,
|
||||||
response=response,
|
|
||||||
)
|
)
|
||||||
return function_decl
|
return function_decl
|
||||||
|
|
||||||
|
|||||||
@@ -150,48 +150,6 @@ class TestMCPTool:
|
|||||||
assert declaration.parameters is not None
|
assert declaration.parameters is not None
|
||||||
assert declaration.response is None
|
assert declaration.response is None
|
||||||
|
|
||||||
def test_get_declaration_with_output_schema(self):
|
|
||||||
"""Test function declaration generation with an output schema."""
|
|
||||||
self.mock_mcp_tool.outputSchema = {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"status": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The status of the operation",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
tool = MCPTool(
|
|
||||||
mcp_tool=self.mock_mcp_tool,
|
|
||||||
mcp_session_manager=self.mock_session_manager,
|
|
||||||
)
|
|
||||||
|
|
||||||
declaration = tool._get_declaration()
|
|
||||||
|
|
||||||
assert isinstance(declaration, FunctionDeclaration)
|
|
||||||
assert declaration.response is not None
|
|
||||||
assert declaration.response.type == Type.OBJECT
|
|
||||||
assert "status" in declaration.response.properties
|
|
||||||
assert declaration.response.properties["status"].type == Type.STRING
|
|
||||||
assert (
|
|
||||||
declaration.response.properties["status"].description
|
|
||||||
== "The status of the operation"
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_get_declaration_with_empty_output_schema(self):
|
|
||||||
"""Test function declaration with an empty output schema."""
|
|
||||||
self.mock_mcp_tool.outputSchema = {}
|
|
||||||
tool = MCPTool(
|
|
||||||
mcp_tool=self.mock_mcp_tool,
|
|
||||||
mcp_session_manager=self.mock_session_manager,
|
|
||||||
)
|
|
||||||
|
|
||||||
declaration = tool._get_declaration()
|
|
||||||
|
|
||||||
assert declaration.response is not None
|
|
||||||
assert declaration.response.type == Type.OBJECT
|
|
||||||
assert declaration.response.properties is None
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_run_async_impl_no_auth(self):
|
async def test_run_async_impl_no_auth(self):
|
||||||
"""Test running tool without authentication."""
|
"""Test running tool without authentication."""
|
||||||
|
|||||||
Reference in New Issue
Block a user