Skip to content

Commit 63f9008

Browse files
committed
feat(tools):exposed configurable parameter as property in McpToolset and added test cases
1 parent 85434e2 commit 63f9008

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,37 @@ def __init__(
140140
self._auth_credential = auth_credential
141141
self._require_confirmation = require_confirmation
142142

143+
@property
144+
def connection_params(self) -> Union[
145+
StdioServerParameters,
146+
StdioConnectionParams,
147+
SseConnectionParams,
148+
StreamableHTTPConnectionParams,
149+
]:
150+
return self._connection_params
151+
152+
@property
153+
def auth_scheme(self) -> Optional[AuthScheme]:
154+
return self._auth_scheme
155+
156+
@property
157+
def auth_credential(self) -> Optional[AuthCredential]:
158+
return self._auth_credential
159+
160+
@property
161+
def require_confirmation(self) -> Union[bool, Callable[..., bool]]:
162+
return self._require_confirmation
163+
164+
@property
165+
def header_provider(
166+
self,
167+
) -> Optional[Callable[[ReadonlyContext], Dict[str, str]]]:
168+
return self._header_provider
169+
170+
@property
171+
def errlog(self) -> TextIO:
172+
return self._errlog
173+
143174
@retry_on_errors
144175
async def get_tools(
145176
self,

tests/unittests/tools/mcp_tool/test_mcp_toolset.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ def test_init_basic(self):
7676
assert toolset._auth_scheme is None
7777
assert toolset._auth_credential is None
7878

79+
def test_connection_params(self):
80+
"""Test getting connection params."""
81+
toolset = MCPToolset(connection_params=self.mock_stdio_params)
82+
assert toolset.connection_params == self.mock_stdio_params
83+
84+
def test_auth_scheme(self):
85+
"""Test getting auth scheme."""
86+
toolset = MCPToolset(connection_params=self.mock_stdio_params)
87+
assert toolset.auth_scheme is None
88+
89+
def test_auth_credential(self):
90+
"""Test getting auth credential."""
91+
toolset = MCPToolset(connection_params=self.mock_stdio_params)
92+
assert toolset.auth_credential is None
93+
94+
def test_error_log(self):
95+
"""Test getting error log."""
96+
toolset = MCPToolset(connection_params=self.mock_stdio_params)
97+
assert toolset.errlog == sys.stderr
98+
99+
def test_auth_credential_updates(self):
100+
"""Test setting auth credential."""
101+
toolset = MCPToolset(connection_params=self.mock_stdio_params)
102+
toolset._auth_credential = "test_auth_credential"
103+
assert toolset.auth_credential == "test_auth_credential"
104+
79105
def test_init_with_stdio_connection_params(self):
80106
"""Test initialization with StdioConnectionParams."""
81107
stdio_params = StdioConnectionParams(

0 commit comments

Comments
 (0)