diff --git a/docs/spec/lifecycle.md b/docs/spec/lifecycle.md index 6be76ecea..d0a1492e1 100644 --- a/docs/spec/lifecycle.md +++ b/docs/spec/lifecycle.md @@ -48,17 +48,19 @@ This sequence ensures that both parties are aware of each other's capabilities a ## Initialization The initialization process **MUST** begin with the client sending an `initialize` request to the server. This request **MUST** include: -- The *protocol version* supported by the client as a numeric integer +- The *protocol version* supported by the client, as a string - The client's capabilities - Information about the client implementation +Protocol versions are represented as strings in the format `YYYY-MM-DD` (year–month–day, all zero-padded), and can be lexicographically compared—for example, `2024-10-07` is greater than `2024-10-06`. + {{}} {{}} ```typescript export interface InitializeRequest extends Request { method: "initialize"; params: { - protocolVersion: number; + protocolVersion: string; capabilities: ClientCapabilities; clientInfo: Implementation; }; @@ -72,7 +74,7 @@ export interface InitializeRequest extends Request { "id": 1, "method": "initialize", "params": { - "protocolVersion": 1, + "protocolVersion": "2024-10-07", "capabilities": { "experimental": {}, "sampling": {} @@ -98,7 +100,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult` {{}} ```typescript export interface InitializeResult extends Result { - protocolVersion: number; + protocolVersion: string; capabilities: ServerCapabilities; serverInfo: Implementation; } @@ -110,7 +112,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult` "jsonrpc": "2.0", "id": 1, "result": { - "protocolVersion": 1, + "protocolVersion": "2024-10-07", "capabilities": { "experimental": {}, "logging": {}, @@ -130,7 +132,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult` {{}} {{}} -If the server cannot support the protocol version requested by the client, it **SHOULD** respond with an error. +The server may choose a different protocol version than the client has requested. In such cases, it is up to the client whether to proceed with the connection or abort. ## Capability Exchange diff --git a/schema/schema.json b/schema/schema.json index e4c17ba7b..9c67f8851 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -461,9 +461,8 @@ "$ref": "#/definitions/Implementation" }, "protocolVersion": { - "const": 1, "description": "The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.", - "type": "integer" + "type": "string" } }, "required": [ @@ -492,9 +491,8 @@ "$ref": "#/definitions/ServerCapabilities" }, "protocolVersion": { - "const": 1, "description": "The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.", - "type": "integer" + "type": "string" }, "serverInfo": { "$ref": "#/definitions/Implementation" diff --git a/schema/schema.ts b/schema/schema.ts index 849efb919..346f06a16 100644 --- a/schema/schema.ts +++ b/schema/schema.ts @@ -109,7 +109,7 @@ export interface JSONRPCError { export type EmptyResult = Result; /* Initialization */ -export const PROTOCOL_VERSION = 1; +export const LATEST_PROTOCOL_VERSION = "2024-10-07"; /** * This request is sent from the client to the server when it first connects, asking it to begin initialization. */ @@ -119,7 +119,7 @@ export interface InitializeRequest extends Request { /** * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well. */ - protocolVersion: typeof PROTOCOL_VERSION; + protocolVersion: string; capabilities: ClientCapabilities; clientInfo: Implementation; }; @@ -132,7 +132,7 @@ export interface InitializeResult extends Result { /** * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect. */ - protocolVersion: typeof PROTOCOL_VERSION; + protocolVersion: string; capabilities: ServerCapabilities; serverInfo: Implementation; }