fix(scanner): resolve uvx source from ephemeral archive cache (MCP-2400)#664
Merged
Conversation
Deploying mcpproxy-docs with
|
| Latest commit: |
1e26701
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a26cecf5.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://mcp-2400-uvx-archive-cache.mcpproxy-docs.pages.dev |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
resolveUvxCache only checked the persistent `uv tool install` tools dir and git checkouts, so a server launched via plain `uvx <pkg>` — whose wheel is unpacked into the content-addressed ~/.cache/uv/archive-v0 cache, keyed by an opaque hash rather than package name — always missed and fell through to a tool-definitions-only scan. Add a third local-cache strategy that scans archive-v0 entries and matches the target distribution by its wheel .dist-info (robust to dist-name vs import-name differences), supporting both the flat and venv-style layouts and picking the newest entry when several versions are cached. Also strip PEP 508 version specifiers (==, >=, [extras]) from the spec before matching. The container resolver (findContainerTargetDir) already searched archive-v0; this brings the host resolver to parity. Complements the published-source fetch in #658 (MCP-2206) by resolving locally first, avoiding a network round-trip and working in air-gapped deployments. Related #658 Related MCP-2400
1f1feca to
1e26701
Compare
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
Fixes MCP-2400:
uvx-launched (PIP) MCP servers always fell back totool_definitions_only(0 source files scanned) because the host sourceresolver never looked in the right cache.
resolveUvxCacheonly checked:~/.cache/uv/git-v0/checkouts/…(git+URL packages), and~/.local/share/uv/tools/<pkg>(persistentuv tool install).But the common case — a plain
uvx <pkg>server — unpacks its publishedwheel into the content-addressed
~/.cache/uv/archive-v0/<hash>/cache,keyed by an opaque hash, not by package name. So even a server that had
been run locally missed both strategies and degraded to a definitions-only scan.
Fix
Add a third local-cache strategy to
resolveUvxCachethat:archive-v0/<hash>entry and matches the target distribution byits wheel
.dist-infodirectory (robust to dist-name vs import-namedifferences, e.g.
python-dotenv→dotenv);<hash>/<dist>-<ver>.dist-info) and venv-style(
<hash>/lib/python*/site-packages/…) layouts observed in real uv caches;resolveNpxCache);==,>=,[extras], …) before matching.The container resolver (
findContainerTargetDir) already searchedarchive-v0;this brings the host resolver to parity.
Relationship to #658 (MCP-2206)
This is the residual local-cache-resolve gap MCP-2400 was scoped down to.
PR #658 adds a published-source network fetch as the final fallback; this PR
makes the local cache path succeed first — avoiding a redundant network
round-trip and working in air-gapped deployments where the fetch is disabled.
The two are logically independent (#658 touches
Resolve/ResolveFullSourceand a new
package_fetch.go; this touches onlyresolveUvxCache), so theycompose cleanly regardless of merge order.
Tests (TDD)
internal/security/scanner/source_resolver_test.go— 5 new tests (alloffline/deterministic): flat layout, venv-style layout, name normalization +
version pin, newest-entry-wins, and clean fall-through on no match.
Verification
go test ./internal/security/scanner/ -race✅go build ./cmd/mcpproxy✅golangci-lint v2(CI config) ✅ 0 issuesDocs
docs/features/security-scanner-plugins.md— note that uvx resolution nowcovers the ephemeral
archive-v0cache.Related #658
Related MCP-2400