Repository navigation
fix(mcp): don't misread a value-taking uv/pipx flag's value as the package spec - #92
Open
PratikDhanave wants to merge 1 commit into
Open
PratikDhanave wants to merge 1 commit into
PratikDhanave wants to merge 1 commit into
Conversation
…ckage The uvx, `uv tool run`, and `pipx run` branches called firstNonFlag with a nil value-taking-flag set, so a flag that consumes a separate argument (--python 3.11, --with <pkg>, --index-url <url>) had its value returned as the package identity — e.g. `uvx --with markitdown mcp-server-markitdown` inferred "markitdown". The npm-family branches already guard this with npmValueTakingFlags. Add uvValueTakingFlags and pass it at the three call sites. Add a regression test.
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.
Summary
The
uvx,uv tool run, andpipx runlauncher branches ininternal/ecosystem/mcp/mcp.gomisidentify the scanned package when a value-taking flag precedes it.Root cause
Those three branches call
firstNonFlag(args, skip, nil)with a nil value-taking-flag set, so a flag that consumes a separate argument has its value returned as the package identity:uvx --with markitdown mcp-server-markitdownmarkitdownmcp-server-markitdownuvx --python 3.11 mcp-server-time3.11mcp-server-timeuv tool run --python 3.11 mcp-server-time3.11mcp-server-timepipx run --python 3.11 mcp-server-time3.11mcp-server-timeuvx --with <extra> <server>anduvx --python <ver> <server>are common MCP configs. The scanner emits a bogus package record (e.g.package_name="3.11") and misses the real one, breaking exposure matching; with--index-url https://token@host/... <pkg>it would also fold a credential-bearing URL into the package spec — the exact leak the npm branch already guards against vianpmValueTakingFlags.Fix
Add
uvValueTakingFlags(mirroringnpmValueTakingFlags) covering--python/-p,--with/--with-requirements/--with-editable,--index/--index-url/--extra-index-url/--default-index,--find-links/-f,--constraint/-c,--override,--pip-args, and pass it at the three call sites. (--from/--specare already handled explicitly at the call sites and intentionally omitted.)Testing
Added
TestInferPackageFromArgs_UvValueTakingFlags(the four rows above).go test ./internal/ecosystem/mcp/passes;go build+gofmtclean.