diff --git a/src/google/adk/integrations/api_registry/__init__.py b/src/google/adk/integrations/api_registry/__init__.py index e1aded4b..d24b43e2 100644 --- a/src/google/adk/integrations/api_registry/__init__.py +++ b/src/google/adk/integrations/api_registry/__init__.py @@ -12,8 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import warnings + from .api_registry import ApiRegistry +warnings.warn( + "google.adk.integrations.api_registry is deprecated, use" + " google.adk.integrations.agent_registry instead.", + DeprecationWarning, + stacklevel=2, +) + __all__ = [ - 'ApiRegistry', + "ApiRegistry", ] diff --git a/src/google/adk/integrations/api_registry/api_registry.py b/src/google/adk/integrations/api_registry/api_registry.py index abcd01a4..de6b26d8 100644 --- a/src/google/adk/integrations/api_registry/api_registry.py +++ b/src/google/adk/integrations/api_registry/api_registry.py @@ -17,6 +17,7 @@ from __future__ import annotations import os from typing import Any from typing import Callable +import warnings from google.adk.agents.readonly_context import ReadonlyContext from google.adk.tools.base_toolset import ToolPredicate @@ -50,7 +51,11 @@ def _get_api_registry_url(client_cert_source: Any | None = None) -> str: class ApiRegistry: - """Registry that provides McpToolsets for MCP servers registered in API Registry.""" + """[DEPRECATED] Registry for MCP servers registered in API Registry. + + Deprecated: Use AgentRegistry from `google.adk.integrations.agent_registry` + instead. + """ def __init__( self, @@ -68,6 +73,12 @@ class ApiRegistry: header_provider: Optional function to provide additional headers for MCP server calls. """ + warnings.warn( + "ApiRegistry is deprecated. Use AgentRegistry from" + " google.adk.integrations.agent_registry instead.", + DeprecationWarning, + stacklevel=2, + ) self.api_registry_project_id = api_registry_project_id self.location = location self._credentials, _ = google.auth.default() diff --git a/src/google/adk/tools/api_registry.py b/src/google/adk/tools/api_registry.py index 7c7c678c..cb3d0787 100644 --- a/src/google/adk/tools/api_registry.py +++ b/src/google/adk/tools/api_registry.py @@ -19,8 +19,8 @@ import warnings from google.adk.integrations.api_registry import ApiRegistry as ApiRegistry warnings.warn( - "google.adk.tools.api_registry is moved to" - " google.adk.integrations.api_registry", + "google.adk.tools.api_registry is deprecated, use" + " google.adk.integrations.agent_registry instead.", DeprecationWarning, stacklevel=2, ) diff --git a/tests/unittests/integrations/api_registry/test_api_registry.py b/tests/unittests/integrations/api_registry/test_api_registry.py index 50844c44..87dc241f 100644 --- a/tests/unittests/integrations/api_registry/test_api_registry.py +++ b/tests/unittests/integrations/api_registry/test_api_registry.py @@ -81,6 +81,18 @@ class TestApiRegistry(unittest.IsolatedAsyncioTestCase): mock_use_cert_patcher.start() self.addCleanup(mock_use_cert_patcher.stop) + def test_deprecation_warning(self): + mock_response = MagicMock() + mock_response.raise_for_status = MagicMock() + mock_response.json = MagicMock(return_value=MOCK_MCP_SERVERS_LIST) + self.mock_session.get.return_value = mock_response + + with self.assertWarns(DeprecationWarning) as cm: + ApiRegistry( + api_registry_project_id=self.project_id, location=self.location + ) + self.assertIn("ApiRegistry is deprecated", str(cm.warning)) + def test_init_success(self): mock_response = MagicMock() mock_response.raise_for_status = MagicMock()