Fix: Handle error responses in Streamable HTTP SSE streams (#1390)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
parent
fcde488227
commit
9bc9abc68b
1 changed files with 80 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import type { FetchLike, JSONRPCMessage, Transport } from '@modelcontextprotocol
|
|||
import {
|
||||
createFetchWithInit,
|
||||
isInitializedNotification,
|
||||
isJSONRPCErrorResponse,
|
||||
isJSONRPCRequest,
|
||||
isJSONRPCResultResponse,
|
||||
JSONRPCMessageSchema,
|
||||
|
|
@ -412,7 +413,8 @@ export class StreamableHTTPClientTransport implements Transport {
|
|||
if (!event.event || event.event === 'message') {
|
||||
try {
|
||||
const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
|
||||
if (isJSONRPCResultResponse(message)) {
|
||||
// Handle both success AND error responses for completion detection and ID remapping
|
||||
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
|
||||
// Mark that we received a response - no need to reconnect for this request
|
||||
receivedResponse = true;
|
||||
if (replayMessageId !== undefined) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue