Skip to content

Commit e010392

Browse files
Merge pull request modelcontextprotocol#22 from modelcontextprotocol/justin/version-string
Change protocol version to a string, rev to 2024-10-07
2 parents 74d9a2f + 9291c0b commit e010392

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

docs/spec/lifecycle.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,19 @@ This sequence ensures that both parties are aware of each other's capabilities a
4848
## Initialization
4949
The initialization process **MUST** begin with the client sending an `initialize` request to the server. This request **MUST** include:
5050

51-
- The *protocol version* supported by the client as a numeric integer
51+
- The *protocol version* supported by the client, as a string
5252
- The client's capabilities
5353
- Information about the client implementation
5454

55+
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`.
56+
5557
{{<tabs items="Spec (TS),Example">}}
5658
{{<tab>}}
5759
```typescript
5860
export interface InitializeRequest extends Request {
5961
method: "initialize";
6062
params: {
61-
protocolVersion: number;
63+
protocolVersion: string;
6264
capabilities: ClientCapabilities;
6365
clientInfo: Implementation;
6466
};
@@ -72,7 +74,7 @@ export interface InitializeRequest extends Request {
7274
"id": 1,
7375
"method": "initialize",
7476
"params": {
75-
"protocolVersion": 1,
77+
"protocolVersion": "2024-10-07",
7678
"capabilities": {
7779
"experimental": {},
7880
"sampling": {}
@@ -98,7 +100,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult`
98100
{{<tab>}}
99101
```typescript
100102
export interface InitializeResult extends Result {
101-
protocolVersion: number;
103+
protocolVersion: string;
102104
capabilities: ServerCapabilities;
103105
serverInfo: Implementation;
104106
}
@@ -110,7 +112,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult`
110112
"jsonrpc": "2.0",
111113
"id": 1,
112114
"result": {
113-
"protocolVersion": 1,
115+
"protocolVersion": "2024-10-07",
114116
"capabilities": {
115117
"experimental": {},
116118
"logging": {},
@@ -130,7 +132,7 @@ The server **MUST** respond to the initialize request with an `InitializeResult`
130132
{{</tab>}}
131133
{{</tabs>}}
132134

133-
If the server cannot support the protocol version requested by the client, it **SHOULD** respond with an error.
135+
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.
134136

135137
## Capability Exchange
136138

schema/schema.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,8 @@
465465
"$ref": "#/definitions/Implementation"
466466
},
467467
"protocolVersion": {
468-
"const": 1,
469468
"description": "The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.",
470-
"type": "integer"
469+
"type": "string"
471470
}
472471
},
473472
"required": [
@@ -496,9 +495,8 @@
496495
"$ref": "#/definitions/ServerCapabilities"
497496
},
498497
"protocolVersion": {
499-
"const": 1,
500498
"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.",
501-
"type": "integer"
499+
"type": "string"
502500
},
503501
"serverInfo": {
504502
"$ref": "#/definitions/Implementation"

schema/schema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export interface JSONRPCError {
114114
export type EmptyResult = Result;
115115

116116
/* Initialization */
117-
export const PROTOCOL_VERSION = 1;
117+
export const LATEST_PROTOCOL_VERSION = "2024-10-07";
118118
/**
119119
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
120120
*/
@@ -124,7 +124,7 @@ export interface InitializeRequest extends Request {
124124
/**
125125
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
126126
*/
127-
protocolVersion: typeof PROTOCOL_VERSION;
127+
protocolVersion: string;
128128
capabilities: ClientCapabilities;
129129
clientInfo: Implementation;
130130
};
@@ -137,7 +137,7 @@ export interface InitializeResult extends Result {
137137
/**
138138
* 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.
139139
*/
140-
protocolVersion: typeof PROTOCOL_VERSION;
140+
protocolVersion: string;
141141
capabilities: ServerCapabilities;
142142
serverInfo: Implementation;
143143
}

0 commit comments

Comments
 (0)