fix(fix-pin): preserve canonical raw command/args instead of dropping arguments#48
Merged
Conversation
… arguments
planPinFixes built the target edit from canonicalServer.command.split(' ')[0],
but `command` is the joined *display* string (command + args + url). When the
canonical config authored the launch as a single inline command string
("npx -y @modelcontextprotocol/server-github@1.2.3") with no separate `args`
array, the split copied only "npx" and silently dropped the package argument —
rewriting the target down to a broken launch line.
- Add McpServer.rawCommand: the verbatim `command` value as authored, before
args/url were joined for display. Set it in the MCP parser.
- planPinFixes now copies rawCommand + the verbatim args array, faithfully
reproducing the canonical raw shape. Skip planning for url-only servers that
have nothing launchable to copy.
- alignCommandAndArgs validates all edits before mutating (atomic per call, so
a partially-applicable fix can't half-rewrite a file) and refuses with a
clear message when the canonical folds args into the command string but the
target keeps a separate args array — applying that would yield a duplicated,
corrupt launch line.
Tests: inline-command canonical keeps its full command; shape-mismatch is
skipped with the file left byte-for-byte untouched.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
planPinFixesbuilt the target edit from:But
McpServer.commandis the joined display string (command+args+url), andargsis only populated when the parser saw a separateargsarray. So when a canonical config authors the launch as a single inline string:command.split(' ')[0]copied only"npx"andargswasundefined— the fix silently dropped the package argument and rewrote the target down to a brokennpx. A "helpful" fix that quietly lobotomizes the config.Fix
McpServer.rawCommand— the verbatimcommandvalue as authored, before args/url were joined for the display string. Populated in the MCP parser.planPinFixesnow copiesrawCommand+ the verbatimargsarray, faithfully reproducing the canonical raw shape (inline command string vs. bare command + separate args). Url-only servers (nothing launchable to copy) are skipped.alignCommandAndArgsnow validates all edits before mutating (atomic per call — a partially-applicable fix can no longer half-rewrite a file), and refuses with a clear message when the canonical folds args into the command string but the target keeps a separateargsarray. Applying that would yield a duplicated, corrupt launch (npx -y pkg@1.2.3 -y pkg@2.0.0), so we skip and tell the user to align manually.Tests
fix-pin-inline-command: canonical inline command string is preserved in full (package + flags intact), no strayargsintroduced, mismatch resolved on re-audit.fix-pin-shape-mismatch: skipped withApplied 0 edit(s), skipped 1and the target file left byte-for-byte untouched.All 120 tests pass;
dist/rebuilt and committed.🤖 Generated with Claude Code