agentshield/adapter/mcp/
mod.rs1pub(crate) mod binding;
2pub(crate) mod dependencies;
3pub(crate) mod filter;
4pub(crate) mod loader;
5pub(crate) mod provenance;
6pub(crate) mod tools;
7
8#[cfg(test)]
9mod tests;
10
11use std::path::Path;
12
13use crate::analysis::AnalysisBundle;
14use crate::config::ScanPathFilter;
15use crate::error::Result;
16use crate::ir::*;
17
18pub use dependencies::parse_dependencies;
19pub use filter::is_test_file;
20pub use provenance::parse_provenance;
21pub use tools::extract_mcp_tools_from_source;
22
23pub(crate) use loader::{
24 collect_source_files_with_filter, has_recursive_python_import, load_mcp_analysis,
25 load_mcp_target,
26};
27
28#[cfg(test)]
29use binding::bind_mcp_tool_operations;
30#[cfg(test)]
31use tools::{
32 McpToolHandler, extract_mcp_tool_declarations_from_source, parse_mcp_tool_handler,
33};
34
35pub struct McpAdapter;
42
43impl super::Adapter for McpAdapter {
44 fn framework(&self) -> Framework {
45 Framework::Mcp
46 }
47
48 fn detect(&self, root: &Path) -> bool {
49 super::mcp_metadata::metadata_root_for_scan(root).is_some()
50 }
51
52 fn load(&self, root: &Path, ignore_tests: bool) -> Result<Vec<ScanTarget>> {
53 let filter = ScanPathFilter::for_ignore_tests(ignore_tests);
54 self.load_with_filter(root, &filter)
55 }
56
57 fn load_with_filter(&self, root: &Path, filter: &ScanPathFilter) -> Result<Vec<ScanTarget>> {
58 load_mcp_target(root, filter).map(|(target, _)| vec![target])
59 }
60}
61
62impl super::AnalysisAdapter for McpAdapter {
63 fn framework(&self) -> Framework {
64 Framework::Mcp
65 }
66
67 fn detect(&self, root: &Path) -> bool {
68 super::mcp_metadata::metadata_root_for_scan(root).is_some()
69 }
70
71 fn load_analysis_with_filter(
72 &self,
73 root: &Path,
74 filter: &ScanPathFilter,
75 ) -> Result<Vec<AnalysisBundle>> {
76 load_mcp_analysis(root, filter)
77 }
78}
79
80pub(crate) struct McpAnalysisAdapter;
81
82impl super::AnalysisAdapter for McpAnalysisAdapter {
83 fn framework(&self) -> Framework {
84 Framework::Mcp
85 }
86
87 fn detect(&self, root: &Path) -> bool {
88 super::mcp_metadata::metadata_root_for_scan(root).is_some()
89 }
90
91 fn load_analysis_with_filter(
92 &self,
93 root: &Path,
94 filter: &ScanPathFilter,
95 ) -> Result<Vec<AnalysisBundle>> {
96 load_mcp_analysis(root, filter)
97 }
98}