methods
Per-version method maps and parse/serialize functions for MCP traffic.
This module is supported public API; the mcp.types.v* packages it draws on
are internal validators and not for direct import.
Surface maps key (method, version) to per-version wire types (key absence is
the version gate; shape validation is per schema era, i.e. 2025-11-25 for every
pre-2026 version and 2026-07-28 for 2026). Monolith maps key method to the
version-free mcp.types models user code receives.
SERVER_RESULTS
module-attribute
SERVER_RESULTS: Final[
Mapping[tuple[str, str], type[BaseModel] | UnionType]
] = MappingProxyType(
{
(
"completion/complete",
"2024-11-05",
): CompleteResult,
("initialize", "2024-11-05"): InitializeResult,
("logging/setLevel", "2024-11-05"): EmptyResult,
("ping", "2024-11-05"): EmptyResult,
("prompts/get", "2024-11-05"): GetPromptResult,
("prompts/list", "2024-11-05"): ListPromptsResult,
(
"resources/list",
"2024-11-05",
): ListResourcesResult,
(
"resources/read",
"2024-11-05",
): ReadResourceResult,
("resources/subscribe", "2024-11-05"): EmptyResult,
(
"resources/templates/list",
"2024-11-05",
): ListResourceTemplatesResult,
(
"resources/unsubscribe",
"2024-11-05",
): EmptyResult,
("tools/call", "2024-11-05"): CallToolResult,
("tools/list", "2024-11-05"): ListToolsResult,
(
"completion/complete",
"2025-03-26",
): CompleteResult,
("initialize", "2025-03-26"): InitializeResult,
("logging/setLevel", "2025-03-26"): EmptyResult,
("ping", "2025-03-26"): EmptyResult,
("prompts/get", "2025-03-26"): GetPromptResult,
("prompts/list", "2025-03-26"): ListPromptsResult,
(
"resources/list",
"2025-03-26",
): ListResourcesResult,
(
"resources/read",
"2025-03-26",
): ReadResourceResult,
("resources/subscribe", "2025-03-26"): EmptyResult,
(
"resources/templates/list",
"2025-03-26",
): ListResourceTemplatesResult,
(
"resources/unsubscribe",
"2025-03-26",
): EmptyResult,
("tools/call", "2025-03-26"): CallToolResult,
("tools/list", "2025-03-26"): ListToolsResult,
(
"completion/complete",
"2025-06-18",
): CompleteResult,
("initialize", "2025-06-18"): InitializeResult,
("logging/setLevel", "2025-06-18"): EmptyResult,
("ping", "2025-06-18"): EmptyResult,
("prompts/get", "2025-06-18"): GetPromptResult,
("prompts/list", "2025-06-18"): ListPromptsResult,
(
"resources/list",
"2025-06-18",
): ListResourcesResult,
(
"resources/read",
"2025-06-18",
): ReadResourceResult,
("resources/subscribe", "2025-06-18"): EmptyResult,
(
"resources/templates/list",
"2025-06-18",
): ListResourceTemplatesResult,
(
"resources/unsubscribe",
"2025-06-18",
): EmptyResult,
("tools/call", "2025-06-18"): CallToolResult,
("tools/list", "2025-06-18"): ListToolsResult,
(
"completion/complete",
"2025-11-25",
): CompleteResult,
("initialize", "2025-11-25"): InitializeResult,
("logging/setLevel", "2025-11-25"): EmptyResult,
("ping", "2025-11-25"): EmptyResult,
("prompts/get", "2025-11-25"): GetPromptResult,
("prompts/list", "2025-11-25"): ListPromptsResult,
(
"resources/list",
"2025-11-25",
): ListResourcesResult,
(
"resources/read",
"2025-11-25",
): ReadResourceResult,
("resources/subscribe", "2025-11-25"): EmptyResult,
(
"resources/templates/list",
"2025-11-25",
): ListResourceTemplatesResult,
(
"resources/unsubscribe",
"2025-11-25",
): EmptyResult,
("tools/call", "2025-11-25"): CallToolResult,
("tools/list", "2025-11-25"): ListToolsResult,
(
"completion/complete",
"2026-07-28",
): CompleteResult,
("prompts/get", "2026-07-28"): AnyGetPromptResult,
("prompts/list", "2026-07-28"): ListPromptsResult,
(
"resources/list",
"2026-07-28",
): ListResourcesResult,
(
"resources/read",
"2026-07-28",
): AnyReadResourceResult,
(
"resources/templates/list",
"2026-07-28",
): ListResourceTemplatesResult,
("server/discover", "2026-07-28"): DiscoverResult,
("subscriptions/listen", "2026-07-28"): EmptyResult,
("tools/call", "2026-07-28"): AnyCallToolResult,
("tools/list", "2026-07-28"): ListToolsResult,
}
)
Results servers send, keyed by the originating client request's (method, version).
CLIENT_RESULTS
module-attribute
CLIENT_RESULTS: Final[
Mapping[tuple[str, str], type[BaseModel] | UnionType]
] = MappingProxyType(
{
("ping", "2024-11-05"): EmptyResult,
("roots/list", "2024-11-05"): ListRootsResult,
(
"sampling/createMessage",
"2024-11-05",
): CreateMessageResult,
("ping", "2025-03-26"): EmptyResult,
("roots/list", "2025-03-26"): ListRootsResult,
(
"sampling/createMessage",
"2025-03-26",
): CreateMessageResult,
("elicitation/create", "2025-06-18"): ElicitResult,
("ping", "2025-06-18"): EmptyResult,
("roots/list", "2025-06-18"): ListRootsResult,
(
"sampling/createMessage",
"2025-06-18",
): CreateMessageResult,
("elicitation/create", "2025-11-25"): ElicitResult,
("ping", "2025-11-25"): EmptyResult,
("roots/list", "2025-11-25"): ListRootsResult,
(
"sampling/createMessage",
"2025-11-25",
): CreateMessageResult,
}
)
Results clients send, keyed by the originating server request's (method, version).
SPEC_CLIENT_METHODS
module-attribute
Spec request methods a client may send (any version); the server-side spec-method discriminator.
SPEC_CLIENT_NOTIFICATION_METHODS
module-attribute
SPEC_CLIENT_NOTIFICATION_METHODS: Final[frozenset[str]] = (
frozenset(m for (m, _) in CLIENT_NOTIFICATIONS)
)
Spec notification methods a client may send (any version); the server-side spec-method discriminator.
MONOLITH_REQUESTS
module-attribute
MONOLITH_REQUESTS: Final[
Mapping[str, type[Request[Any, Any]]]
] = MappingProxyType(
{
"completion/complete": CompleteRequest,
"elicitation/create": ElicitRequest,
"initialize": InitializeRequest,
"logging/setLevel": SetLevelRequest,
"ping": PingRequest,
"prompts/get": GetPromptRequest,
"prompts/list": ListPromptsRequest,
"resources/list": ListResourcesRequest,
"resources/read": ReadResourceRequest,
"resources/subscribe": SubscribeRequest,
"resources/templates/list": ListResourceTemplatesRequest,
"resources/unsubscribe": UnsubscribeRequest,
"roots/list": ListRootsRequest,
"sampling/createMessage": CreateMessageRequest,
"server/discover": DiscoverRequest,
"subscriptions/listen": SubscriptionsListenRequest,
"tools/call": CallToolRequest,
"tools/list": ListToolsRequest,
}
)
Monolith request model per method, both directions.
MONOLITH_NOTIFICATIONS
module-attribute
MONOLITH_NOTIFICATIONS: Final[
Mapping[str, type[Notification[Any, Any]]]
] = MappingProxyType(
{
"notifications/cancelled": CancelledNotification,
"notifications/elicitation/complete": ElicitCompleteNotification,
"notifications/initialized": InitializedNotification,
"notifications/message": LoggingMessageNotification,
"notifications/progress": ProgressNotification,
"notifications/prompts/list_changed": PromptListChangedNotification,
"notifications/resources/list_changed": ResourceListChangedNotification,
"notifications/resources/updated": ResourceUpdatedNotification,
"notifications/roots/list_changed": RootsListChangedNotification,
"notifications/subscriptions/acknowledged": SubscriptionsAcknowledgedNotification,
"notifications/tools/list_changed": ToolListChangedNotification,
}
)
Monolith notification model per method, both directions.
MONOLITH_RESULTS
module-attribute
MONOLITH_RESULTS: Final[
Mapping[str, type[Result] | UnionType]
] = MappingProxyType(
{
"completion/complete": CompleteResult,
"elicitation/create": ElicitResult,
"initialize": InitializeResult,
"logging/setLevel": EmptyResult,
"ping": EmptyResult,
"prompts/get": GetPromptResult
| InputRequiredResult,
"prompts/list": ListPromptsResult,
"resources/list": ListResourcesResult,
"resources/read": ReadResourceResult
| InputRequiredResult,
"resources/subscribe": EmptyResult,
"resources/templates/list": ListResourceTemplatesResult,
"resources/unsubscribe": EmptyResult,
"roots/list": ListRootsResult,
"sampling/createMessage": CreateMessageResult
| CreateMessageResultWithTools,
"server/discover": DiscoverResult,
"subscriptions/listen": EmptyResult,
"tools/call": CallToolResult | InputRequiredResult,
"tools/list": ListToolsResult,
}
)
Monolith result model (or two-arm union) per request method.
validate_client_request
validate_client_request(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = CLIENT_REQUESTS
) -> None
Validate a client request against surface only.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface validation. |
Source code in src/mcp/types/methods.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
parse_client_request
parse_client_request(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = CLIENT_REQUESTS,
monolith: Mapping[
str, type[Request[Any, Any]]
] = MONOLITH_REQUESTS
) -> Request[Any, Any]
Validate a client request against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel]]
|
|
CLIENT_REQUESTS
|
monolith
|
Mapping[str, type[Request[Any, Any]]]
|
|
MONOLITH_REQUESTS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |
parse_server_request
parse_server_request(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = SERVER_REQUESTS,
monolith: Mapping[
str, type[Request[Any, Any]]
] = MONOLITH_REQUESTS
) -> Request[Any, Any]
Validate a server request against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel]]
|
|
SERVER_REQUESTS
|
monolith
|
Mapping[str, type[Request[Any, Any]]]
|
|
MONOLITH_REQUESTS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
validate_client_notification
validate_client_notification(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = CLIENT_NOTIFICATIONS
) -> None
Validate a client notification against surface only.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface validation. |
Source code in src/mcp/types/methods.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
parse_client_notification
parse_client_notification(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = CLIENT_NOTIFICATIONS,
monolith: Mapping[
str, type[Notification[Any, Any]]
] = MONOLITH_NOTIFICATIONS
) -> Notification[Any, Any]
Validate a client notification against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel]]
|
|
CLIENT_NOTIFICATIONS
|
monolith
|
Mapping[str, type[Notification[Any, Any]]]
|
|
MONOLITH_NOTIFICATIONS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
parse_server_notification
parse_server_notification(
method: str,
version: str,
params: Mapping[str, Any] | None,
*,
surface: Mapping[
tuple[str, str], type[BaseModel]
] = SERVER_NOTIFICATIONS,
monolith: Mapping[
str, type[Notification[Any, Any]]
] = MONOLITH_NOTIFICATIONS
) -> Notification[Any, Any]
Validate a server notification against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel]]
|
|
SERVER_NOTIFICATIONS
|
monolith
|
Mapping[str, type[Notification[Any, Any]]]
|
|
MONOLITH_NOTIFICATIONS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
body fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
serialize_server_result
serialize_server_result(
method: str,
version: str,
data: Mapping[str, Any],
*,
surface: Mapping[
tuple[str, str], type[BaseModel] | UnionType
] = SERVER_RESULTS
) -> dict[str, Any]
Validate data against surface and return its surface-shaped dump.
The surface model carries extra="ignore", so fields not in version's
schema are dropped from the returned dict.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
result fails surface validation. |
Source code in src/mcp/types/methods.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
validate_server_result
validate_server_result(
method: str,
version: str,
data: Mapping[str, Any],
*,
surface: Mapping[
tuple[str, str], type[BaseModel] | UnionType
] = SERVER_RESULTS
) -> None
Validate a server result against surface only.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
result fails surface validation. |
Source code in src/mcp/types/methods.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
parse_server_result
parse_server_result(
method: str,
version: str,
data: Mapping[str, Any],
*,
surface: Mapping[
tuple[str, str], type[BaseModel] | UnionType
] = SERVER_RESULTS,
monolith: Mapping[
str, type[Result] | UnionType
] = MONOLITH_RESULTS
) -> Result
Validate a server result against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel] | UnionType]
|
|
SERVER_RESULTS
|
monolith
|
Mapping[str, type[Result] | UnionType]
|
|
MONOLITH_RESULTS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
result fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | |
validate_client_result
validate_client_result(
method: str,
version: str,
data: Mapping[str, Any],
*,
surface: Mapping[
tuple[str, str], type[BaseModel] | UnionType
] = CLIENT_RESULTS
) -> None
Validate a client result against surface only.
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
result fails surface validation. |
Source code in src/mcp/types/methods.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | |
parse_client_result
parse_client_result(
method: str,
version: str,
data: Mapping[str, Any],
*,
surface: Mapping[
tuple[str, str], type[BaseModel] | UnionType
] = CLIENT_RESULTS,
monolith: Mapping[
str, type[Result] | UnionType
] = MONOLITH_RESULTS
) -> Result
Validate a client result against surface, then parse and return its monolith model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
surface
|
Mapping[tuple[str, str], type[BaseModel] | UnionType]
|
|
CLIENT_RESULTS
|
monolith
|
Mapping[str, type[Result] | UnionType]
|
|
MONOLITH_RESULTS
|
Raises:
| Type | Description |
|---|---|
ValueError
|
|
KeyError
|
|
ValidationError
|
result fails surface or monolith validation. |
RuntimeError
|
surface matched but |
Source code in src/mcp/types/methods.py
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | |