Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #84.
What this changes
server-configs.tsread withJSON.parseand wrote withJSON.stringify(next, null, 2). Two consequences:JSON.parsethrew on the first//, the file was skipped, and its servers stayed off the proxy — no message beyond them not appearing in the list. That is the worse half: it is a reachmcp wrapclaims to cover and silently does not.mcp wraptouched the whole file.Configs are now read with
jsonc-parser(comments and trailing commas allowed; a file that still will not parse is left exactly alone), and written by span through a newmcp/json-span.ts, using the indentation helperagents/managed-json.tsalready has. Only the wrapped entries' text changes.The part span editing alone does not get right
I measured before writing this.
jsonc-parserkeeps comments and indentation, but anargsarray written inline —"args": ["-y", "gh-mcp"]— comes back on five lines after a wrap and an unwrap. So span edits by themselves do not meet "unwrap stays byte-identical".unwrapdeliberately rebuilds each entry from the wrapped one, not from the backup, so it survives--purge. That stays. On top of it: beforewriteRelaunchesreplaces the backup, it reads it, and where the backup still holds an entry whose value equals the one being restored — compared withcanonicalJson, since key order is not part of the value — that entry's original text is spliced back in. Otherwise (after a purge, or if the entry changed) it falls back to the span edit, which is still correct and still touches only that entry's lines.How it was verified
In
mcp-command.test.ts, against two hand-written fixtures — one with comments, a trailing comma and an inline array, one in plain four-space JSON:Four fail on
main— including the plain-JSON reformatting and round trip, whichmaindoes parse and then rewrites. The existing round-trip test for a two-space file still passes.prettier,tscandknipclean. Full suite on Node 24: every failing file also fails onmainhere (the Noise pairing tests, which need the native addon; no Rust on this machine).Checklist
pnpm format && pnpm typecheck && pnpm test && pnpm deadcodeall pass (Noise tests aside)any, no magic values, noconsole.*outsidecli-output.tsmcp wrapnow writes JSONC files it used to skip, and writes less of each file; the changeset names both