Drop Content and args parameter in ClientSessionGroup.call_tool (#1866)
This commit is contained in:
parent
c251e728f4
commit
024d7597fd
4 changed files with 36 additions and 31 deletions
|
|
@ -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).
|
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
|
## Deprecations
|
||||||
|
|
||||||
<!-- Add deprecations below -->
|
<!-- Add deprecations below -->
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ import logging
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import Any, TypeAlias, overload
|
from typing import Any, TypeAlias
|
||||||
|
|
||||||
import anyio
|
import anyio
|
||||||
import httpx
|
import httpx
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from typing_extensions import Self, deprecated
|
from typing_extensions import Self
|
||||||
|
|
||||||
import mcp
|
import mcp
|
||||||
from mcp import types
|
from mcp import types
|
||||||
|
|
@ -190,29 +190,6 @@ class ClientSessionGroup:
|
||||||
"""Returns the tools as a dictionary of names to tools."""
|
"""Returns the tools as a dictionary of names to tools."""
|
||||||
return self._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(
|
async def call_tool(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
|
|
@ -221,14 +198,13 @@ class ClientSessionGroup:
|
||||||
progress_callback: ProgressFnT | None = None,
|
progress_callback: ProgressFnT | None = None,
|
||||||
*,
|
*,
|
||||||
meta: dict[str, Any] | None = None,
|
meta: dict[str, Any] | None = None,
|
||||||
args: dict[str, Any] | None = None,
|
|
||||||
) -> types.CallToolResult:
|
) -> types.CallToolResult:
|
||||||
"""Executes a tool given its name and arguments."""
|
"""Executes a tool given its name and arguments."""
|
||||||
session = self._tool_to_session[name]
|
session = self._tool_to_session[name]
|
||||||
session_tool_name = self.tools[name].name
|
session_tool_name = self.tools[name].name
|
||||||
return await session.call_tool(
|
return await session.call_tool(
|
||||||
session_tool_name,
|
session_tool_name,
|
||||||
arguments if args is None else args,
|
arguments=arguments,
|
||||||
read_timeout_seconds=read_timeout_seconds,
|
read_timeout_seconds=read_timeout_seconds,
|
||||||
progress_callback=progress_callback,
|
progress_callback=progress_callback,
|
||||||
meta=meta,
|
meta=meta,
|
||||||
|
|
|
||||||
|
|
@ -1196,9 +1196,6 @@ class ResourceLink(Resource):
|
||||||
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
|
ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource
|
||||||
"""A content block that can be used in prompts and tool results."""
|
"""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):
|
class PromptMessage(BaseModel):
|
||||||
"""Describes a message returned as part of a prompt."""
|
"""Describes a message returned as part of a prompt."""
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class TestClientSessionGroup:
|
||||||
assert result.content == [text_content]
|
assert result.content == [text_content]
|
||||||
mock_session.call_tool.assert_called_once_with(
|
mock_session.call_tool.assert_called_once_with(
|
||||||
"my_tool",
|
"my_tool",
|
||||||
{"name": "value1", "args": {}},
|
arguments={"name": "value1", "args": {}},
|
||||||
read_timeout_seconds=None,
|
read_timeout_seconds=None,
|
||||||
progress_callback=None,
|
progress_callback=None,
|
||||||
meta=None,
|
meta=None,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue