diff --git a/docs/migration.md b/docs/migration.md index 881014a930..e849c5250c 100644 --- a/docs/migration.md +++ b/docs/migration.md @@ -52,6 +52,38 @@ async with http_client: The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx.AsyncClient` instead (see example above). +### `Content` type alias removed + +The deprecated `Content` type alias has been removed. Use `ContentBlock` directly instead. + +**Before (v1):** + +```python +from mcp.types import Content +``` + +**After (v2):** + +```python +from mcp.types import ContentBlock +``` + +### `args` parameter removed from `ClientSessionGroup.call_tool()` + +The deprecated `args` parameter has been removed from `ClientSessionGroup.call_tool()`. Use `arguments` instead. + +**Before (v1):** + +```python +result = await session_group.call_tool("my_tool", args={"key": "value"}) +``` + +**After (v2):** + +```python +result = await session_group.call_tool("my_tool", arguments={"key": "value"}) +``` + ## Deprecations diff --git a/src/mcp/client/session_group.py b/src/mcp/client/session_group.py index c9ce81d204..46dc3b560a 100644 --- a/src/mcp/client/session_group.py +++ b/src/mcp/client/session_group.py @@ -12,12 +12,12 @@ from collections.abc import Callable from dataclasses import dataclass from types import TracebackType -from typing import Any, TypeAlias, overload +from typing import Any, TypeAlias import anyio import httpx from pydantic import BaseModel -from typing_extensions import Self, deprecated +from typing_extensions import Self import mcp from mcp import types @@ -190,29 +190,6 @@ def tools(self) -> dict[str, types.Tool]: """Returns the tools as a dictionary of names to tools.""" return self._tools - @overload - async def call_tool( - self, - name: str, - arguments: dict[str, Any], - read_timeout_seconds: float | None = None, - progress_callback: ProgressFnT | None = None, - *, - meta: dict[str, Any] | None = None, - ) -> types.CallToolResult: ... - - @overload - @deprecated("The 'args' parameter is deprecated. Use 'arguments' instead.") - async def call_tool( - self, - name: str, - *, - args: dict[str, Any], - read_timeout_seconds: float | None = None, - progress_callback: ProgressFnT | None = None, - meta: dict[str, Any] | None = None, - ) -> types.CallToolResult: ... - async def call_tool( self, name: str, @@ -221,14 +198,13 @@ async def call_tool( progress_callback: ProgressFnT | None = None, *, meta: dict[str, Any] | None = None, - args: dict[str, Any] | None = None, ) -> types.CallToolResult: """Executes a tool given its name and arguments.""" session = self._tool_to_session[name] session_tool_name = self.tools[name].name return await session.call_tool( session_tool_name, - arguments if args is None else args, + arguments=arguments, read_timeout_seconds=read_timeout_seconds, progress_callback=progress_callback, meta=meta, diff --git a/src/mcp/types.py b/src/mcp/types.py index cc23e7f6b1..84f6acdaaa 100644 --- a/src/mcp/types.py +++ b/src/mcp/types.py @@ -1196,9 +1196,6 @@ class ResourceLink(Resource): ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource """A content block that can be used in prompts and tool results.""" -Content: TypeAlias = ContentBlock -# """DEPRECATED: Content is deprecated, you should use ContentBlock directly.""" - class PromptMessage(BaseModel): """Describes a message returned as part of a prompt.""" diff --git a/tests/client/test_session_group.py b/tests/client/test_session_group.py index b03fe9ca88..ed07293aed 100644 --- a/tests/client/test_session_group.py +++ b/tests/client/test_session_group.py @@ -77,7 +77,7 @@ def hook(name: str, server_info: types.Implementation) -> str: # pragma: no cov assert result.content == [text_content] mock_session.call_tool.assert_called_once_with( "my_tool", - {"name": "value1", "args": {}}, + arguments={"name": "value1", "args": {}}, read_timeout_seconds=None, progress_callback=None, meta=None,