Skip to content

Commit 024d759

Browse files
authored
Drop Content and args parameter in ClientSessionGroup.call_tool (#1866)
1 parent c251e72 commit 024d759

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

docs/migration.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,38 @@ async with http_client:
5252

5353
The `headers`, `timeout`, `sse_read_timeout`, and `auth` parameters have been removed from `StreamableHTTPTransport`. Configure these on the `httpx.AsyncClient` instead (see example above).
5454

55+
### `Content` type alias removed
56+
57+
The deprecated `Content` type alias has been removed. Use `ContentBlock` directly instead.
58+
59+
**Before (v1):**
60+
61+
```python
62+
from mcp.types import Content
63+
```
64+
65+
**After (v2):**
66+
67+
```python
68+
from mcp.types import ContentBlock
69+
```
70+
71+
### `args` parameter removed from `ClientSessionGroup.call_tool()`
72+
73+
The deprecated `args` parameter has been removed from `ClientSessionGroup.call_tool()`. Use `arguments` instead.
74+
75+
**Before (v1):**
76+
77+
```python
78+
result = await session_group.call_tool("my_tool", args={"key": "value"})
79+
```
80+
81+
**After (v2):**
82+
83+
```python
84+
result = await session_group.call_tool("my_tool", arguments={"key": "value"})
85+
```
86+
5587
## Deprecations
5688

5789
<!-- Add deprecations below -->

src/mcp/client/session_group.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from collections.abc import Callable
1313
from dataclasses import dataclass
1414
from types import TracebackType
15-
from typing import Any, TypeAlias, overload
15+
from typing import Any, TypeAlias
1616

1717
import anyio
1818
import httpx
1919
from pydantic import BaseModel
20-
from typing_extensions import Self, deprecated
20+
from typing_extensions import Self
2121

2222
import mcp
2323
from mcp import types
@@ -190,29 +190,6 @@ def tools(self) -> dict[str, types.Tool]:
190190
"""Returns the tools as a dictionary of names to tools."""
191191
return self._tools
192192

193-
@overload
194-
async def call_tool(
195-
self,
196-
name: str,
197-
arguments: dict[str, Any],
198-
read_timeout_seconds: float | None = None,
199-
progress_callback: ProgressFnT | None = None,
200-
*,
201-
meta: dict[str, Any] | None = None,
202-
) -> types.CallToolResult: ...
203-
204-
@overload
205-
@deprecated("The 'args' parameter is deprecated. Use 'arguments' instead.")
206-
async def call_tool(
207-
self,
208-
name: str,
209-
*,
210-
args: dict[str, Any],
211-
read_timeout_seconds: float | None = None,
212-
progress_callback: ProgressFnT | None = None,
213-
meta: dict[str, Any] | None = None,
214-
) -> types.CallToolResult: ...
215-
216193
async def call_tool(
217194
self,
218195
name: str,
@@ -221,14 +198,13 @@ async def call_tool(
221198
progress_callback: ProgressFnT | None = None,
222199
*,
223200
meta: dict[str, Any] | None = None,
224-
args: dict[str, Any] | None = None,
225201
) -> types.CallToolResult:
226202
"""Executes a tool given its name and arguments."""
227203
session = self._tool_to_session[name]
228204
session_tool_name = self.tools[name].name
229205
return await session.call_tool(
230206
session_tool_name,
231-
arguments if args is None else args,
207+
arguments=arguments,
232208
read_timeout_seconds=read_timeout_seconds,
233209
progress_callback=progress_callback,
234210
meta=meta,

src/mcp/types.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,6 @@ class ResourceLink(Resource):
11961196
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
11971197
"""A content block that can be used in prompts and tool results."""
11981198

1199-
Content: TypeAlias = ContentBlock
1200-
# """DEPRECATED: Content is deprecated, you should use ContentBlock directly."""
1201-
12021199

12031200
class PromptMessage(BaseModel):
12041201
"""Describes a message returned as part of a prompt."""

tests/client/test_session_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def hook(name: str, server_info: types.Implementation) -> str: # pragma: no cov
7777
assert result.content == [text_content]
7878
mock_session.call_tool.assert_called_once_with(
7979
"my_tool",
80-
{"name": "value1", "args": {}},
80+
arguments={"name": "value1", "args": {}},
8181
read_timeout_seconds=None,
8282
progress_callback=None,
8383
meta=None,

0 commit comments

Comments
 (0)