fix(server): application/json header for notifictions (#1373)

This commit is contained in:
Matt 2026-01-09 13:29:32 +00:00 • committed by GitHub
commit 8b6e455c79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@modelcontextprotocol/server': patch
---
add application/json header for notifications

View file

@ -667,7 +667,12 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
for (const message of messages) {
this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo });
}
return new Response(null, { status: 202 });
return new Response(null, {
status: 202,
headers: {
'Content-Type': 'application/json'
}
});
}
// The default behavior is to use SSE streaming

View file

@ -651,6 +651,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
const response = await sendPostRequest(baseUrl, batchNotifications, sessionId);
expect(response.status).toBe(202);
expect(response.headers.get('content-type')).toBe('application/json');
});
it('should handle batch request messages with SSE stream for responses', async () => {