Skip to content

Commit b618157

Browse files
committed
Continue allowing 2024-10-07 in version negotiation
1 parent 0bf7e66 commit b618157

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

src/client/index.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
import { ProgressCallback, Protocol } from "../shared/protocol.js";
22
import { Transport } from "../shared/transport.js";
33
import {
4+
CallToolRequest,
5+
CallToolResultSchema,
46
ClientNotification,
57
ClientRequest,
68
ClientResult,
7-
Implementation,
8-
InitializeResultSchema,
9-
Notification,
10-
PROTOCOL_VERSION,
11-
Request,
12-
Result,
13-
ServerCapabilities,
149
CompleteRequest,
15-
GetPromptRequest,
16-
ListPromptsRequest,
17-
ListResourcesRequest,
18-
ReadResourceRequest,
19-
SubscribeRequest,
20-
UnsubscribeRequest,
21-
CallToolRequest,
22-
ListToolsRequest,
2310
CompleteResultSchema,
11+
EmptyResultSchema,
12+
GetPromptRequest,
2413
GetPromptResultSchema,
14+
Implementation,
15+
InitializeResultSchema,
16+
LATEST_PROTOCOL_VERSION,
17+
ListPromptsRequest,
2518
ListPromptsResultSchema,
19+
ListResourcesRequest,
2620
ListResourcesResultSchema,
27-
ReadResourceResultSchema,
28-
CallToolResultSchema,
29-
ListToolsResultSchema,
30-
EmptyResultSchema,
31-
LoggingLevel,
3221
ListResourceTemplatesRequest,
3322
ListResourceTemplatesResultSchema,
23+
ListToolsRequest,
24+
ListToolsResultSchema,
25+
LoggingLevel,
26+
Notification,
27+
ReadResourceRequest,
28+
ReadResourceResultSchema,
29+
Request,
30+
Result,
31+
ServerCapabilities,
32+
SubscribeRequest,
33+
SUPPORTED_PROTOCOL_VERSIONS,
34+
UnsubscribeRequest
3435
} from "../types.js";
3536

3637
/**
@@ -84,7 +85,7 @@ export class Client<
8485
{
8586
method: "initialize",
8687
params: {
87-
protocolVersion: PROTOCOL_VERSION,
88+
protocolVersion: LATEST_PROTOCOL_VERSION,
8889
capabilities: {},
8990
clientInfo: this._clientInfo,
9091
},
@@ -96,7 +97,7 @@ export class Client<
9697
throw new Error(`Server sent invalid initialize result: ${result}`);
9798
}
9899

99-
if (result.protocolVersion !== PROTOCOL_VERSION) {
100+
if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
100101
throw new Error(
101102
`Server's protocol version is not supported: ${result.protocolVersion}`,
102103
);

src/server/index.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
import { ProgressCallback, Protocol } from "../shared/protocol.js";
22
import {
33
ClientCapabilities,
4+
CreateMessageRequest,
5+
CreateMessageResultSchema,
6+
EmptyResultSchema,
47
Implementation,
58
InitializedNotificationSchema,
69
InitializeRequest,
710
InitializeRequestSchema,
811
InitializeResult,
12+
LATEST_PROTOCOL_VERSION,
13+
ListPromptsRequestSchema,
14+
ListResourcesRequestSchema,
15+
ListRootsRequest,
16+
ListRootsResultSchema,
17+
ListToolsRequestSchema,
18+
LoggingMessageNotification,
919
Notification,
10-
PROTOCOL_VERSION,
1120
Request,
21+
ResourceUpdatedNotification,
1222
Result,
23+
ServerCapabilities,
1324
ServerNotification,
1425
ServerRequest,
1526
ServerResult,
16-
ServerCapabilities,
17-
ListResourcesRequestSchema,
18-
ListToolsRequestSchema,
19-
ListPromptsRequestSchema,
2027
SetLevelRequestSchema,
21-
CreateMessageRequest,
22-
CreateMessageResultSchema,
23-
EmptyResultSchema,
24-
LoggingMessageNotification,
25-
ResourceUpdatedNotification,
26-
ListRootsRequest,
27-
ListRootsResultSchema,
28+
SUPPORTED_PROTOCOL_VERSIONS
2829
} from "../types.js";
2930

3031
/**
@@ -86,17 +87,13 @@ export class Server<
8687
private async _oninitialize(
8788
request: InitializeRequest,
8889
): 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;
9491

9592
this._clientCapabilities = request.params.capabilities;
9693
this._clientVersion = request.params.clientInfo;
9794

9895
return {
99-
protocolVersion: PROTOCOL_VERSION,
96+
protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION,
10097
capabilities: this.getCapabilities(),
10198
serverInfo: this._serverInfo,
10299
};

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from "zod";
22

3-
export const PROTOCOL_VERSION = "2024-11-05";
3+
export const LATEST_PROTOCOL_VERSION = "2024-11-05";
4+
export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2024-10-07"];
45

56
/* JSON-RPC types */
67
export const JSONRPC_VERSION = "2.0";

0 commit comments

Comments
 (0)