|
1 | 1 | import { ProgressCallback, Protocol } from "../shared/protocol.js";
|
2 | 2 | import {
|
3 | 3 | ClientCapabilities,
|
| 4 | + CreateMessageRequest, |
| 5 | + CreateMessageResultSchema, |
| 6 | + EmptyResultSchema, |
4 | 7 | Implementation,
|
5 | 8 | InitializedNotificationSchema,
|
6 | 9 | InitializeRequest,
|
7 | 10 | InitializeRequestSchema,
|
8 | 11 | InitializeResult,
|
| 12 | + LATEST_PROTOCOL_VERSION, |
| 13 | + ListPromptsRequestSchema, |
| 14 | + ListResourcesRequestSchema, |
| 15 | + ListRootsRequest, |
| 16 | + ListRootsResultSchema, |
| 17 | + ListToolsRequestSchema, |
| 18 | + LoggingMessageNotification, |
9 | 19 | Notification,
|
10 |
| - PROTOCOL_VERSION, |
11 | 20 | Request,
|
| 21 | + ResourceUpdatedNotification, |
12 | 22 | Result,
|
| 23 | + ServerCapabilities, |
13 | 24 | ServerNotification,
|
14 | 25 | ServerRequest,
|
15 | 26 | ServerResult,
|
16 |
| - ServerCapabilities, |
17 |
| - ListResourcesRequestSchema, |
18 |
| - ListToolsRequestSchema, |
19 |
| - ListPromptsRequestSchema, |
20 | 27 | SetLevelRequestSchema,
|
21 |
| - CreateMessageRequest, |
22 |
| - CreateMessageResultSchema, |
23 |
| - EmptyResultSchema, |
24 |
| - LoggingMessageNotification, |
25 |
| - ResourceUpdatedNotification, |
26 |
| - ListRootsRequest, |
27 |
| - ListRootsResultSchema, |
| 28 | + SUPPORTED_PROTOCOL_VERSIONS |
28 | 29 | } from "../types.js";
|
29 | 30 |
|
30 | 31 | /**
|
@@ -86,17 +87,13 @@ export class Server<
|
86 | 87 | private async _oninitialize(
|
87 | 88 | request: InitializeRequest,
|
88 | 89 | ): Promise<InitializeResult> {
|
89 |
| - if (request.params.protocolVersion !== PROTOCOL_VERSION) { |
90 |
| - throw new Error( |
91 |
| - `Client's protocol version is not supported: ${request.params.protocolVersion}`, |
92 |
| - ); |
93 |
| - } |
| 90 | + const requestedVersion = request.params.protocolVersion; |
94 | 91 |
|
95 | 92 | this._clientCapabilities = request.params.capabilities;
|
96 | 93 | this._clientVersion = request.params.clientInfo;
|
97 | 94 |
|
98 | 95 | return {
|
99 |
| - protocolVersion: PROTOCOL_VERSION, |
| 96 | + protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION, |
100 | 97 | capabilities: this.getCapabilities(),
|
101 | 98 | serverInfo: this._serverInfo,
|
102 | 99 | };
|
|
0 commit comments