Skip to content

Commit 0bdcb05

Browse files
committed
fix(mcp): satisfy CI for trace context client factory
1 parent c34c12f commit 0bdcb05

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from typing import TextIO
3333
from typing import Union
3434

35+
import httpx
3536
from mcp import ClientSession
3637
from mcp import StdioServerParameters
3738
from mcp.client.sse import sse_client
@@ -48,10 +49,10 @@
4849

4950

5051
def create_mcp_http_client(
51-
headers=None,
52-
timeout=None,
53-
auth=None,
54-
):
52+
headers: dict[str, str] | None = None,
53+
timeout: httpx.Timeout | None = None,
54+
auth: httpx.Auth | None = None,
55+
) -> httpx.AsyncClient:
5556
"""Creates MCP HTTP client and instruments it when OTel is available."""
5657
client = _create_mcp_http_client(
5758
headers=headers,

tests/unittests/tools/mcp_tool/test_mcp_session_manager.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# limitations under the License.
1414

1515
import asyncio
16+
import builtins
1617
from datetime import timedelta
1718
import hashlib
1819
from io import StringIO
1920
import json
2021
import sys
21-
import builtins
2222
from unittest.mock import ANY
2323
from unittest.mock import AsyncMock
2424
from unittest.mock import Mock
@@ -193,7 +193,9 @@ def test_init_with_streamable_http_default_httpx_factory(
193193
].get_default(),
194194
)
195195

196-
@patch("google.adk.tools.mcp_tool.mcp_session_manager._create_mcp_http_client")
196+
@patch(
197+
"google.adk.tools.mcp_tool.mcp_session_manager._create_mcp_http_client"
198+
)
197199
def test_default_httpx_factory_instruments_client_when_available(
198200
self, mock_base_factory
199201
):
@@ -215,7 +217,9 @@ def test_default_httpx_factory_instruments_client_when_available(
215217
assert result is client
216218
mock_instrumentor.instrument_client.assert_called_once_with(client)
217219

218-
@patch("google.adk.tools.mcp_tool.mcp_session_manager._create_mcp_http_client")
220+
@patch(
221+
"google.adk.tools.mcp_tool.mcp_session_manager._create_mcp_http_client"
222+
)
219223
def test_default_httpx_factory_handles_missing_opentelemetry(
220224
self, mock_base_factory
221225
):

0 commit comments

Comments
 (0)