Skip to content

Commit ac6064b

Browse files
committed
Make request and notification method generic
The request and notification method were defined as str but later overwritten in subclasses with literals. This causes a reportIncompatibleVariableOverride issue. We need to make method generic.
1 parent 04ad96e commit ac6064b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

mcp_python/types.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,23 @@ class Meta(BaseModel):
4141
This parameter name is reserved by MCP to allow clients and servers to attach additional metadata to their notifications.
4242
"""
4343

44-
4544
RequestParamsT = TypeVar("RequestParamsT", bound=RequestParams)
4645
NotificationParamsT = TypeVar("NotificationParamsT", bound=NotificationParams)
46+
MethodT = TypeVar("MethodT", bound=str)
4747

4848

49-
class Request(BaseModel, Generic[RequestParamsT]):
49+
class Request(BaseModel, Generic[RequestParamsT, MethodT]):
5050
"""Base class for JSON-RPC requests."""
5151

52-
method: str
52+
method: MethodT
5353
params: RequestParamsT
5454
model_config = ConfigDict(extra="allow")
5555

5656

57-
class Notification(BaseModel, Generic[NotificationParamsT]):
57+
class Notification(BaseModel, Generic[NotificationParamsT, MethodT]):
5858
"""Base class for JSON-RPC notifications."""
5959

60-
method: str
60+
method: MethodT
6161
model_config = ConfigDict(extra="allow")
6262

6363

0 commit comments

Comments
 (0)