Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
ffd5914
fix(contrib): pool and idle-evict MCP connections in google_adk_agents
wankhede04 Jul 21, 2026
11e7550
test(contrib): cover MCP connection reuse, idle eviction, and error e…
wankhede04 Jul 21, 2026
0996b6c
fix(contrib): make google_adk_agents MCP toolsets stateless (fixes fa…
wankhede04 Jul 22, 2026
4748a58
feat(contrib): add stateful pooled MCP toolset provider for google_ad…
wankhede04 Jul 22, 2026
57c9142
fix(contrib): guarantee heartbeat task cleanup in stateful MCP server…
wankhede04 Jul 22, 2026
02f2cd7
Update temporalio/contrib/google_adk_agents/_mcp.py
brianstrauch Jul 22, 2026
726469c
fix(contrib): fix duplicate-tool error wording in stateful call_tool
wankhede04 Jul 23, 2026
e16eefa
Merge branch 'main' into fix/google-adk-agents-mcp-connection-leak
tconley1428 Jul 23, 2026
493ad31
fix(contrib): fix pyright/basedpyright errors in google_adk_agents MC…
wankhede04 Jul 24, 2026
3a44d24
Merge branch 'main' into fix/google-adk-agents-mcp-connection-leak
brianstrauch Jul 24, 2026
ba4cd5c
fix(contrib): silence basedpyright reportUnusedParameter in MCP test …
wankhede04 Jul 28, 2026
75f63f1
Merge remote-tracking branch 'origin/fix/google-adk-agents-mcp-connec…
wankhede04 Jul 28, 2026
29939ee
Merge branch 'main' into fix/google-adk-agents-mcp-connection-leak
brianstrauch Jul 28, 2026
63f35f9
Add missing docstrings to __aenter__/__aexit__ to fix pydocstyle CI f…
wankhede04 Aug 5, 2026
d2f64c9
Add __init__.py to tests/contrib/google_adk_agents
brianstrauch Aug 5, 2026
23c794f
Use pydoctor-resolvable form of Worker cross-reference
brianstrauch Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(contrib): fix pyright/basedpyright errors in google_adk_agents MC…
…P tests

The fake toolset factories in test_mcp.py and test_stateful_mcp.py were
annotated as returning _FakeToolset, which pyright/basedpyright correctly
flagged as incompatible with TemporalMcpToolSetProvider's/
TemporalStatefulMcpToolSetProvider's toolset_factory parameter type of
Callable[[Any | None], McpToolset], since _FakeToolset is a structurally
similar stand-in but not a subclass of McpToolset.

Annotate the factories as returning McpToolset and cast the fake instance
through object first (as basedpyright's reportInvalidCast requires for
unrelated concrete types), matching CI's build-lint-test/test-latest-deps
failure on PR #1664.
  • Loading branch information
wankhede04 committed Jul 24, 2026
commit 493ad3142cb07aaf604dbdeb28eb2bae86ca2391
27 changes: 14 additions & 13 deletions tests/contrib/google_adk_agents/test_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
honors that call's ``factory_argument``, and always closes the toolset.
"""

from typing import Any
from typing import Any, cast

import pytest
from google.adk.events import EventActions
from google.adk.tools.mcp_tool import McpToolset

from temporalio.contrib.google_adk_agents._mcp import (
TemporalMcpToolSetProvider,
Expand Down Expand Up @@ -103,10 +104,10 @@ async def test_call_tool_creates_and_closes_fresh_toolset_each_call():
"""Each call_tool builds its own toolset and closes it, every time."""
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_reuse", factory)
_, call_tool = provider._get_activities()
Expand All @@ -123,10 +124,10 @@ def factory(arg: Any) -> _FakeToolset:
async def test_get_tools_creates_and_closes_fresh_toolset():
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_list", factory)
get_tools, _ = provider._get_activities()
Expand All @@ -145,10 +146,10 @@ async def test_factory_argument_honored_on_every_call():
"""
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_routing", factory)
_, call_tool = provider._get_activities()
Expand All @@ -164,10 +165,10 @@ async def test_call_tool_closes_toolset_on_error():
"""A failure mid-call still closes the toolset (no leak on the error path)."""
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg, fail_run=True)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_run_error", factory)
_, call_tool = provider._get_activities()
Expand All @@ -182,10 +183,10 @@ def factory(arg: Any) -> _FakeToolset:
async def test_get_tools_closes_toolset_on_error():
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg, fail_get_tools=True)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_list_error", factory)
get_tools, _ = provider._get_activities()
Expand All @@ -201,10 +202,10 @@ async def test_call_tool_no_matching_tool_still_closes():
"""A business-logic ApplicationError still closes the fresh toolset."""
created: list[_FakeToolset] = []

def factory(arg: Any) -> _FakeToolset:
def factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg)
created.append(toolset)
return toolset
return cast(McpToolset, cast(object, toolset))

provider = TemporalMcpToolSetProvider("stateless_no_match", factory)
_, call_tool = provider._get_activities()
Expand Down
8 changes: 5 additions & 3 deletions tests/contrib/google_adk_agents/test_stateful_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import uuid
from datetime import timedelta
from typing import Any
from typing import Any, cast

from google.adk.tools.mcp_tool import McpToolset

from temporalio import workflow
from temporalio.client import Client
Expand Down Expand Up @@ -73,10 +75,10 @@ async def close(self) -> None:
self.closed = True


def _factory(arg: Any) -> _FakeToolset:
def _factory(arg: Any) -> McpToolset:
toolset = _FakeToolset(arg)
CREATED.append(toolset)
return toolset # type: ignore[return-value]
return cast(McpToolset, cast(object, toolset))


@workflow.defn
Expand Down