Skip to content

Commit 50cdcfd

Browse files
fix: address review feedback — remove double onerror fire, align error messages
- Remove redundant onerror call in replayEvents send callback (writeSSEEvent already reports the actual error) - Add trailing period to handleUnsupportedRequest onerror message to match response body - Include supported versions list in validateProtocolVersion onerror message to match response body
1 parent 4985f69 commit 50cdcfd

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

packages/server/src/server/streamableHttp.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
534534
send: async (eventId: string, message: JSONRPCMessage) => {
535535
const success = this.writeSSEEvent(streamController!, encoder, message, eventId);
536536
if (!success) {
537-
this.onerror?.(new Error('Failed replay events'));
538537
try {
539538
streamController!.close();
540539
} catch {
@@ -592,7 +591,7 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
592591
* Handles unsupported requests (`PUT`, `PATCH`, etc.)
593592
*/
594593
private handleUnsupportedRequest(): Response {
595-
this.onerror?.(new Error('Method not allowed'));
594+
this.onerror?.(new Error('Method not allowed.'));
596595
return Response.json(
597596
{
598597
jsonrpc: '2.0',
@@ -893,12 +892,9 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
893892
const protocolVersion = req.headers.get('mcp-protocol-version');
894893

895894
if (protocolVersion !== null && !this._supportedProtocolVersions.includes(protocolVersion)) {
896-
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion}`));
897-
return this.createJsonErrorResponse(
898-
400,
899-
-32_000,
900-
`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${this._supportedProtocolVersions.join(', ')})`
901-
);
895+
const error = `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${this._supportedProtocolVersions.join(', ')})`;
896+
this.onerror?.(new Error(error));
897+
return this.createJsonErrorResponse(400, -32_000, error);
902898
}
903899
return undefined;
904900
}

0 commit comments

Comments
 (0)