Fix: Environment variable expansion in headers for HTTP-based MCP transports (#380)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: samanhappy <2755122+samanhappy@users.noreply.github.com>
This commit is contained in:
Copilot
2025-10-23 19:18:50 +08:00
committed by GitHub
parent c1fee91142
commit 7dbd6c386e
2 changed files with 182 additions and 3 deletions

View File

@@ -162,7 +162,7 @@ const createTransportFromConfig = (name: string, conf: ServerConfig): any => {
const options: any = {};
if (conf.headers && Object.keys(conf.headers).length > 0) {
options.requestInit = {
headers: conf.headers,
headers: replaceEnvVars(conf.headers),
};
}
transport = new StreamableHTTPClientTransport(new URL(conf.url || ''), options);
@@ -171,10 +171,10 @@ const createTransportFromConfig = (name: string, conf: ServerConfig): any => {
const options: any = {};
if (conf.headers && Object.keys(conf.headers).length > 0) {
options.eventSourceInit = {
headers: conf.headers,
headers: replaceEnvVars(conf.headers),
};
options.requestInit = {
headers: conf.headers,
headers: replaceEnvVars(conf.headers),
};
}
transport = new SSEClientTransport(new URL(conf.url), options);