Skip to content

Commit 0fb82c1

Browse files
suntp0xToshii
andauthored
fix:The POST requests of MCP's SSE server support setting headers. (RooCodeInc#2969)
* fix:The POST requests of MCP's SSE server support setting headers.(RooCodeInc#2652) * fix:The POST requests of MCP's SSE server support setting headers.(RooCodeInc#2652) --------- Co-authored-by: Toshii <[email protected]>
1 parent 36c3f93 commit 0fb82c1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/services/mcp/McpHub.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const BaseConfigSchema = z.object({
5656

5757
const SseConfigSchema = BaseConfigSchema.extend({
5858
url: z.string().url(),
59+
headers: z.record(z.string()).optional(), // headers of POST requests to the sse server
5960
}).transform((config) => ({
6061
...config,
6162
transportType: "sse" as const,
@@ -328,7 +329,14 @@ export class McpHub {
328329
let transport: StdioClientTransport | SSEClientTransport | StreamableHTTPClientTransport
329330

330331
if (config.transportType === "sse") {
331-
transport = new SSEClientTransport(new URL(config.url), {})
332+
// Set headers of POST requests to the sse server
333+
const postRequestInit = {
334+
headers: config.headers,
335+
}
336+
337+
transport = new SSEClientTransport(new URL(config.url), {
338+
requestInit: postRequestInit,
339+
})
332340
} else if (config.transportType === "http") {
333341
transport = new StreamableHTTPClientTransport(new URL(config.url), {})
334342
} else {

0 commit comments

Comments
 (0)