Some checks failed
CI / Format (push) Successful in 3s
CI / Clippy (push) Successful in 4m4s
CI / Security Audit (push) Successful in 1m42s
CI / Tests (push) Successful in 4m38s
CI / Deploy Agent (push) Successful in 2s
CI / Deploy Dashboard (push) Successful in 1s
CI / Deploy MCP (push) Failing after 2s
CI / Detect Changes (push) Successful in 7s
CI / Deploy Docs (push) Successful in 2s
New `compliance-mcp` crate providing a Model Context Protocol server with 7 tools: list/get/summarize findings, list SBOM packages, SBOM vulnerability report, list DAST findings, and DAST scan summary. Supports stdio (local dev) and Streamable HTTP (deployment via MCP_PORT). Includes Dockerfile, CI clippy check, and Coolify deploy job. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Sharang Parnerkar <parnerkarsharang@gmail.com> Reviewed-on: #5
110 lines
3.9 KiB
Rust
110 lines
3.9 KiB
Rust
use rmcp::{
|
|
handler::server::wrapper::Parameters, model::*, tool, tool_handler, tool_router, ServerHandler,
|
|
};
|
|
|
|
use crate::database::Database;
|
|
use crate::tools::{dast, findings, sbom};
|
|
|
|
pub struct ComplianceMcpServer {
|
|
db: Database,
|
|
#[allow(dead_code)]
|
|
tool_router: rmcp::handler::server::router::tool::ToolRouter<Self>,
|
|
}
|
|
|
|
#[tool_router]
|
|
impl ComplianceMcpServer {
|
|
pub fn new(db: Database) -> Self {
|
|
Self {
|
|
db,
|
|
tool_router: Self::tool_router(),
|
|
}
|
|
}
|
|
|
|
// ── Findings ──────────────────────────────────────────
|
|
|
|
#[tool(
|
|
description = "List security findings with optional filters for repo, severity, status, and scan type"
|
|
)]
|
|
async fn list_findings(
|
|
&self,
|
|
Parameters(params): Parameters<findings::ListFindingsParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
findings::list_findings(&self.db, params).await
|
|
}
|
|
|
|
#[tool(description = "Get a single finding by its ID")]
|
|
async fn get_finding(
|
|
&self,
|
|
Parameters(params): Parameters<findings::GetFindingParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
findings::get_finding(&self.db, params).await
|
|
}
|
|
|
|
#[tool(description = "Get a summary of findings counts grouped by severity and status")]
|
|
async fn findings_summary(
|
|
&self,
|
|
Parameters(params): Parameters<findings::FindingsSummaryParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
findings::findings_summary(&self.db, params).await
|
|
}
|
|
|
|
// ── SBOM ──────────────────────────────────────────────
|
|
|
|
#[tool(
|
|
description = "List SBOM packages with optional filters for repo, vulnerabilities, package manager, and license"
|
|
)]
|
|
async fn list_sbom_packages(
|
|
&self,
|
|
Parameters(params): Parameters<sbom::ListSbomPackagesParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
sbom::list_sbom_packages(&self.db, params).await
|
|
}
|
|
|
|
#[tool(
|
|
description = "Generate a vulnerability report for a repository showing all packages with known CVEs"
|
|
)]
|
|
async fn sbom_vuln_report(
|
|
&self,
|
|
Parameters(params): Parameters<sbom::SbomVulnReportParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
sbom::sbom_vuln_report(&self.db, params).await
|
|
}
|
|
|
|
// ── DAST ──────────────────────────────────────────────
|
|
|
|
#[tool(
|
|
description = "List DAST findings with optional filters for target, scan run, severity, exploitability, and vulnerability type"
|
|
)]
|
|
async fn list_dast_findings(
|
|
&self,
|
|
Parameters(params): Parameters<dast::ListDastFindingsParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
dast::list_dast_findings(&self.db, params).await
|
|
}
|
|
|
|
#[tool(description = "Get a summary of recent DAST scan runs and finding counts")]
|
|
async fn dast_scan_summary(
|
|
&self,
|
|
Parameters(params): Parameters<dast::DastScanSummaryParams>,
|
|
) -> Result<CallToolResult, rmcp::ErrorData> {
|
|
dast::dast_scan_summary(&self.db, params).await
|
|
}
|
|
}
|
|
|
|
#[tool_handler]
|
|
impl ServerHandler for ComplianceMcpServer {
|
|
fn get_info(&self) -> ServerInfo {
|
|
ServerInfo {
|
|
protocol_version: ProtocolVersion::V_2024_11_05,
|
|
capabilities: ServerCapabilities::builder()
|
|
.enable_tools()
|
|
.build(),
|
|
server_info: Implementation::from_build_env(),
|
|
instructions: Some(
|
|
"Compliance Scanner MCP server. Query security findings, SBOM data, and DAST results."
|
|
.to_string(),
|
|
),
|
|
}
|
|
}
|
|
}
|