Skip to content

Commit 18a279e

Browse files
committed
show-server-info - fixes
1 parent 90d46a0 commit 18a279e

File tree

1 file changed

+48
-16
lines changed

1 file changed

+48
-16
lines changed

src/mcp/types.py

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Generic,
66
Literal,
77
TypeAlias,
8-
TypedDict,
98
TypeVar,
109
)
1110

@@ -74,7 +73,9 @@ class Meta(BaseModel):
7473

7574

7675
RequestParamsT = TypeVar("RequestParamsT", bound=RequestParams | dict[str, Any] | None)
77-
NotificationParamsT = TypeVar("NotificationParamsT", bound=NotificationParams | dict[str, Any] | None)
76+
NotificationParamsT = TypeVar(
77+
"NotificationParamsT", bound=NotificationParams | dict[str, Any] | None
78+
)
7879
MethodT = TypeVar("MethodT", bound=str)
7980

8081

@@ -190,7 +191,9 @@ class JSONRPCError(BaseModel):
190191
model_config = ConfigDict(extra="allow")
191192

192193

193-
class JSONRPCMessage(RootModel[JSONRPCRequest | JSONRPCNotification | JSONRPCResponse | JSONRPCError]):
194+
class JSONRPCMessage(
195+
RootModel[JSONRPCRequest | JSONRPCNotification | JSONRPCResponse | JSONRPCError]
196+
):
194197
pass
195198

196199

@@ -311,7 +314,9 @@ class InitializeResult(Result):
311314
"""Instructions describing how to use the server and its features."""
312315

313316

314-
class InitializedNotification(Notification[NotificationParams | None, Literal["notifications/initialized"]]):
317+
class InitializedNotification(
318+
Notification[NotificationParams | None, Literal["notifications/initialized"]]
319+
):
315320
"""
316321
This notification is sent from the client to the server after initialization has
317322
finished.
@@ -354,7 +359,9 @@ class ProgressNotificationParams(NotificationParams):
354359
model_config = ConfigDict(extra="allow")
355360

356361

357-
class ProgressNotification(Notification[ProgressNotificationParams, Literal["notifications/progress"]]):
362+
class ProgressNotification(
363+
Notification[ProgressNotificationParams, Literal["notifications/progress"]]
364+
):
358365
"""
359366
An out-of-band notification used to inform the receiver of a progress update for a
360367
long-running request.
@@ -450,7 +457,9 @@ class ReadResourceRequestParams(RequestParams):
450457
model_config = ConfigDict(extra="allow")
451458

452459

453-
class ReadResourceRequest(Request[ReadResourceRequestParams, Literal["resources/read"]]):
460+
class ReadResourceRequest(
461+
Request[ReadResourceRequestParams, Literal["resources/read"]]
462+
):
454463
"""Sent from the client to the server, to read a specific resource URI."""
455464

456465
method: Literal["resources/read"]
@@ -491,7 +500,9 @@ class ReadResourceResult(Result):
491500

492501

493502
class ResourceListChangedNotification(
494-
Notification[NotificationParams | None, Literal["notifications/resources/list_changed"]]
503+
Notification[
504+
NotificationParams | None, Literal["notifications/resources/list_changed"]
505+
]
495506
):
496507
"""
497508
An optional notification from the server to the client, informing it that the list
@@ -531,7 +542,9 @@ class UnsubscribeRequestParams(RequestParams):
531542
model_config = ConfigDict(extra="allow")
532543

533544

534-
class UnsubscribeRequest(Request[UnsubscribeRequestParams, Literal["resources/unsubscribe"]]):
545+
class UnsubscribeRequest(
546+
Request[UnsubscribeRequestParams, Literal["resources/unsubscribe"]]
547+
):
535548
"""
536549
Sent from the client to request cancellation of resources/updated notifications from
537550
the server.
@@ -553,7 +566,9 @@ class ResourceUpdatedNotificationParams(NotificationParams):
553566

554567

555568
class ResourceUpdatedNotification(
556-
Notification[ResourceUpdatedNotificationParams, Literal["notifications/resources/updated"]]
569+
Notification[
570+
ResourceUpdatedNotificationParams, Literal["notifications/resources/updated"]
571+
]
557572
):
558573
"""
559574
A notification from the server to the client, informing it that a resource has
@@ -681,7 +696,9 @@ class GetPromptResult(Result):
681696

682697

683698
class PromptListChangedNotification(
684-
Notification[NotificationParams | None, Literal["notifications/prompts/list_changed"]]
699+
Notification[
700+
NotificationParams | None, Literal["notifications/prompts/list_changed"]
701+
]
685702
):
686703
"""
687704
An optional notification from the server to the client, informing it that the list
@@ -788,7 +805,9 @@ class CallToolResult(Result):
788805
isError: bool = False
789806

790807

791-
class ToolListChangedNotification(Notification[NotificationParams | None, Literal["notifications/tools/list_changed"]]):
808+
class ToolListChangedNotification(
809+
Notification[NotificationParams | None, Literal["notifications/tools/list_changed"]]
810+
):
792811
"""
793812
An optional notification from the server to the client, informing it that the list
794813
of tools it offers has changed.
@@ -798,7 +817,9 @@ class ToolListChangedNotification(Notification[NotificationParams | None, Litera
798817
params: NotificationParams | None = None
799818

800819

801-
LoggingLevel = Literal["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]
820+
LoggingLevel = Literal[
821+
"debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"
822+
]
802823

803824

804825
class SetLevelRequestParams(RequestParams):
@@ -831,7 +852,9 @@ class LoggingMessageNotificationParams(NotificationParams):
831852
model_config = ConfigDict(extra="allow")
832853

833854

834-
class LoggingMessageNotification(Notification[LoggingMessageNotificationParams, Literal["notifications/message"]]):
855+
class LoggingMessageNotification(
856+
Notification[LoggingMessageNotificationParams, Literal["notifications/message"]]
857+
):
835858
"""Notification of a log message passed from server to client."""
836859

837860
method: Literal["notifications/message"]
@@ -926,7 +949,9 @@ class CreateMessageRequestParams(RequestParams):
926949
model_config = ConfigDict(extra="allow")
927950

928951

929-
class CreateMessageRequest(Request[CreateMessageRequestParams, Literal["sampling/createMessage"]]):
952+
class CreateMessageRequest(
953+
Request[CreateMessageRequestParams, Literal["sampling/createMessage"]]
954+
):
930955
"""A request from the server to sample an LLM via the client."""
931956

932957
method: Literal["sampling/createMessage"]
@@ -1083,7 +1108,9 @@ class CancelledNotificationParams(NotificationParams):
10831108
model_config = ConfigDict(extra="allow")
10841109

10851110

1086-
class CancelledNotification(Notification[CancelledNotificationParams, Literal["notifications/cancelled"]]):
1111+
class CancelledNotification(
1112+
Notification[CancelledNotificationParams, Literal["notifications/cancelled"]]
1113+
):
10871114
"""
10881115
This notification can be sent by either side to indicate that it is canceling a
10891116
previously-issued request.
@@ -1114,7 +1141,12 @@ class ClientRequest(
11141141

11151142

11161143
class ClientNotification(
1117-
RootModel[CancelledNotification | ProgressNotification | InitializedNotification | RootsListChangedNotification]
1144+
RootModel[
1145+
CancelledNotification
1146+
| ProgressNotification
1147+
| InitializedNotification
1148+
| RootsListChangedNotification
1149+
]
11181150
):
11191151
pass
11201152

0 commit comments

Comments
 (0)