|
@@ -443,13 +443,16 @@ export class McpHub {
|
|
|
|
|
|
|
|
let transport: StdioClientTransport | SSEClientTransport
|
|
let transport: StdioClientTransport | SSEClientTransport
|
|
|
|
|
|
|
|
- if (config.type === "stdio") {
|
|
|
|
|
|
|
+ // Inject environment variables to the config
|
|
|
|
|
+ const configInjected = (await injectEnv(config)) as typeof config
|
|
|
|
|
+
|
|
|
|
|
+ if (configInjected.type === "stdio") {
|
|
|
transport = new StdioClientTransport({
|
|
transport = new StdioClientTransport({
|
|
|
- command: config.command,
|
|
|
|
|
- args: config.args,
|
|
|
|
|
- cwd: config.cwd,
|
|
|
|
|
|
|
+ command: configInjected.command,
|
|
|
|
|
+ args: configInjected.args,
|
|
|
|
|
+ cwd: configInjected.cwd,
|
|
|
env: {
|
|
env: {
|
|
|
- ...(config.env ? await injectEnv(config.env) : {}),
|
|
|
|
|
|
|
+ ...(configInjected.env || {}),
|
|
|
...(process.env.PATH ? { PATH: process.env.PATH } : {}),
|
|
...(process.env.PATH ? { PATH: process.env.PATH } : {}),
|
|
|
...(process.env.HOME ? { HOME: process.env.HOME } : {}),
|
|
...(process.env.HOME ? { HOME: process.env.HOME } : {}),
|
|
|
},
|
|
},
|
|
@@ -508,16 +511,16 @@ export class McpHub {
|
|
|
// SSE connection
|
|
// SSE connection
|
|
|
const sseOptions = {
|
|
const sseOptions = {
|
|
|
requestInit: {
|
|
requestInit: {
|
|
|
- headers: config.headers,
|
|
|
|
|
|
|
+ headers: configInjected.headers,
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
// Configure ReconnectingEventSource options
|
|
// Configure ReconnectingEventSource options
|
|
|
const reconnectingEventSourceOptions = {
|
|
const reconnectingEventSourceOptions = {
|
|
|
max_retry_time: 5000, // Maximum retry time in milliseconds
|
|
max_retry_time: 5000, // Maximum retry time in milliseconds
|
|
|
- withCredentials: config.headers?.["Authorization"] ? true : false, // Enable credentials if Authorization header exists
|
|
|
|
|
|
|
+ withCredentials: configInjected.headers?.["Authorization"] ? true : false, // Enable credentials if Authorization header exists
|
|
|
}
|
|
}
|
|
|
global.EventSource = ReconnectingEventSource
|
|
global.EventSource = ReconnectingEventSource
|
|
|
- transport = new SSEClientTransport(new URL(config.url), {
|
|
|
|
|
|
|
+ transport = new SSEClientTransport(new URL(configInjected.url), {
|
|
|
...sseOptions,
|
|
...sseOptions,
|
|
|
eventSourceInit: reconnectingEventSourceOptions,
|
|
eventSourceInit: reconnectingEventSourceOptions,
|
|
|
})
|
|
})
|
|
@@ -537,9 +540,9 @@ export class McpHub {
|
|
|
const connection: McpConnection = {
|
|
const connection: McpConnection = {
|
|
|
server: {
|
|
server: {
|
|
|
name,
|
|
name,
|
|
|
- config: JSON.stringify(config),
|
|
|
|
|
|
|
+ config: JSON.stringify(configInjected),
|
|
|
status: "connecting",
|
|
status: "connecting",
|
|
|
- disabled: config.disabled,
|
|
|
|
|
|
|
+ disabled: configInjected.disabled,
|
|
|
source,
|
|
source,
|
|
|
projectPath: source === "project" ? vscode.workspace.workspaceFolders?.[0]?.uri.fsPath : undefined,
|
|
projectPath: source === "project" ? vscode.workspace.workspaceFolders?.[0]?.uri.fsPath : undefined,
|
|
|
errorHistory: [],
|
|
errorHistory: [],
|