Skip to content

Commit 4c70606

Browse files
Jacksunweicopybara-github
authored andcommitted
chore: Renames MCPTool and MCPToolset to McpTool and McpToolset
- Keep original class names for backward-compatibility. - Log warning if user instantiate the classes with original names. - New names are more aligned with MCP SDKs convention. PiperOrigin-RevId: 799777320
1 parent 216cb7a commit 4c70606

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@
2121
from .mcp_session_manager import StdioConnectionParams
2222
from .mcp_session_manager import StreamableHTTPConnectionParams
2323
from .mcp_tool import MCPTool
24+
from .mcp_tool import McpTool
2425
from .mcp_toolset import MCPToolset
26+
from .mcp_toolset import McpToolset
2527

2628
__all__.extend([
2729
'adk_to_mcp_tool_type',
2830
'gemini_to_json_schema',
31+
'McpTool',
2932
'MCPTool',
33+
'McpToolset',
3034
'MCPToolset',
31-
'StdioConnectionParams',
3235
'SseConnectionParams',
36+
'StdioConnectionParams',
3337
'StreamableHTTPConnectionParams',
3438
])
3539

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import base64
1818
import logging
1919
from typing import Optional
20+
import warnings
2021

2122
from fastapi.openapi.models import APIKeyIn
2223
from google.genai.types import FunctionDeclaration
@@ -52,7 +53,7 @@
5253
logger = logging.getLogger("google_adk." + __name__)
5354

5455

55-
class MCPTool(BaseAuthenticatedTool):
56+
class McpTool(BaseAuthenticatedTool):
5657
"""Turns an MCP Tool into an ADK Tool.
5758
5859
Internally, the tool initializes from a MCP Tool, and uses the MCP Session to
@@ -216,3 +217,15 @@ async def _get_headers(
216217
)
217218

218219
return headers
220+
221+
222+
class MCPTool(McpTool):
223+
"""Deprecated name, use `McpTool` instead."""
224+
225+
def __init__(self, *args, **kwargs):
226+
warnings.warn(
227+
"MCPTool class is deprecated, use `McpTool` instead.",
228+
DeprecationWarning,
229+
stacklevel=2,
230+
)
231+
super().__init__(*args, **kwargs)

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import Optional
2121
from typing import TextIO
2222
from typing import Union
23+
import warnings
2324

2425
from pydantic import model_validator
2526
from typing_extensions import override
@@ -59,7 +60,7 @@
5960
logger = logging.getLogger("google_adk." + __name__)
6061

6162

62-
class MCPToolset(BaseToolset):
63+
class McpToolset(BaseToolset):
6364
"""Connects to a MCP Server, and retrieves MCP Tools into ADK Tools.
6465
6566
This toolset manages the connection to an MCP server and provides tools
@@ -190,7 +191,7 @@ def from_config(
190191
cls: type[MCPToolset], config: ToolArgsConfig, config_abs_path: str
191192
) -> MCPToolset:
192193
"""Creates an MCPToolset from a configuration object."""
193-
mcp_toolset_config = MCPToolsetConfig.model_validate(config.model_dump())
194+
mcp_toolset_config = McpToolsetConfig.model_validate(config.model_dump())
194195

195196
if mcp_toolset_config.stdio_server_params:
196197
connection_params = mcp_toolset_config.stdio_server_params
@@ -211,7 +212,19 @@ def from_config(
211212
)
212213

213214

214-
class MCPToolsetConfig(BaseToolConfig):
215+
class MCPToolset(McpToolset):
216+
"""Deprecated name, use `McpToolset` instead."""
217+
218+
def __init__(self, *args, **kwargs):
219+
warnings.warn(
220+
"MCPToolset class is deprecated, use `McpToolset` instead.",
221+
DeprecationWarning,
222+
stacklevel=2,
223+
)
224+
super().__init__(*args, **kwargs)
225+
226+
227+
class McpToolsetConfig(BaseToolConfig):
215228
"""The config for MCPToolset."""
216229

217230
stdio_server_params: Optional[StdioServerParameters] = None

0 commit comments

Comments
 (0)