Skip to content

Commit 79d4464

Browse files
committed
Fix: Add proper authentication headers for SSE POST /message #2
1 parent ad8c9e6 commit 79d4464

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-proxy-server",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"author": "ptbsare",
55
"license": "MIT",
66
"description": "An MCP proxy server that aggregates and serves multiple MCP resource servers through a single interface with stdio/sse support",

src/client.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,28 @@ const createClient = (name: string, transportConfig: TransportConfig): { client:
2929
}
3030

3131
if (customHeaders) {
32+
// Apply custom headers to requestInit for POST requests
33+
transportOptions.requestInit = {
34+
headers: customHeaders,
35+
};
36+
37+
// Apply custom headers to eventSourceInit.fetch for GET requests
3238
const headersToAdd = customHeaders;
3339
transportOptions.eventSourceInit = {
3440
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {
3541
const originalHeaders = new Headers(init?.headers || {});
3642
for (const key in headersToAdd) {
37-
originalHeaders.set(key, headersToAdd[key]);
38-
}
39-
return fetch(input, {
40-
...init,
41-
headers: originalHeaders,
42-
});
43-
},
43+
originalHeaders.set(key, headersToAdd[key]);
44+
}
45+
return fetch(input, {
46+
...init,
47+
headers: originalHeaders,
48+
});
49+
},
4450
} as any;
45-
}
51+
}
4652

47-
transport = new SSEClientTransport(new URL(transportConfig.url), transportOptions);
53+
transport = new SSEClientTransport(new URL(transportConfig.url), transportOptions);
4854
} else if (isStdioConfig(transportConfig)) {
4955
const mergedEnv = {
5056
...process.env,

0 commit comments

Comments
 (0)