diff --git a/packages/core/src/config/normalize.ts b/packages/core/src/config/normalize.ts index 4b0709adf27..af50de40729 100644 --- a/packages/core/src/config/normalize.ts +++ b/packages/core/src/config/normalize.ts @@ -257,6 +257,7 @@ function normalizeMcp(input: Record, encoded: Record, encoded: Record setOwn(nativeServers, key, server), - ) + Object.entries( + decodeMap(expandServerTimeouts(value), ConfigMCP.Server, path, diagnostics, decodeEncoded), + ).forEach(([key, server]) => setOwn(nativeServers, key, server)) return } if (name === "timeout" && !isDirectLegacyMcp(value)) { - normalizeMcpTimeout(value, timeout, path, diagnostics) + normalizeMcpTimeout( + typeof value === "number" ? ConfigMigrateV1.migrateMcpTimeout(value) : value, + timeout, + path, + diagnostics, + ) return } const server = decodeValue(ConfigMCPV1.Info, value, path, diagnostics) @@ -298,6 +304,19 @@ function normalizeMcp(input: Record, encoded: Record [ + name, + isRecord(server) && typeof server.timeout === "number" + ? { ...server, timeout: ConfigMigrateV1.migrateMcpTimeout(server.timeout) } + : server, + ]), + ) +} + function normalizeMcpTimeout( value: unknown, timeout: Record, diff --git a/packages/core/src/v1/config/migrate.ts b/packages/core/src/v1/config/migrate.ts index bcf4a6582b5..6c9eb2938d2 100644 --- a/packages/core/src/v1/config/migrate.ts +++ b/packages/core/src/v1/config/migrate.ts @@ -76,6 +76,11 @@ export function modelSelection(input?: string, variant?: string) { } } +// V1 had a single MCP timeout, so a bare number bounds every phase. +export function migrateMcpTimeout(timeout: number) { + return { startup: timeout, catalog: timeout, execution: timeout } +} + export function migrateMcp(info: ConfigMCPV1.Info) { const disabled = info.enabled === undefined ? undefined : !info.enabled if (info.type === "local") @@ -85,7 +90,7 @@ export function migrateMcp(info: ConfigMCPV1.Info) { cwd: info.cwd, environment: info.environment, disabled, - timeout: info.timeout === undefined ? undefined : { catalog: info.timeout, execution: info.timeout }, + timeout: info.timeout === undefined ? undefined : migrateMcpTimeout(info.timeout), } return { type: info.type, @@ -99,7 +104,7 @@ export function migrateMcp(info: ConfigMCPV1.Info) { redirect_uri: info.oauth.redirectUri, }, disabled, - timeout: info.timeout === undefined ? undefined : { catalog: info.timeout, execution: info.timeout }, + timeout: info.timeout === undefined ? undefined : migrateMcpTimeout(info.timeout), } } diff --git a/packages/core/test/config/config.test.ts b/packages/core/test/config/config.test.ts index 35c10ce46fa..680b47b74a2 100644 --- a/packages/core/test/config/config.test.ts +++ b/packages/core/test/config/config.test.ts @@ -1823,13 +1823,13 @@ describe("Config", () => { type: "local", command: ["node", "server.js"], disabled: true, - timeout: { catalog: 10000, execution: 10000 }, + timeout: { startup: 10000, catalog: 10000, execution: 10000 }, }, remote: { type: "remote", url: "https://mcp.example.com", oauth: { client_id: "client", callback_port: 19876 }, - timeout: { catalog: 20000, execution: 20000 }, + timeout: { startup: 20000, catalog: 20000, execution: 20000 }, }, }, }) diff --git a/packages/core/test/config/normalization.test.ts b/packages/core/test/config/normalization.test.ts index 3990f95bce1..b068cf49785 100644 --- a/packages/core/test/config/normalization.test.ts +++ b/packages/core/test/config/normalization.test.ts @@ -420,6 +420,35 @@ describe("ConfigNormalize", () => { ).toBe(true) }) + test("expands numeric MCP timeouts to every phase", () => { + const result = normalized({ + mcp: { + timeout: 4000, + servers: { + local: { type: "local", command: ["local"], timeout: 6000 }, + remote: { type: "remote", url: "https://remote.example.com", timeout: 8000 }, + structured: { type: "local", command: ["structured"], timeout: { catalog: 9000 } }, + invalid: { type: "local", command: ["invalid"], timeout: -1 }, + }, + }, + }) + expect(result.encoded.mcp).toEqual({ + timeout: { startup: 4000, catalog: 4000, execution: 4000 }, + servers: { + local: { type: "local", command: ["local"], timeout: { startup: 6000, catalog: 6000, execution: 6000 } }, + remote: { + type: "remote", + url: "https://remote.example.com", + timeout: { startup: 8000, catalog: 8000, execution: 8000 }, + }, + structured: { type: "local", command: ["structured"], timeout: { catalog: 9000 } }, + }, + }) + expect(result.diagnostics.map((item) => [item.kind, item.path])).toEqual([ + ["invalid", ["mcp", "servers", "invalid"]], + ]) + }) + test("uses raw MCP discriminators for reserved server names", () => { const result = normalized({ mcp: {