From ff34e7aeffb8eb972a7f12a5f7e504be58734b5c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 12 Oct 2026 04:20:48 +0000 Subject: [PATCH] fix(setup): drop non-boolean activation switches from retained entries A string such as enabled: "false" was kept and then accepted as the desired entry, so setup could report success while doctor rejected the registration. Those values are removed with the other managed switches. --- docs/installation.md | 7 ++--- .../ClientConfigurationDocument.ts | 8 ++++-- src/application/Setup.planning.test.ts | 4 +-- src/application/SetupPlan.ts | 4 +-- .../clientRegistrationFields.test.ts | 26 +++++++++++++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/docs/installation.md b/docs/installation.md index 59bacef47..55c922a7b 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -66,9 +66,10 @@ Other fields you added to that entry, such as OMP's `timeout` or Codex's client-specific keys. It removes remote-server keys such as `url`, `headers`, `oauth_resource`, and `tcp` that contradict the local command, and an entry-level `enabled: false` or (outside Grok Build) `disabled: true`, so the registration -is active. An existing entry without a `command` is a remote server and is -replaced whole. A legacy OpenCode entry moved into the native `mcp.servers` -table keeps only its environment. +is active. A non-boolean `enabled` or `disabled` value is removed too, because +registration status accepts only booleans. An existing entry without a +`command` is a remote server and is replaced whole. A legacy OpenCode entry +moved into the native `mcp.servers` table keeps only its environment. Setup and doctor report a malformed REA environment map or invalid runtime setting before setup writes files. Repair the named setting in the client configuration; setup does not silently discard the rest of the map. diff --git a/src/application/ClientConfigurationDocument.ts b/src/application/ClientConfigurationDocument.ts index e56c8af69..f3adc7835 100644 --- a/src/application/ClientConfigurationDocument.ts +++ b/src/application/ClientConfigurationDocument.ts @@ -1533,8 +1533,11 @@ const REGISTRATION_REMOTE_KEYS: Readonly> = { /** * Whether setup replaces or removes an existing entry key. Setup registers an * active server, so entry-level switches that turn it off are removed too. - * Grok Build's entry `disabled` is kept, matching registration status, which - * reads only Grok's root `disabled_mcp_servers` list. + * Non-boolean `enabled` or `disabled` values are removed as well: registration + * status requires booleans, and retaining a string would leave doctor invalid + * after setup reports success. Grok Build's boolean entry `disabled` is kept, + * matching registration status, which reads only Grok's root + * `disabled_mcp_servers` list. */ const registrationManagedKey = ( dialect: ClientRegistrationDialect, @@ -1543,6 +1546,7 @@ const registrationManagedKey = ( ): boolean => Object.hasOwn(REGISTRATION_LAUNCHER_KEYS, key) || Object.hasOwn(REGISTRATION_REMOTE_KEYS, key) || + ((key === "enabled" || key === "disabled") && typeof value !== "boolean") || (key === "enabled" && value === false) || (key === "disabled" && value === true && dialect !== "grok"); diff --git a/src/application/Setup.planning.test.ts b/src/application/Setup.planning.test.ts index 2571c9a41..cddaa2264 100644 --- a/src/application/Setup.planning.test.ts +++ b/src/application/Setup.planning.test.ts @@ -157,7 +157,7 @@ describe("setup workflow", () => { `startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`, ); expect(result.plannedActions[0]?.detail).toContain( - "remote-server keys and switches that turn the server off, which are removed", + "non-boolean enabled or disabled values, which are removed", ); expect(host.hopperInstalls).toBe(0); expect(host.configurations).toBe(0); @@ -214,7 +214,7 @@ describe("setup approval disclosure", () => { `startup_timeout_sec, which setup sets to ${String(MCP_STARTUP_POLICY.codexStartupTimeoutSeconds)}`, ); expect(result.plannedActions[0]?.detail).toContain( - "The entry disabled flag is kept.", + "A boolean entry disabled flag is kept.", ); }); diff --git a/src/application/SetupPlan.ts b/src/application/SetupPlan.ts index ea54745bc..6643c3bce 100644 --- a/src/application/SetupPlan.ts +++ b/src/application/SetupPlan.ts @@ -338,8 +338,8 @@ const localEntryDisclosure = (clientName: string): string => { : ""; const removed = clientName === "grok_build" - ? "remote-server keys and an enabled: false switch, which are removed. The entry disabled flag is kept." - : "remote-server keys and switches that turn the server off, which are removed."; + ? "remote-server keys, an enabled: false switch, and non-boolean enabled or disabled values, which are removed. A boolean entry disabled flag is kept." + : "remote-server keys, switches that turn the server off, and non-boolean enabled or disabled values, which are removed."; const exceptions = rewritten === "" ? removed : `${rewritten}and ${removed}`; return `On an existing local command entry, user fields are kept except ${exceptions} When that entry is remote, its other fields are replaced.`; }; diff --git a/tests/boundary/filesystem/clientRegistrationFields.test.ts b/tests/boundary/filesystem/clientRegistrationFields.test.ts index 97bb7c8e3..8dab99100 100644 --- a/tests/boundary/filesystem/clientRegistrationFields.test.ts +++ b/tests/boundary/filesystem/clientRegistrationFields.test.ts @@ -138,6 +138,32 @@ it("drops Codex oauth_resource from a local command entry", async () => { }); }); +it("drops malformed activation switches from a local command entry", async () => { + const root = await createTestTempDirectory("rea-registration-switches-"); + const configPath = join(root, "mcp.json"); + const client: SetupClient = { name: "cursor", format: "json", configPath }; + const existing = { + ...clientRegistrationEntry("json", ["rea-old", "mcp"], environment), + timeout: 600000, + enabled: "false", + disabled: "true", + }; + await writeFile( + configPath, + serializeClientConfiguration(configurationWith("json", existing), "json"), + ); + expect(await configureClientConfiguration(client, {}, command)).toMatchObject( + { status: "configured" }, + ); + expect( + parseClientConfiguration(await readFile(configPath, "utf8"), "json").servers + .rea, + ).toEqual({ + ...clientRegistrationEntry("json", command, environment), + timeout: 600000, + }); +}); + it("drops a Qwen tcp endpoint from a local command entry", async () => { const root = await createTestTempDirectory("rea-registration-tcp-"); const configPath = join(root, "settings.json");