Skip to content

Commit e15e19d

Browse files
RKestcopybara-github
authored andcommitted
fix: remove hardcoded google-cloud-aiplatform version in agent engine requirements
This fixes e.g. `--trace_to_cloud flag` Co-authored-by: Max Ind <maxind@google.com> PiperOrigin-RevId: 834190152
1 parent 0cc3d6d commit e15e19d

File tree

3 files changed

+1
-74
lines changed

3 files changed

+1
-74
lines changed

src/google/adk/cli/cli_deploy.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,11 +776,7 @@ def to_agent_engine(
776776
if not os.path.exists(requirements_txt_path):
777777
click.echo(f'Creating {requirements_txt_path}...')
778778
with open(requirements_txt_path, 'w', encoding='utf-8') as f:
779-
f.write(
780-
'google-cloud-aiplatform[adk,agent_engines] @ '
781-
'git+https://github.com/googleapis/python-aiplatform.git@'
782-
'bf1851e59cb34e63b509a2a610e72691e1c4ca28'
783-
)
779+
f.write('google-cloud-aiplatform[adk,agent_engines]')
784780
click.echo(f'Created {requirements_txt_path}')
785781
agent_config['requirements_file'] = agent_config.get(
786782
'requirements',

src/google/adk/tools/mcp_tool/mcp_session_manager.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,17 @@
2525
from typing import Any
2626
from typing import Dict
2727
from typing import Optional
28-
from typing import Protocol
29-
from typing import runtime_checkable
3028
from typing import TextIO
3129
from typing import Union
3230

3331
import anyio
3432
from pydantic import BaseModel
35-
from pydantic import ConfigDict
3633

3734
try:
3835
from mcp import ClientSession
3936
from mcp import StdioServerParameters
4037
from mcp.client.sse import sse_client
4138
from mcp.client.stdio import stdio_client
42-
from mcp.client.streamable_http import create_mcp_http_client
43-
from mcp.client.streamable_http import McpHttpClientFactory
4439
from mcp.client.streamable_http import streamablehttp_client
4540
except ImportError as e:
4641

@@ -89,11 +84,6 @@ class SseConnectionParams(BaseModel):
8984
sse_read_timeout: float = 60 * 5.0
9085

9186

92-
@runtime_checkable
93-
class CheckableMcpHttpClientFactory(McpHttpClientFactory, Protocol):
94-
pass
95-
96-
9787
class StreamableHTTPConnectionParams(BaseModel):
9888
"""Parameters for the MCP Streamable HTTP connection.
9989
@@ -109,18 +99,13 @@ class StreamableHTTPConnectionParams(BaseModel):
10999
Streamable HTTP server.
110100
terminate_on_close: Whether to terminate the MCP Streamable HTTP server
111101
when the connection is closed.
112-
httpx_client_factory: Factory function to create a custom HTTPX client. If
113-
not provided, a default factory will be used.
114102
"""
115103

116-
model_config = ConfigDict(arbitrary_types_allowed=True)
117-
118104
url: str
119105
headers: dict[str, Any] | None = None
120106
timeout: float = 5.0
121107
sse_read_timeout: float = 60 * 5.0
122108
terminate_on_close: bool = True
123-
httpx_client_factory: CheckableMcpHttpClientFactory = create_mcp_http_client
124109

125110

126111
def retry_on_closed_resource(func):
@@ -301,7 +286,6 @@ def _create_client(self, merged_headers: Optional[Dict[str, str]] = None):
301286
seconds=self._connection_params.sse_read_timeout
302287
),
303288
terminate_on_close=self._connection_params.terminate_on_close,
304-
httpx_client_factory=self._connection_params.httpx_client_factory,
305289
)
306290
else:
307291
raise ValueError(

tests/unittests/tools/mcp_tool/test_mcp_session_manager.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -146,59 +146,6 @@ def test_init_with_streamable_http_params(self):
146146

147147
assert manager._connection_params == http_params
148148

149-
@patch("google.adk.tools.mcp_tool.mcp_session_manager.streamablehttp_client")
150-
def test_init_with_streamable_http_custom_httpx_factory(
151-
self, mock_streamablehttp_client
152-
):
153-
"""Test that streamablehttp_client is called with custom httpx_client_factory."""
154-
from datetime import timedelta
155-
156-
custom_httpx_factory = Mock()
157-
158-
http_params = StreamableHTTPConnectionParams(
159-
url="https://example.com/mcp",
160-
timeout=15.0,
161-
httpx_client_factory=custom_httpx_factory,
162-
)
163-
manager = MCPSessionManager(http_params)
164-
165-
manager._create_client()
166-
167-
mock_streamablehttp_client.assert_called_once_with(
168-
url="https://example.com/mcp",
169-
headers=None,
170-
timeout=timedelta(seconds=15.0),
171-
sse_read_timeout=timedelta(seconds=300.0),
172-
terminate_on_close=True,
173-
httpx_client_factory=custom_httpx_factory,
174-
)
175-
176-
@pytest.mark.asyncio
177-
@patch("google.adk.tools.mcp_tool.mcp_session_manager.streamablehttp_client")
178-
async def test_init_with_streamable_http_default_httpx_factory(
179-
self, mock_streamablehttp_client
180-
):
181-
"""Test that streamablehttp_client is called with custom httpx_client_factory."""
182-
from datetime import timedelta
183-
184-
from mcp.client.streamable_http import create_mcp_http_client
185-
186-
http_params = StreamableHTTPConnectionParams(
187-
url="https://example.com/mcp", timeout=15.0
188-
)
189-
manager = MCPSessionManager(http_params)
190-
191-
manager._create_client()
192-
193-
mock_streamablehttp_client.assert_called_once_with(
194-
url="https://example.com/mcp",
195-
headers=None,
196-
timeout=timedelta(seconds=15.0),
197-
sse_read_timeout=timedelta(seconds=300.0),
198-
terminate_on_close=True,
199-
httpx_client_factory=create_mcp_http_client,
200-
)
201-
202149
def test_generate_session_key_stdio(self):
203150
"""Test session key generation for stdio connections."""
204151
manager = MCPSessionManager(self.mock_stdio_connection_params)

0 commit comments

Comments
 (0)