Skip to content

Commit cf87366

Browse files
committed
fix(mcp): satisfy CI for trace context client factory
1 parent 66fac16 commit cf87366

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 SamplingCapability
3738
from mcp import StdioServerParameters
@@ -50,10 +51,10 @@
5051

5152

5253
def create_mcp_http_client(
53-
headers=None,
54-
timeout=None,
55-
auth=None,
56-
):
54+
headers: dict[str, str] | None = None,
55+
timeout: httpx.Timeout | None = None,
56+
auth: httpx.Auth | None = None,
57+
) -> httpx.AsyncClient:
5758
"""Creates MCP HTTP client and instruments it when OTel is available."""
5859
client = _create_mcp_http_client(
5960
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)