feat(cli): wrap and unwrap the Claude Desktop config for one server - #213
Merged
kerlenton merged 3 commits intoAug 8, 2026
Merged
Conversation
Add `mcpsnoop wrap <server>` and `mcpsnoop unwrap <server>`, which edit Claude Desktop's claude_desktop_config.json so a named server starts through mcpsnoop, and put it back. Only the target server's byte range is rewritten. Decoding into a json.RawMessage returns the value's original bytes and InputOffset gives its exact span, so the user's indentation, key order, other servers and trailing newline all survive; a decode-and-re-encode of the whole file could not do that. wrap copies the config to <config>.mcpsnoop.bak before touching it, and unwrap restores those bytes verbatim when the rest of the file is still as wrap left it, so the round trip is byte for byte. When the config changed in the meantime, unwrap rewrites only the entry and keeps the backup, so an unrelated edit is never clobbered. Both directions are idempotent, --dry-run writes nothing, and a missing config, an unknown server, an unknown client and a non-stdio entry each report what to do next. Clients live in a registry that a file registers itself into from init, so a second client is a new file rather than an edit to wrap.go. Config path resolution goes through os.UserConfigDir, which already resolves to the three directories Claude Desktop uses, so there is no runtime.GOOS switch to get wrong. Fixes kerlenton#136
Owner
|
Thank you! |
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 #136.
Pointing Claude Desktop at the proxy meant hand-editing its config — easy to get wrong, awkward to undo. Adds
mcpsnoop wrap/unwrapfor one named server.internal/toolbaseline/baseline.go)unwraprestores the entry byte for byte--dry-runprints the change without writingScoped to Claude Desktop only, one config path per OS, as the issue asks. Client-specific details sit behind a small
wrapClientvalue so a second client would be a data change — but none is added here.Checklist
make checkpasses (gofmt, vet, staticcheck, race tests) — plus cross-compiled vet and build for windows and darwin