Skip to content

Conversation

ashleyhindle
Copy link
Collaborator

@ashleyhindle ashleyhindle commented Aug 27, 2025

Adds FileWriter class that 'intelligently' handles plain JSON files, and JSON5 style files which VS Code supports.

  • Detects & preserves JSON 5 features (comments, trailing commas)
  • 'Smart' injects based on existing keys and indents

Fixes #107

--

We keep the basic json_decode -> data_set -> json_encode -> write process for 'plain' JSON files, and only fallback to complex injection when we detect a JSON5 style file. This allows people to keep their comments in mcp.json and we won't overwrite them, they'll stay retained, and we'll inject our config at the exact right place.

Adds FileWriter class that 'intelligently' handles plain JSON files, and JSON5 style files which VS Code supports.

- Detects & preserves JSON 5 features (comments, trailing commas)
- 'Smart' injects based on existing keys and indents
@ashleyhindle ashleyhindle marked this pull request as ready for review August 27, 2025 08:46
Copy link
Member

@pushpak1300 pushpak1300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good. 👍🏻
what do you think about this changes ?

@ashleyhindle ashleyhindle merged commit 2415160 into main Aug 28, 2025
10 checks passed
@ashleyhindle ashleyhindle deleted the dont-overwrite-invalid-json branch August 28, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Existing server configuration overwritten in mcp.json
2 participants