1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\JsonRpc;
15:
16: use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcNotification;
17: use Nexus\Mcp\Core\Schema\JsonRpc\JsonRpcRequest;
18: use Nexus\Mcp\Core\Schema\Notification\CancelledNotification;
19: use Nexus\Mcp\Core\Schema\Notification\ElicitationCompleteNotification;
20: use Nexus\Mcp\Core\Schema\Notification\InitializedNotification;
21: use Nexus\Mcp\Core\Schema\Notification\LoggingMessageNotification;
22: use Nexus\Mcp\Core\Schema\Notification\ProgressNotification;
23: use Nexus\Mcp\Core\Schema\Notification\PromptListChangedNotification;
24: use Nexus\Mcp\Core\Schema\Notification\ResourceListChangedNotification;
25: use Nexus\Mcp\Core\Schema\Notification\ResourceUpdatedNotification;
26: use Nexus\Mcp\Core\Schema\Notification\RootsListChangedNotification;
27: use Nexus\Mcp\Core\Schema\Notification\TaskStatusNotification;
28: use Nexus\Mcp\Core\Schema\Notification\ToolListChangedNotification;
29: use Nexus\Mcp\Core\Schema\Request\CallToolRequest;
30: use Nexus\Mcp\Core\Schema\Request\CancelTaskRequest;
31: use Nexus\Mcp\Core\Schema\Request\CompleteRequest;
32: use Nexus\Mcp\Core\Schema\Request\CreateMessageRequest;
33: use Nexus\Mcp\Core\Schema\Request\ElicitRequest;
34: use Nexus\Mcp\Core\Schema\Request\GetPromptRequest;
35: use Nexus\Mcp\Core\Schema\Request\GetTaskPayloadRequest;
36: use Nexus\Mcp\Core\Schema\Request\GetTaskRequest;
37: use Nexus\Mcp\Core\Schema\Request\InitializeRequest;
38: use Nexus\Mcp\Core\Schema\Request\ListPromptsRequest;
39: use Nexus\Mcp\Core\Schema\Request\ListResourcesRequest;
40: use Nexus\Mcp\Core\Schema\Request\ListResourceTemplatesRequest;
41: use Nexus\Mcp\Core\Schema\Request\ListRootsRequest;
42: use Nexus\Mcp\Core\Schema\Request\ListTasksRequest;
43: use Nexus\Mcp\Core\Schema\Request\ListToolsRequest;
44: use Nexus\Mcp\Core\Schema\Request\PingRequest;
45: use Nexus\Mcp\Core\Schema\Request\ReadResourceRequest;
46: use Nexus\Mcp\Core\Schema\Request\SetLevelRequest;
47: use Nexus\Mcp\Core\Schema\Request\SubscribeRequest;
48: use Nexus\Mcp\Core\Schema\Request\UnsubscribeRequest;
49:
50: /**
51: * Spec-default method → class maps consumed by `JsonRpcMessageParser`.
52: */
53: final class JsonRpcMethodRegistry
54: {
55: /**
56: * Keyed by spec method literal (`completion/complete`, `initialize`, etc.), sorted by key.
57: *
58: * @return array<non-empty-string, class-string<JsonRpcRequest<non-empty-string>>>
59: */
60: public static function requests(): array
61: {
62: return [
63: CompleteRequest::getMethod() => CompleteRequest::class,
64: ElicitRequest::getMethod() => ElicitRequest::class,
65: InitializeRequest::getMethod() => InitializeRequest::class,
66: SetLevelRequest::getMethod() => SetLevelRequest::class,
67: PingRequest::getMethod() => PingRequest::class,
68: GetPromptRequest::getMethod() => GetPromptRequest::class,
69: ListPromptsRequest::getMethod() => ListPromptsRequest::class,
70: ListResourcesRequest::getMethod() => ListResourcesRequest::class,
71: ReadResourceRequest::getMethod() => ReadResourceRequest::class,
72: SubscribeRequest::getMethod() => SubscribeRequest::class,
73: ListResourceTemplatesRequest::getMethod() => ListResourceTemplatesRequest::class,
74: UnsubscribeRequest::getMethod() => UnsubscribeRequest::class,
75: ListRootsRequest::getMethod() => ListRootsRequest::class,
76: CreateMessageRequest::getMethod() => CreateMessageRequest::class,
77: CancelTaskRequest::getMethod() => CancelTaskRequest::class,
78: GetTaskRequest::getMethod() => GetTaskRequest::class,
79: ListTasksRequest::getMethod() => ListTasksRequest::class,
80: GetTaskPayloadRequest::getMethod() => GetTaskPayloadRequest::class,
81: CallToolRequest::getMethod() => CallToolRequest::class,
82: ListToolsRequest::getMethod() => ListToolsRequest::class,
83: ];
84: }
85:
86: /**
87: * Keyed by spec method literal (`notifications/cancelled`, etc.), sorted by key.
88: *
89: * @return array<non-empty-string, class-string<JsonRpcNotification<non-empty-string>>>
90: */
91: public static function notifications(): array
92: {
93: return [
94: CancelledNotification::getMethod() => CancelledNotification::class,
95: ElicitationCompleteNotification::getMethod() => ElicitationCompleteNotification::class,
96: InitializedNotification::getMethod() => InitializedNotification::class,
97: LoggingMessageNotification::getMethod() => LoggingMessageNotification::class,
98: ProgressNotification::getMethod() => ProgressNotification::class,
99: PromptListChangedNotification::getMethod() => PromptListChangedNotification::class,
100: ResourceListChangedNotification::getMethod() => ResourceListChangedNotification::class,
101: ResourceUpdatedNotification::getMethod() => ResourceUpdatedNotification::class,
102: RootsListChangedNotification::getMethod() => RootsListChangedNotification::class,
103: TaskStatusNotification::getMethod() => TaskStatusNotification::class,
104: ToolListChangedNotification::getMethod() => ToolListChangedNotification::class,
105: ];
106: }
107: }
108: