How aquasecurity/trivy-mcp works
• What this repo is: a Go-based Trivy plugin that starts an MCP server. The plugin is declared by plugin.yaml, and the binary entrypoint is cmd/trivy-mcp/main.go.
• Startup path: execution flows from the entrypoint into the command layer in pkg/commands (root.go, auth.go). That layer is responsible for CLI command dispatch and for starting the server or handling auth-related actions.
• Runtime configuration: pkg/flag centralizes command-line/config options. This is where transport choices, scan-related settings, and authentication-related flags are assembled before the server starts.
• MCP server boundary: pkg/mcpserver/mcp.go is the main protocol boundary. It exposes the plugin as an MCP server and supports the transports called out in the README: stdio, streamable HTTP, and SSE.
• Tooling layer: pkg/tools defines the MCP tool catalog and execution contracts. The important tools visible in the tree are:
- scan for security analysis
- version for reporting tool/plugin versioning
- result formatting helpers under pkg/tools/result
• Scan pipeline: pkg/tools/scan is the execution path for security checks. scan_args.go builds the scan inputs, scan.go coordinates execution, and aqua.go handles the Aqua-backed scanning path.
• Domain model for output: scan output is normalized into internal findings structures under pkg/findings. This package owns finding identity, severity, listing, and storage semantics so the MCP layer does not deal with raw scan output directly.
• Report parsing boundary: pkg/types/aqua_report.go models the Aqua report format that the scanner produces or consumes. That acts as the translation layer between raw scanner output and the repo’s internal finding representation.
• Authentication and credential validation: internal/creds encapsulates Aqua credential handling and verification. The auth command in pkg/commands/auth.go likely uses this boundary to validate or configure access to Aqua Platform features.
• External integrations: the repo primarily serves MCP-enabled clients such as VS Code, Cursor, JetBrains IDEs, and Claude Desktop. The optional external service is Aqua Security Platform, used for enhanced scanning and assurance-policy compliance.
• End-to-end data flow: IDE/client request → MCP transport in pkg/mcpserver → tool dispatch in pkg/tools → scan execution in pkg/tools/scan → report parsing in pkg/types → normalized findings in pkg/findings → formatted MCP response back to the client.
• Supporting repo structure: docs/ contains installation, configuration, authentication, and IDE-specific setup guides; .github/workflows/ provides lint/test/release automation; Makefile and go.mod indicate a standard Go build/test/release pipeline.
Main entry points: root.go Root command · mcp.go MCP server · finding.go Findings model · tool.go Tool catalog
Components 20
Entry & CLI
Plugin entrypoint and command dispatch.
- Plugin entry · Trivy plugin startup entrypoint.
cmd/trivy-mcp/main.go - Root command · Top-level command routing and startup orchestration.
pkg/commands/root.go - Auth command · Authentication-related command handling.
pkg/commands/auth.go - Flags · Centralized CLI and runtime option parsing.
pkg/flag/flag.go - Options · Shared option definitions used across command and server setup.
pkg/flag/options.go
MCP Runtime
Server boundary and tool registration.
- MCP server · Exposes the plugin as an MCP server over supported transports.
pkg/mcpserver/mcp.go - Tool catalog · Defines the MCP tool set and execution contracts.
pkg/tools/tool.go - Scan tool · Security analysis tool implementation.
pkg/tools/scan/scan.go - Scan args · Builds scan inputs and execution parameters.
pkg/tools/scan/scan_args.go - Aqua scan · Aqua-backed scanning path and execution adapter.
pkg/tools/scan/aqua.go - Version tool · Reports plugin and tool version information.
pkg/tools/version/version.go - Result format · Formats normalized findings for MCP responses.
pkg/tools/result/findings.go
Scan & Findings
Scanning pipeline and normalized output model.
- Findings model · Normalized finding identity, severity, list, and storage semantics.
pkg/findings/finding.go - Finding store · Finding collection and storage behavior.
pkg/findings/store.go - Severity · Severity representation and ordering.
pkg/findings/severity.go
Integrations
External auth and report format boundaries.
- Aqua report · Models the Aqua report format used in translation.
pkg/types/aqua_report.go - Credentials · Aqua credential handling and verification.
internal/creds/aqua.go - Verify access · Credential validation and access verification helpers.
internal/creds/verify.go
Repo Support
Docs and automation around the core runtime.
- Docs · Installation, configuration, authentication, and IDE setup.
docs/README.md - CI pipeline · Lint, test, and release workflows.
.github/workflows/test.yml
Connections 20
- Plugin entry → Root command: starts · Entrypoint hands control to command dispatch.
- Root command → Flags: loads · Commands assemble runtime options from flags.
- Flags → Options: builds · Flag parsing populates shared option state.
- Root command → Auth command: routes · Root command dispatches auth-related actions.
- Root command → MCP server: starts · Command layer launches the MCP server.
- MCP server → Tool catalog: registers · Server exposes the available tools.
- Tool catalog → Scan tool: includes · Tool catalog includes scan capability.
- Tool catalog → Version tool: includes · Tool catalog includes version reporting.
- Scan tool → Scan args: uses · Scan tool builds execution inputs.
- Scan tool → Aqua scan: executes · Scan tool delegates to Aqua-backed scanning.
- Aqua scan → Aqua report: parses · Scanner output is translated through Aqua report schema.
- Aqua scan → Findings model: normalizes · Scan results are converted into findings.
- Findings model → Finding store: stores · Findings are collected and stored.
- Findings model → Severity: classifies · Severity is part of the finding model.
- Result format → Findings model: formats · Formatted responses are built from normalized findings.
- Auth command → Credentials: validates · Auth command uses credential handling.
- Credentials → Verify access: checks · Credential verification confirms access.
- MCP server → Result format: returns · MCP layer returns formatted tool output.
- Docs → MCP server: documents · Docs explain server transports and client setup.
- CI pipeline → Plugin entry: builds · CI covers build and runtime verification.