Skip to content

Commit 6858078

Browse files
refactor: deduplicate MCP server, add object_id support, remove config tools
- Extract shared AnalysisType::from_api_name() and ComplianceType::from_name() so MCP reuses enum parsing instead of duplicating match arms - Make resolve_analysis_id public, reuse from MCP instead of reimplementing - All scan tools now accept object_id as alternative to scan_id, matching the CLI's --object flag and aligning with ELI's natural interaction model - Remove configure_profile/config_get/config_set (config mutation is out of scope for AI agents); keep whoami for diagnostics - Add [Read]/[Write]/[Critical] classification to tool descriptions, preparing for ELI's Permission Gate - Fix &PathBuf -> &Path (Clippy), trim instructions block Net -145 lines from mcp.rs.
1 parent f64fed7 commit 6858078

3 files changed

Lines changed: 153 additions & 298 deletions

File tree

src/client/models.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,14 @@ impl ComplianceType {
605605
Self::Cra => "Cyber Resilience Act",
606606
}
607607
}
608+
609+
/// Parse from a user-provided string (e.g. "cra").
610+
pub fn from_name(name: &str) -> Option<Self> {
611+
match name.to_lowercase().as_str() {
612+
"cra" => Some(Self::Cra),
613+
_ => None,
614+
}
615+
}
608616
}
609617

610618
// === Analysis Type enum (for CLI) ===
@@ -644,6 +652,25 @@ impl AnalysisType {
644652
}
645653
}
646654

655+
/// Parse from the API name string (e.g. "cve", "software-bom").
656+
pub fn from_api_name(name: &str) -> Option<Self> {
657+
match name {
658+
"cve" => Some(Self::Cve),
659+
"password-hash" => Some(Self::PasswordHash),
660+
"malware" => Some(Self::Malware),
661+
"hardening" => Some(Self::Hardening),
662+
"capabilities" => Some(Self::Capabilities),
663+
"crypto" => Some(Self::Crypto),
664+
"software-bom" => Some(Self::SoftwareBom),
665+
"kernel" => Some(Self::Kernel),
666+
"info" => Some(Self::Info),
667+
"symbols" => Some(Self::Symbols),
668+
"tasks" => Some(Self::Tasks),
669+
"stack-overflow" => Some(Self::StackOverflow),
670+
_ => None,
671+
}
672+
}
673+
647674
/// Default sort-by field for this analysis type.
648675
pub fn default_sort_by(&self) -> &'static str {
649676
match self {

src/commands/scan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub async fn run_overview(client: &AnalyzerClient, scan_id: Uuid, format: Format
474474
// ===========================================================================
475475

476476
/// Resolve an analysis type name to its UUID by fetching the scan metadata.
477-
async fn resolve_analysis_id(
477+
pub async fn resolve_analysis_id(
478478
client: &AnalyzerClient,
479479
scan_id: Uuid,
480480
analysis_type: &AnalysisType,

0 commit comments

Comments
 (0)