Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- Add deprecations below -->
Expand Down
30 changes: 3 additions & 27 deletions src/mcp/client/session_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions src/mcp/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion tests/client/test_session_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down