chore: Deprecate ApiRegistry in favor of AgentRegistry

Adds deprecation warnings and updates docstrings for ApiRegistry and
google.adk.integrations.api_registry, directing users to use AgentRegistry
(google.adk.integrations.agent_registry) instead.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 956174446
This commit is contained in:
Kathy Wu
2026-07-29 17:26:49 -07:00
committed by Copybara-Service
parent 2547db61dd
commit d3522c0097
4 changed files with 36 additions and 4 deletions
@@ -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",
]
@@ -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()
+2 -2
View File
@@ -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,
)
@@ -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()