fix(detection): follow local imports in MCP source retrieval - #114
Open
shengqi-gensee wants to merge 4 commits into
Open
fix(detection): follow local imports in MCP source retrieval#114shengqi-gensee wants to merge 4 commits into
shengqi-gensee wants to merge 4 commits into
Conversation
barisozbas
requested changes
Sep 11, 2026
barisozbas
left a comment
Collaborator
There was a problem hiding this comment.
Hi, Please see the below findings.
-
High — source_bundle_complete
)
(
incorrectly remains true when the 24-file limit omits queued dependencies. I reproduced 25 files returning only 24
while reporting complete. Exact size-boundary exhaustion has the same problem. -
Medium — The collector
)
(
reads entire files before applying the limit and counts characters, not bytes. A 100,002-character source produced
400,002 UTF-8 bytes despite the 240,000 budget. -
Medium — A valid non-UTF-8 Python dependency raises UnicodeDecodeError, causing the entire server response—including ts entrypoint—to become status: error.
Contributor
Author
|
Thanks for the review—all three findings were valid and are now fixed:
Added regression coverage for these cases and truncation boundaries. All 145 tests pass. Ready for re-review. |
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.
Related issue:
Relates to #50
What changed?
get_source_codenow returns a bounded, dependency-aware source bundle forregistered Python MCP servers instead of exposing only the registered
entrypoint.
The implementation:
importandfrom ... import ...statements;precedence;
source_codeentrypoint field and MCP input schema.The additional source is returned through
source_files, withsource_bundle_completeindicating whether the bounded bundle was truncated.No detector prompts, routing rules, model configuration, or verdict semantics
are changed.
How did you test it?
Deterministic tests cover:
from package import submodule;Local results:
We also ran an isolated three-repeat ADR-Bench development comparison with
stock Tier 1 and Tier 2 behavior. The only changed variable was entrypoint-only
versus import-following source context. A second control removed comments and
docstrings while retaining executable code.
task_008was consistently recovered by import-following retrieval in allthree raw-source and all three comments/docstrings-stripped repeats. The
entrypoint-only arm classified it as benign in all six corresponding runs.
The imported implementation exposed executable behavior in
function/ai_insights.pyandfunction/system_analyzer.py, including encodedsession-token handling, decoding, endpoint modification, and silent
exfiltration. The result persisted after comments and docstrings were removed,
indicating that the recovery came from executable implementation behavior
rather than vulnerability-describing prose.