Continue allowing 2024-10-07 in version negotiation
This commit is contained in:
parent
0bf7e66e98
commit
b618157c93
3 changed files with 40 additions and 41 deletions
|
|
@ -1,36 +1,37 @@
|
|||
import { ProgressCallback, Protocol } from "../shared/protocol.js";
|
||||
import { Transport } from "../shared/transport.js";
|
||||
import {
|
||||
CallToolRequest,
|
||||
CallToolResultSchema,
|
||||
ClientNotification,
|
||||
ClientRequest,
|
||||
ClientResult,
|
||||
CompleteRequest,
|
||||
CompleteResultSchema,
|
||||
EmptyResultSchema,
|
||||
GetPromptRequest,
|
||||
GetPromptResultSchema,
|
||||
Implementation,
|
||||
InitializeResultSchema,
|
||||
LATEST_PROTOCOL_VERSION,
|
||||
ListPromptsRequest,
|
||||
ListPromptsResultSchema,
|
||||
ListResourcesRequest,
|
||||
ListResourcesResultSchema,
|
||||
ListResourceTemplatesRequest,
|
||||
ListResourceTemplatesResultSchema,
|
||||
ListToolsRequest,
|
||||
ListToolsResultSchema,
|
||||
LoggingLevel,
|
||||
Notification,
|
||||
PROTOCOL_VERSION,
|
||||
ReadResourceRequest,
|
||||
ReadResourceResultSchema,
|
||||
Request,
|
||||
Result,
|
||||
ServerCapabilities,
|
||||
CompleteRequest,
|
||||
GetPromptRequest,
|
||||
ListPromptsRequest,
|
||||
ListResourcesRequest,
|
||||
ReadResourceRequest,
|
||||
SubscribeRequest,
|
||||
UnsubscribeRequest,
|
||||
CallToolRequest,
|
||||
ListToolsRequest,
|
||||
CompleteResultSchema,
|
||||
GetPromptResultSchema,
|
||||
ListPromptsResultSchema,
|
||||
ListResourcesResultSchema,
|
||||
ReadResourceResultSchema,
|
||||
CallToolResultSchema,
|
||||
ListToolsResultSchema,
|
||||
EmptyResultSchema,
|
||||
LoggingLevel,
|
||||
ListResourceTemplatesRequest,
|
||||
ListResourceTemplatesResultSchema,
|
||||
SUPPORTED_PROTOCOL_VERSIONS,
|
||||
UnsubscribeRequest
|
||||
} from "../types.js";
|
||||
|
||||
/**
|
||||
|
|
@ -84,7 +85,7 @@ export class Client<
|
|||
{
|
||||
method: "initialize",
|
||||
params: {
|
||||
protocolVersion: PROTOCOL_VERSION,
|
||||
protocolVersion: LATEST_PROTOCOL_VERSION,
|
||||
capabilities: {},
|
||||
clientInfo: this._clientInfo,
|
||||
},
|
||||
|
|
@ -96,7 +97,7 @@ export class Client<
|
|||
throw new Error(`Server sent invalid initialize result: ${result}`);
|
||||
}
|
||||
|
||||
if (result.protocolVersion !== PROTOCOL_VERSION) {
|
||||
if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
|
||||
throw new Error(
|
||||
`Server's protocol version is not supported: ${result.protocolVersion}`,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,30 +1,31 @@
|
|||
import { ProgressCallback, Protocol } from "../shared/protocol.js";
|
||||
import {
|
||||
ClientCapabilities,
|
||||
CreateMessageRequest,
|
||||
CreateMessageResultSchema,
|
||||
EmptyResultSchema,
|
||||
Implementation,
|
||||
InitializedNotificationSchema,
|
||||
InitializeRequest,
|
||||
InitializeRequestSchema,
|
||||
InitializeResult,
|
||||
LATEST_PROTOCOL_VERSION,
|
||||
ListPromptsRequestSchema,
|
||||
ListResourcesRequestSchema,
|
||||
ListRootsRequest,
|
||||
ListRootsResultSchema,
|
||||
ListToolsRequestSchema,
|
||||
LoggingMessageNotification,
|
||||
Notification,
|
||||
PROTOCOL_VERSION,
|
||||
Request,
|
||||
ResourceUpdatedNotification,
|
||||
Result,
|
||||
ServerCapabilities,
|
||||
ServerNotification,
|
||||
ServerRequest,
|
||||
ServerResult,
|
||||
ServerCapabilities,
|
||||
ListResourcesRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
ListPromptsRequestSchema,
|
||||
SetLevelRequestSchema,
|
||||
CreateMessageRequest,
|
||||
CreateMessageResultSchema,
|
||||
EmptyResultSchema,
|
||||
LoggingMessageNotification,
|
||||
ResourceUpdatedNotification,
|
||||
ListRootsRequest,
|
||||
ListRootsResultSchema,
|
||||
SUPPORTED_PROTOCOL_VERSIONS
|
||||
} from "../types.js";
|
||||
|
||||
/**
|
||||
|
|
@ -86,17 +87,13 @@ export class Server<
|
|||
private async _oninitialize(
|
||||
request: InitializeRequest,
|
||||
): Promise<InitializeResult> {
|
||||
if (request.params.protocolVersion !== PROTOCOL_VERSION) {
|
||||
throw new Error(
|
||||
`Client's protocol version is not supported: ${request.params.protocolVersion}`,
|
||||
);
|
||||
}
|
||||
const requestedVersion = request.params.protocolVersion;
|
||||
|
||||
this._clientCapabilities = request.params.capabilities;
|
||||
this._clientVersion = request.params.clientInfo;
|
||||
|
||||
return {
|
||||
protocolVersion: PROTOCOL_VERSION,
|
||||
protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION,
|
||||
capabilities: this.getCapabilities(),
|
||||
serverInfo: this._serverInfo,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const PROTOCOL_VERSION = "2024-11-05";
|
||||
export const LATEST_PROTOCOL_VERSION = "2024-11-05";
|
||||
export const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2024-10-07"];
|
||||
|
||||
/* JSON-RPC types */
|
||||
export const JSONRPC_VERSION = "2.0";
|
||||
|
|
|
|||
Loading…
Reference in a new issue