From df0dc31095f4adc31bdffecbf29f287e7ad8ba8a Mon Sep 17 00:00:00 2001 From: Liooo Date: Wed, 10 Dec 2025 22:50:26 +0900 Subject: [PATCH] fix: nullable json-rpc error id instead of optional --- src/server/streamableHttp.ts | 2 +- src/spec.types.ts | 2 +- src/types.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/streamableHttp.ts b/src/server/streamableHttp.ts index ab1131f63..219cb00cf 100644 --- a/src/server/streamableHttp.ts +++ b/src/server/streamableHttp.ts @@ -873,7 +873,7 @@ export class StreamableHTTPServerTransport implements Transport { let requestId = options?.relatedRequestId; if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) { // If the message is a response, use the request ID from the message - requestId = message.id; + requestId = message.id ?? undefined; } // Check if this message should be sent on the standalone SSE stream (no request ID) diff --git a/src/spec.types.ts b/src/spec.types.ts index 07a1cceff..3ee9880a8 100644 --- a/src/spec.types.ts +++ b/src/spec.types.ts @@ -169,7 +169,7 @@ export interface JSONRPCResultResponse { */ export interface JSONRPCErrorResponse { jsonrpc: typeof JSONRPC_VERSION; - id?: RequestId; + id: RequestId | null; error: Error; } diff --git a/src/types.ts b/src/types.ts index dc0c22353..e0cced52b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -198,7 +198,7 @@ export enum ErrorCode { export const JSONRPCErrorResponseSchema = z .object({ jsonrpc: z.literal(JSONRPC_VERSION), - id: RequestIdSchema.optional(), + id: RequestIdSchema.nullable(), error: z.object({ /** * The error type that occurred.