Skip to content

Commit 8b6e455

Browse files
authored
fix(server): application/json header for notifictions (#1373)
1 parent 09a658b commit 8b6e455

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

.changeset/strong-hairs-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelcontextprotocol/server': patch
3+
---
4+
5+
add application/json header for notifications

packages/server/src/server/webStandardStreamableHttp.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,12 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
667667
for (const message of messages) {
668668
this.onmessage?.(message, { authInfo: options?.authInfo, requestInfo });
669669
}
670-
return new Response(null, { status: 202 });
670+
return new Response(null, {
671+
status: 202,
672+
headers: {
673+
'Content-Type': 'application/json'
674+
}
675+
});
671676
}
672677

673678
// The default behavior is to use SSE streaming

packages/server/test/server/streamableHttp.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
651651
const response = await sendPostRequest(baseUrl, batchNotifications, sessionId);
652652

653653
expect(response.status).toBe(202);
654+
expect(response.headers.get('content-type')).toBe('application/json');
654655
});
655656

656657
it('should handle batch request messages with SSE stream for responses', async () => {

0 commit comments

Comments
 (0)