Skip to content

Commit 935fe5d

Browse files
committed
Make call_tool() return value covariant
`list` is invariant, hence handlers can't just return `list[str]`. We need to use Sequence here.
1 parent 74c49c2 commit 935fe5d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mcp_python/server/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import warnings
44
from collections.abc import Awaitable, Callable
5-
from typing import Any
5+
from typing import Any, Sequence
66

77
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
88
from pydantic import AnyUrl
@@ -337,7 +337,7 @@ def call_tool(self):
337337

338338
def decorator(
339339
func: Callable[
340-
..., Awaitable[list[str | types.ImageContent | types.EmbeddedResource]]
340+
..., Awaitable[Sequence[str | types.ImageContent | types.EmbeddedResource]]
341341
],
342342
):
343343
logger.debug("Registering handler for CallToolRequest")

0 commit comments

Comments
 (0)