diff --git a/src/mcp/cli/__init__.py b/src/mcp/cli/__init__.py index 3ef56d806..0552a6616 100644 --- a/src/mcp/cli/__init__.py +++ b/src/mcp/cli/__init__.py @@ -1,4 +1,5 @@ """FastMCP CLI package.""" +# pyright: reportUnknownVariableType=false from .cli import app diff --git a/src/mcp/cli/cli.py b/src/mcp/cli/cli.py index 69e2921f1..0a4aa4da8 100644 --- a/src/mcp/cli/cli.py +++ b/src/mcp/cli/cli.py @@ -1,4 +1,8 @@ """MCP CLI tools.""" +# pyright: reportMissingImports=false +# pyright: reportUnknownMemberType=false +# pyright: reportUnknownVariableType=false +# pyright: reportUntypedFunctionDecorator=false import importlib.metadata import importlib.util diff --git a/src/mcp/client/session.py b/src/mcp/client/session.py index 948817140..3d6b9fb31 100644 --- a/src/mcp/client/session.py +++ b/src/mcp/client/session.py @@ -96,11 +96,12 @@ async def _default_logging_callback( class ClientSession( BaseSession[ - types.ClientRequest, - types.ClientNotification, - types.ClientResult, - types.ServerRequest, - types.ServerNotification, + types.ClientRequest, # SendRequestT + types.ClientNotification, # SendNotificationT + types.ClientResult, # SendResultT + types.ServerRequest, # ReceiveRequestT + Any, # ReceiveResultT,Any Type + types.ServerNotification, # ReceiveNotificationT ] ): def __init__( diff --git a/src/mcp/client/websocket.py b/src/mcp/client/websocket.py index 0a371610b..85e0dbf91 100644 --- a/src/mcp/client/websocket.py +++ b/src/mcp/client/websocket.py @@ -1,3 +1,8 @@ +# pyright: reportMissingImports=false +# pyright: reportUnknownVariableType=false +# pyright: reportUnknownArgumentType=false +# pyright: reportUnknownMemberType=false + import json import logging from collections.abc import AsyncGenerator diff --git a/src/mcp/server/session.py b/src/mcp/server/session.py index 5c696b136..50c29055f 100644 --- a/src/mcp/server/session.py +++ b/src/mcp/server/session.py @@ -74,6 +74,7 @@ class ServerSession( types.ServerNotification, types.ServerResult, types.ClientRequest, + Any, types.ClientNotification, ] ): diff --git a/src/mcp/shared/context.py b/src/mcp/shared/context.py index f3006e7d5..4050d2b40 100644 --- a/src/mcp/shared/context.py +++ b/src/mcp/shared/context.py @@ -6,7 +6,7 @@ from mcp.shared.session import BaseSession from mcp.types import RequestId, RequestParams -SessionT = TypeVar("SessionT", bound=BaseSession[Any, Any, Any, Any, Any]) +SessionT = TypeVar("SessionT", bound=BaseSession[Any, Any, Any, Any, Any, Any]) LifespanContextT = TypeVar("LifespanContextT") RequestT = TypeVar("RequestT", default=Any) diff --git a/src/mcp/shared/progress.py b/src/mcp/shared/progress.py index 1ad81a779..76d06b58e 100644 --- a/src/mcp/shared/progress.py +++ b/src/mcp/shared/progress.py @@ -10,6 +10,7 @@ BaseSession, ReceiveNotificationT, ReceiveRequestT, + ReceiveResultT, SendNotificationT, SendRequestT, SendResultT, @@ -23,8 +24,12 @@ class Progress(BaseModel): @dataclass -class ProgressContext(Generic[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT]): - session: BaseSession[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT] +class ProgressContext( + Generic[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT, ReceiveResultT] +): + session: BaseSession[ + SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveResultT, ReceiveNotificationT + ] progress_token: ProgressToken total: float | None current: float = field(default=0.0, init=False) @@ -40,12 +45,16 @@ async def progress(self, amount: float, message: str | None = None) -> None: @contextmanager def progress( ctx: RequestContext[ - BaseSession[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT], + BaseSession[ + SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveResultT, ReceiveNotificationT + ], LifespanContextT, ], total: float | None = None, ) -> Generator[ - ProgressContext[SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT], + ProgressContext[ + SendRequestT, SendNotificationT, SendResultT, ReceiveRequestT, ReceiveNotificationT, ReceiveResultT + ], None, ]: if ctx.meta is None or ctx.meta.progressToken is None: diff --git a/src/mcp/shared/session.py b/src/mcp/shared/session.py index 6536272d9..93cbbbde8 100644 --- a/src/mcp/shared/session.py +++ b/src/mcp/shared/session.py @@ -75,6 +75,7 @@ def __init__( SendNotificationT, SendResultT, ReceiveRequestT, + ReceiveResultT, ReceiveNotificationT ]""", on_complete: Callable[["RequestResponder[ReceiveRequestT, SendResultT]"], Any], @@ -162,6 +163,7 @@ class BaseSession( SendNotificationT, SendResultT, ReceiveRequestT, + ReceiveResultT, ReceiveNotificationT, ], ): diff --git a/tests/shared/test_progress_notifications.py b/tests/shared/test_progress_notifications.py index 08bcb2662..069738a9d 100644 --- a/tests/shared/test_progress_notifications.py +++ b/tests/shared/test_progress_notifications.py @@ -290,7 +290,7 @@ async def handle_client_message( # cast for type checker typed_context = cast( RequestContext[ - BaseSession[Any, Any, Any, Any, Any], + BaseSession[Any, Any, Any, Any, Any, Any], Any, ], request_context,