Skip to content

Commit 572425e

Browse files
committed
feat: allow server to tell transport the protocol version
1 parent cd7a055 commit 572425e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/server/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,12 @@ export class Server<
442442

443443
const protocolVersion = SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION;
444444

445+
// Inform the transport of the negotiated protocol version.
446+
// This allows the transport to validate subsequent request headers.
447+
if (this.transport?.setProtocolVersion) {
448+
this.transport.setProtocolVersion(protocolVersion);
449+
}
450+
445451
return {
446452
protocolVersion,
447453
capabilities: this.getCapabilities(),

src/shared/transport.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ export interface Transport {
122122
sessionId?: string;
123123

124124
/**
125-
* Sets the protocol version used for the connection (called when the initialize response is received).
125+
* Sets the protocol version after negotiation during initialization.
126+
* This is called by the Server/Client class after the initialize handshake completes.
126127
*/
127128
setProtocolVersion?: (version: string) => void;
129+
130+
/**
131+
* Gets the negotiated protocol version, if set.
132+
* Available after initialization completes.
133+
*/
134+
protocolVersion?: string;
128135
}

0 commit comments

Comments
 (0)