[PR #5045] [CLOSED] fix(setup): admit only strict JSON for Claude Desktop configuration #6757

Closed
opened 2026-11-01 21:42:50 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5045
Author: @cpruijsen
Created: 10/18/2026
Status: ❌ Closed

Base: main ← Head: fix/desktop-strict-json-config


📝 Commits (3)

  • 01ff9b8 fix(setup): admit only strict JSON for Claude Desktop configuration
  • 9aecad6 test(setup): place the Claude Desktop fixture under AppData on Windows
  • 8802ccc test(setup): write the BOM prefix as an escape

📊 Changes

3 files changed (+67 additions, -45 deletions)

View changed files

📝 src/application/ClientConfigurationDocument.ts (+3 -2)
📝 src/application/SupportedClients.ts (+1 -1)
📝 tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts (+63 -42)

📄 Description

Summary

Claude Desktop reads claude_desktop_config.json with a strict JSON.parse after removing a UTF-8 BOM. REA still parsed that file as JSONC. When the file had a comment or a trailing comma, setup reported ready and wrote into it, and doctor reported the registration aligned. Claude Desktop then cannot parse the file, so it loads no MCP servers from it at all, not only rea.

This applies the strict format that #4944 added for Claude Code to Claude Desktop as well.

Problem and expected behavior

Smallest trigger, on macOS or Linux:

{
  // any comment
  "mcpServers": { "peer": { "command": "/usr/bin/true", "args": [] } }
}

rea setup --client claude_desktop --yes on base: status: "ready", the file is rewritten, and rea doctor --client claude_desktop reports aligned. Expected: setup refuses the file as malformed before any backup or write, and doctor reports invalid, which is what already happens for Claude Code.

Change and scope

  • SupportedClients.ts: claude_desktop uses format: "claude_code" (the strict JSON format) instead of json.
  • ClientConfigurationDocument.ts: the comment on that branch names both clients.
  • No other code branches on the claude_code format, so admission is the only behavior that changes: the server key, registration entry shape, and serialization fall through to the same defaults the json format used. Empty-file handling is unchanged (the empty check runs before the strict branch). Plain and BOM-prefixed JSON still configure.

What I chose and the alternative: I reused the existing claude_code format rather than renaming it to a client-neutral strict_json or adding a separate claude_desktop branch. A rename would churn the format union, generated metadata, and the tests #4944 just added for zero behavior change; a second branch would duplicate one parse call. If a third strict-JSON client appears, renaming the format then is a one-commit cleanup.

Not included: other clients that share the json format. I did not check each of their native readers.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Scope decision: not applicable. This is an ordinary fix inside the existing setup boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: client configuration parsing (parseDocument in ClientConfigurationDocument.ts), before planning.
  • Contribution scope fit and linked maintainer decision: not applicable (ordinary fix, follows #4944).
  • CLI and MCP/tool-catalog contract: setup's clientStates[].client.format for Claude Desktop changes from "json" to "claude_code". Setup and uninstall for Claude Desktop now return needs_human / failed with a malformed remediation for JSONC input, the same as Claude Code. No tool catalog changes.
  • Provider, bridge, target-format, or platform compatibility: Claude Desktop on macOS, Linux and Windows (one shared client definition).
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): setup_clients[].format for claude_desktop in the generated product catalog becomes "claude_code" (regenerated output, not committed). npm run docs:check passes. No package or installation impact.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration. (Setup now refuses a write it used to make.)
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts now runs each case for both claude_code and claude_desktop. The registration assertions use arrayContaining, because doctor --client claude_desktop also lists a claude_code entry (its marker directory is the test home).

  • Base reproduction or other evidence: with the source change reverted, the two Claude Desktop "refuse JSON with a comment / trailing comma" cases fail and the other 6 pass. With the change, 8 of 8 pass.

  • Claude Desktop reader (source-derived, Claude Desktop 2.42304.0 on macOS, from app.asar): the config loader parses the file with JSON.parse(text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text) and shows "Couldn't load app settings ... error reading or parsing claude_desktop_config.json" on failure, loading no servers.

  • User-visible CLI/MCP output (if applicable): rea setup --client claude_desktop --yes --format json at this head, with a throwaway HOME whose claude_desktop_config.json holds the commented file above (exit 1, the file is byte-for-byte unchanged and no .rea.backup is written):

    {
      "status": "needs_human",
      "plannedActions": [],
      "appliedActions": [],
      "remediation": "Claude Desktop: Configuration <home>/Library/Application Support/Claude/claude_desktop_config.json is malformed: Expected property name or '}' in JSON at position 4 (line 2 column 3)"
    }
    

    (doctor and clientStates omitted; <home> stands for the throwaway directory.)

  • Native Claude Desktop 3.6556.2 on macOS (executed, 2026-10-24): with the commented file above plus a test server, Claude Desktop logged Error reading or parsing config file (SyntaxError), showed "Couldn't load app settings ... Expected property name or '}' in JSON at position 4 (line 2 column 3)", and did not start the test server. With the same server in plain JSON, it started the server. So a commented file costs the user every MCP server in it, which is the case setup now refuses.

  • Remaining proof gaps: none known.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts: 8 passed. With the src/ change reverted in an isolated worktree: 2 failed, 6 passed (expected). Also passed under Node 24.21.0.
  • npm run test:focused -- on claudeDesktopClientConfiguration, clientLifecycle, setupConfig, clientConfigurationBom, windowsNpxRegistration (boundary), ClaudeDesktopConfigLocation.test.ts and Setup.configuration.test.ts: 7 files, 160 passed, 2 skipped.
  • npm run check:fast: passed.
  • npm run docs:check: passed.
  • npm run verify:test-discovery: passed.
  • Platform: macOS (arm64), Node 26; focused suite re-run on Node 24.21.0 (.nvmrc pins the 24 line).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. A Claude Desktop file that has comments or trailing commas was already unreadable by Claude Desktop. Setup now asks the user to fix it instead of writing into it.
  • Real Hopper/Ghidra, browser, or OS coverage: native Claude Desktop 3.6556.2 on macOS arm64, as above.
  • Package or release metadata impact: the generated product catalog format value for claude_desktop changes (regenerated, not committed).
  • Security, privacy, process, or containment review: none. The change only refuses a write.

Author readiness

Human owner: @cpruijsen

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above. (No issue exists; this follows #4944.)
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5045 **Author:** [@cpruijsen](https://github.com/cpruijsen) **Created:** 10/18/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/desktop-strict-json-config` --- ### 📝 Commits (3) - [`01ff9b8`](https://github.com/morluto/rea/commit/01ff9b8506d7cef65b837e0036633a7e2884a28f) fix(setup): admit only strict JSON for Claude Desktop configuration - [`9aecad6`](https://github.com/morluto/rea/commit/9aecad6294073151aa7aa68fc2140a6718b6e8e8) test(setup): place the Claude Desktop fixture under AppData on Windows - [`8802ccc`](https://github.com/morluto/rea/commit/8802cccc8f06b9d93aae5b6028c43de6c472862a) test(setup): write the BOM prefix as an escape ### 📊 Changes **3 files changed** (+67 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `src/application/ClientConfigurationDocument.ts` (+3 -2) 📝 `src/application/SupportedClients.ts` (+1 -1) 📝 `tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts` (+63 -42) </details> ### 📄 Description ## Summary Claude Desktop reads `claude_desktop_config.json` with a strict `JSON.parse` after removing a UTF-8 BOM. REA still parsed that file as JSONC. When the file had a comment or a trailing comma, setup reported `ready` and wrote into it, and doctor reported the registration `aligned`. Claude Desktop then cannot parse the file, so it loads no MCP servers from it at all, not only rea. This applies the strict format that #4944 added for Claude Code to Claude Desktop as well. ## Problem and expected behavior Smallest trigger, on macOS or Linux: ```jsonc { // any comment "mcpServers": { "peer": { "command": "/usr/bin/true", "args": [] } } } ``` `rea setup --client claude_desktop --yes` on base: `status: "ready"`, the file is rewritten, and `rea doctor --client claude_desktop` reports `aligned`. Expected: setup refuses the file as malformed before any backup or write, and doctor reports `invalid`, which is what already happens for Claude Code. ## Change and scope - `SupportedClients.ts`: `claude_desktop` uses `format: "claude_code"` (the strict JSON format) instead of `json`. - `ClientConfigurationDocument.ts`: the comment on that branch names both clients. - No other code branches on the `claude_code` format, so admission is the only behavior that changes: the server key, registration entry shape, and serialization fall through to the same defaults the `json` format used. Empty-file handling is unchanged (the empty check runs before the strict branch). Plain and BOM-prefixed JSON still configure. What I chose and the alternative: I reused the existing `claude_code` format rather than renaming it to a client-neutral `strict_json` or adding a separate `claude_desktop` branch. A rename would churn the format union, generated metadata, and the tests #4944 just added for zero behavior change; a second branch would duplicate one parse call. If a third strict-JSON client appears, renaming the format then is a one-commit cleanup. Not included: other clients that share the `json` format. I did not check each of their native readers. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. Scope decision: not applicable. This is an ordinary fix inside the existing setup boundary. ## Contract and boundary impact - Semantic owner and earliest changed stage: client configuration parsing (`parseDocument` in `ClientConfigurationDocument.ts`), before planning. - Contribution scope fit and linked maintainer decision: not applicable (ordinary fix, follows #4944). - CLI and MCP/tool-catalog contract: setup's `clientStates[].client.format` for Claude Desktop changes from `"json"` to `"claude_code"`. Setup and uninstall for Claude Desktop now return `needs_human` / `failed` with a `malformed` remediation for JSONC input, the same as Claude Code. No tool catalog changes. - Provider, bridge, target-format, or platform compatibility: Claude Desktop on macOS, Linux and Windows (one shared client definition). - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): `setup_clients[].format` for `claude_desktop` in the generated product catalog becomes `"claude_code"` (regenerated output, not committed). `npm run docs:check` passes. No package or installation impact. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [x] Change process memory, registers, files, or configuration. (Setup now refuses a write it used to make.) - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts` now runs each case for both `claude_code` and `claude_desktop`. The registration assertions use `arrayContaining`, because `doctor --client claude_desktop` also lists a `claude_code` entry (its marker directory is the test home). - Base reproduction or other evidence: with the source change reverted, the two Claude Desktop "refuse JSON with a comment / trailing comma" cases fail and the other 6 pass. With the change, 8 of 8 pass. - Claude Desktop reader (source-derived, Claude Desktop 2.42304.0 on macOS, from `app.asar`): the config loader parses the file with `JSON.parse(text.charCodeAt(0) === 0xFEFF ? text.slice(1) : text)` and shows "Couldn't load app settings ... error reading or parsing claude_desktop_config.json" on failure, loading no servers. - User-visible CLI/MCP output (if applicable): `rea setup --client claude_desktop --yes --format json` at this head, with a throwaway `HOME` whose `claude_desktop_config.json` holds the commented file above (exit 1, the file is byte-for-byte unchanged and no `.rea.backup` is written): ```json { "status": "needs_human", "plannedActions": [], "appliedActions": [], "remediation": "Claude Desktop: Configuration <home>/Library/Application Support/Claude/claude_desktop_config.json is malformed: Expected property name or '}' in JSON at position 4 (line 2 column 3)" } ``` (`doctor` and `clientStates` omitted; `<home>` stands for the throwaway directory.) - Native Claude Desktop 3.6556.2 on macOS (executed, 2026-10-24): with the commented file above plus a test server, Claude Desktop logged `Error reading or parsing config file (SyntaxError)`, showed "Couldn't load app settings ... Expected property name or '}' in JSON at position 4 (line 2 column 3)", and did not start the test server. With the same server in plain JSON, it started the server. So a commented file costs the user every MCP server in it, which is the case setup now refuses. - Remaining proof gaps: none known. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:focused -- tests/acceptance/setup/claudeCodeStrictJsonSetup.test.ts`: 8 passed. With the `src/` change reverted in an isolated worktree: 2 failed, 6 passed (expected). Also passed under Node 24.21.0. - `npm run test:focused --` on `claudeDesktopClientConfiguration`, `clientLifecycle`, `setupConfig`, `clientConfigurationBom`, `windowsNpxRegistration` (boundary), `ClaudeDesktopConfigLocation.test.ts` and `Setup.configuration.test.ts`: 7 files, 160 passed, 2 skipped. - `npm run check:fast`: passed. - `npm run docs:check`: passed. - `npm run verify:test-discovery`: passed. - Platform: macOS (arm64), Node 26; focused suite re-run on Node 24.21.0 (`.nvmrc` pins the 24 line). ## Compatibility, safety, and release - Breaking changes or migration steps: none. A Claude Desktop file that has comments or trailing commas was already unreadable by Claude Desktop. Setup now asks the user to fix it instead of writing into it. - Real Hopper/Ghidra, browser, or OS coverage: native Claude Desktop 3.6556.2 on macOS arm64, as above. - Package or release metadata impact: the generated product catalog format value for `claude_desktop` changes (regenerated, not committed). - Security, privacy, process, or containment review: none. The change only refuses a write. ## Author readiness Human owner: @cpruijsen - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. (No issue exists; this follows #4944.) - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:42:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6757
No description provided.