diff --git a/src/google/adk/tools/mcp_tool/mcp_toolset.py b/src/google/adk/tools/mcp_tool/mcp_toolset.py index 2e79b8203c..f34c1cc985 100644 --- a/src/google/adk/tools/mcp_tool/mcp_toolset.py +++ b/src/google/adk/tools/mcp_tool/mcp_toolset.py @@ -149,6 +149,37 @@ def __init__( self._auth_credential = auth_credential self._require_confirmation = require_confirmation + @property + def connection_params(self) -> Union[ + StdioServerParameters, + StdioConnectionParams, + SseConnectionParams, + StreamableHTTPConnectionParams, + ]: + return self._connection_params + + @property + def auth_scheme(self) -> Optional[AuthScheme]: + return self._auth_scheme + + @property + def auth_credential(self) -> Optional[AuthCredential]: + return self._auth_credential + + @property + def require_confirmation(self) -> Union[bool, Callable[..., bool]]: + return self._require_confirmation + + @property + def header_provider( + self, + ) -> Optional[Callable[[ReadonlyContext], Dict[str, str]]]: + return self._header_provider + + @property + def errlog(self) -> TextIO: + return self._errlog + async def _execute_with_session( self, coroutine_func: Callable[[Any], Awaitable[T]], diff --git a/tests/unittests/tools/mcp_tool/test_mcp_toolset.py b/tests/unittests/tools/mcp_tool/test_mcp_toolset.py index d2fece0e8f..95c9201920 100644 --- a/tests/unittests/tools/mcp_tool/test_mcp_toolset.py +++ b/tests/unittests/tools/mcp_tool/test_mcp_toolset.py @@ -80,6 +80,61 @@ def test_init_basic(self): assert toolset._auth_scheme is None assert toolset._auth_credential is None + def test_connection_params(self): + """Test getting connection params.""" + toolset = MCPToolset(connection_params=self.mock_stdio_params) + assert toolset.connection_params == self.mock_stdio_params + + def test_auth_scheme(self): + """Test getting auth scheme.""" + toolset = MCPToolset(connection_params=self.mock_stdio_params) + assert toolset.auth_scheme is None + + def test_auth_credential(self): + """Test getting auth credential.""" + toolset = MCPToolset(connection_params=self.mock_stdio_params) + assert toolset.auth_credential is None + + def test_error_log(self): + """Test getting error log.""" + toolset = MCPToolset(connection_params=self.mock_stdio_params) + assert toolset.errlog == sys.stderr + + def test_auth_scheme_with_value(self): + """Test getting auth scheme when provided at initialization.""" + mock_scheme = Mock() + toolset = MCPToolset( + connection_params=self.mock_stdio_params, + auth_scheme=mock_scheme, + ) + assert toolset.auth_scheme == mock_scheme + + def test_require_confirmation(self): + """Test getting require_confirmation flag.""" + toolset = MCPToolset( + connection_params=self.mock_stdio_params, + require_confirmation=True, + ) + assert toolset.require_confirmation is True + + def test_header_provider(self): + """Test getting header_provider.""" + mock_header_provider = Mock() + toolset = MCPToolset( + connection_params=self.mock_stdio_params, + header_provider=mock_header_provider, + ) + assert toolset.header_provider == mock_header_provider + + def test_auth_credential_with_value(self): + """Test getting auth credential when provided at initialization.""" + mock_credential = Mock(spec=AuthCredential) + toolset = MCPToolset( + connection_params=self.mock_stdio_params, + auth_credential=mock_credential, + ) + assert toolset.auth_credential == mock_credential + def test_init_with_stdio_connection_params(self): """Test initialization with StdioConnectionParams.""" stdio_params = StdioConnectionParams(