Skip to content

feat: add MCP server mode (--mcp)#7

Open
algorni wants to merge 3 commits intomainfrom
feat/mcp-server
Open

feat: add MCP server mode (--mcp)#7
algorni wants to merge 3 commits intomainfrom
feat/mcp-server

Conversation

@algorni
Copy link

@algorni algorni commented Feb 23, 2026

Summary

  • Add MCP (Model Context Protocol) server mode via analyzer --mcp, enabling AI assistants (Claude, etc.) to use all Analyzer operations as structured tools over stdio JSON-RPC
  • New src/mcp.rs with 20 tools: object management, scan creation/status/score, paginated analysis results browsing, compliance checks, SBOM/report downloads, and configuration
  • Add rmcp and schemars dependencies, bump version to 0.2.1
  • Update README with MCP Server mode documentation and Claude Code configuration examples

MCP Tools

Objects: list_objects, create_object, delete_object
Scans: create_scan, get_scan_status, get_scan_score, get_scan_types, get_scan_overview, cancel_scan, delete_scan
Results: get_analysis_results (paginated, with search), get_compliance
Downloads: download_sbom, download_report, download_compliance_report
Config: configure_profile, config_get, config_set, whoami

Test plan

  • cargo build --release compiles successfully
  • analyzer --help shows --mcp flag
  • analyzer --mcp starts MCP server on stdio (verify with MCP inspector)
  • CLI commands still work as before (no regressions)
  • Configure in Claude Code and test tools interactively

Base automatically changed from feat/analysis-results to main February 25, 2026 14:47
Alberto Gorni and others added 2 commits March 6, 2026 09:49
Add Model Context Protocol (MCP) server that exposes all Analyzer CLI
operations as structured tools over stdio JSON-RPC. This enables AI
assistants like Claude to manage objects, create scans, browse paginated
analysis results, check compliance, download reports/SBOMs, and more.

- New src/mcp.rs with 20 MCP tools (objects, scans, results, config)
- Add --mcp flag to main CLI, route to MCP server before subcommands
- Add rmcp and schemars dependencies
- Update README with MCP Server mode docs and Claude Code config
- Bump version to 0.2.1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…g 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.
@giovannialberto giovannialberto requested a review from krsh March 6, 2026 09:32
@giovannialberto
Copy link
Member

I cleaned up a few things here and there and changed some things to make sure that it's maintainable and aligned with our future plans. It's all tested and good to go for me. Adding @krsh as final reviewer.

humantime = "2"
bytes = "1"
clap_complete = "4"
rmcp = { version = "0.12", features = ["server", "macros", "transport-io"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to the latest version (1.2.0)

capabilities, info, symbols (IDF), tasks (IDF), stack-overflow (IDF).\n\
\n\
## Exein Rating (Security Score)\n\
0-100 where **lower is better** (0 = no issues, 100 = worst). \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/output.rs (format_score), scores >= 80 are colored green and < 50 red. This visually implies to human users that HIGHER IS BETTER.

Invert the color logic (.green(), .yellow(), .red()) in src/output.rs and src/commands/scan.rs

bytes = "1"
clap_complete = "4"
rmcp = { version = "0.12", features = ["server", "macros", "transport-io"] }
schemars = "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By enabling the uuid1 feature for schemars, we can directly use Option<Uuid> instead of Option<String> in the structs within src/mcp.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants