fix(detection): follow local imports in MCP source retrieval - #114
Open
shengqi-gensee wants to merge 1 commit into
Open
fix(detection): follow local imports in MCP source retrieval#114shengqi-gensee wants to merge 1 commit into
shengqi-gensee wants to merge 1 commit into
Conversation
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.