Closed
Description
Validations
- I believe this is a way to improve. I'll try to join the Continue Discord for questions
- I'm not able to find an open issue that requests the same enhancement
Problem
Hello, I'm trying to use an MCP sse server protected by authentication, but I found that the headers are not sent in the request
I did the change in a local environment, and I want to share with you, and if it's useful could be added in the code
Solution
Headers in interfaces
https://github.com/continuedev/continue/blob/main/core/index.d.ts#L1105-L1124
export interface StdioOptions {
type: "stdio";
command: string;
args: string[];
env?: Record<string, string>;
headers?: HeadersInit;
}
export interface WebSocketOptions {
type: "websocket";
url: string;
headers?: HeadersInit;
}
export interface SSEOptions {
type: "sse";
url: string;
headers?: HeadersInit;
}
Send headers to mcp library
https://github.com/continuedev/continue/blob/main/core/context/mcp/index.ts#L170-L171
case "sse":
console.log("HEADERS");
console.log(options.transport.headers);
return new SSEClientTransport(new URL(options.transport.url), {
eventSourceInit: {
fetch: (input, init) =>
fetch(input, {
...init,
headers: {
...init?.headers,
...(options.transport.headers as Record<string, string> | undefined),
}
}),
},
requestInit: { headers: options.transport.headers }
});
These changes allow using a config like this (config.json)
"experimental": {
"modelContextProtocolServers": [
{
"name": "hola",
"transport": {
"type": "sse",
"url": "https://protected.example.org/sse",
"headers": {
"Authorization": "Bearer supertoken"
}
}
},
]
}