Skip to content

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
perplexityai:mainfrom
PratikDhanaveFork:fix/uvx-pipx-value-taking-flags
Open

PratikDhanave wants to merge 1 commit into
perplexityai:mainfrom
PratikDhanaveFork:fix/uvx-pipx-value-taking-flags

Conversation

@PratikDhanave

Copy link
Copy Markdown

Summary

The uvx, uv tool run, and pipx run launcher branches in internal/ecosystem/mcp/mcp.go misidentify 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:

command inferred (wrong) correct
uvx --with markitdown mcp-server-markitdown markitdown mcp-server-markitdown
uvx --python 3.11 mcp-server-time 3.11 mcp-server-time
uv tool run --python 3.11 mcp-server-time 3.11 mcp-server-time
pipx run --python 3.11 mcp-server-time 3.11 mcp-server-time

uvx --with <extra> <server> and uvx --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 via npmValueTakingFlags.

Fix

Add uvValueTakingFlags (mirroring npmValueTakingFlags) 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/--spec are already handled explicitly at the call sites and intentionally omitted.)

Testing

Added TestInferPackageFromArgs_UvValueTakingFlags (the four rows above).

  • Before: all four return the flag value (test fails).
  • After: all return the package. Full go test ./internal/ecosystem/mcp/ passes; go build + gofmt clean.

…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.
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.

1 participant