# aquasecurity/trivy-mcp architecture

> Architecture diagram of the GitHub repository aquasecurity/trivy-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aquasecurity/trivy-mcp
- Repository: https://github.com/aquasecurity/trivy-mcp

## Overview

- **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: [`pkg/commands/root.go`](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/commands/root.go) (Root command), [`pkg/mcpserver/mcp.go`](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/mcpserver/mcp.go) (MCP server), [`pkg/findings/finding.go`](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/finding.go) (Findings model), [`pkg/tools/tool.go`](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/tool.go) (Tool catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Entry & CLI"]
  node_n1["Plugin entry<br/>go main<br/>[main.go]"]
  node_n2["Root command<br/>cli dispatch<br/>[root.go]"]
  node_n3["Auth command<br/>auth flow<br/>[auth.go]"]
  node_n4["Flags<br/>config assembly<br/>[flag.go]"]
  node_n5["Options<br/>config model<br/>[options.go]"]
end

subgraph group_g2["MCP Runtime"]
  node_n6["MCP server<br/>protocol boundary<br/>[mcp.go]"]
  node_n7["Tool catalog<br/>tool registry<br/>[tool.go]"]
  node_n8["Scan tool<br/>mcp tool<br/>[scan.go]"]
  node_n9["Scan args<br/>scan inputs<br/>[scan_args.go]"]
  node_n10["Aqua scan<br/>scan backend<br/>[aqua.go]"]
  node_n11["Version tool<br/>mcp tool<br/>[version.go]"]
  node_n12["Result format<br/>response formatting<br/>[findings.go]"]
end

subgraph group_g3["Scan & Findings"]
  node_n13["Findings model<br/>domain model<br/>[finding.go]"]
  node_n14[("Finding store<br/>persistence model<br/>[store.go]")]
  node_n15["Severity<br/>classification<br/>[severity.go]"]
end

subgraph group_g4["Integrations"]
  node_n16["Aqua report<br/>report schema<br/>[aqua_report.go]"]
  node_n17["Credentials<br/>auth boundary<br/>[aqua.go]"]
  node_n18["Verify access<br/>credential check<br/>[verify.go]"]
end

subgraph group_g5["Repo Support"]
  node_n19["Docs<br/>guides<br/>[README.md]"]
  node_n20["CI pipeline<br/>automation<br/>[test.yml]"]
end

node_n1 -->|"starts"| node_n2
node_n2 -->|"loads"| node_n4
node_n4 -->|"builds"| node_n5
node_n2 -->|"routes"| node_n3
node_n2 -->|"starts"| node_n6
node_n6 -->|"registers"| node_n7
node_n7 -->|"includes"| node_n8
node_n7 -->|"includes"| node_n11
node_n8 -->|"uses"| node_n9
node_n8 -->|"executes"| node_n10
node_n10 -->|"parses"| node_n16
node_n10 -->|"normalizes"| node_n13
node_n13 -->|"stores"| node_n14
node_n13 -->|"classifies"| node_n15
node_n12 -->|"formats"| node_n13
node_n3 -->|"validates"| node_n17
node_n17 -->|"checks"| node_n18
node_n6 -->|"returns"| node_n12
node_n19 -.->|"documents"| node_n6
node_n20 -.->|"builds"| node_n1

click node_n1 "https://github.com/aquasecurity/trivy-mcp/blob/main/cmd/trivy-mcp/main.go"
click node_n2 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/commands/root.go"
click node_n3 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/commands/auth.go"
click node_n4 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/flag/flag.go"
click node_n5 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/flag/options.go"
click node_n6 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/mcpserver/mcp.go"
click node_n7 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/tool.go"
click node_n8 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/scan.go"
click node_n9 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/scan_args.go"
click node_n10 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/aqua.go"
click node_n11 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/version/version.go"
click node_n12 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/result/findings.go"
click node_n13 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/finding.go"
click node_n14 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/store.go"
click node_n15 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/severity.go"
click node_n16 "https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/types/aqua_report.go"
click node_n17 "https://github.com/aquasecurity/trivy-mcp/blob/main/internal/creds/aqua.go"
click node_n18 "https://github.com/aquasecurity/trivy-mcp/blob/main/internal/creds/verify.go"
click node_n19 "https://github.com/aquasecurity/trivy-mcp/blob/main/docs/README.md"
click node_n20 "https://github.com/aquasecurity/trivy-mcp/blob/main/.github/workflows/test.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2,node_n3,node_n4,node_n5 toneBlue
class node_n6,node_n7,node_n8,node_n9,node_n10,node_n11,node_n12 toneAmber
class node_n13,node_n14,node_n15 toneMint
class node_n16,node_n17,node_n18 toneRose
class node_n19,node_n20 toneIndigo
```

## Components

### Entry & CLI

Plugin entrypoint and command dispatch.

- [Plugin entry](https://github.com/aquasecurity/trivy-mcp/blob/main/cmd/trivy-mcp/main.go): go main · Trivy plugin startup entrypoint. · `cmd/trivy-mcp/main.go`
- [Root command](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/commands/root.go): cli dispatch · Top-level command routing and startup orchestration. · `pkg/commands/root.go`
- [Auth command](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/commands/auth.go): auth flow · Authentication-related command handling. · `pkg/commands/auth.go`
- [Flags](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/flag/flag.go): config assembly · Centralized CLI and runtime option parsing. · `pkg/flag/flag.go`
- [Options](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/flag/options.go): config model · Shared option definitions used across command and server setup. · `pkg/flag/options.go`

### MCP Runtime

Server boundary and tool registration.

- [MCP server](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/mcpserver/mcp.go): protocol boundary · Exposes the plugin as an MCP server over supported transports. · `pkg/mcpserver/mcp.go`
- [Tool catalog](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/tool.go): tool registry · Defines the MCP tool set and execution contracts. · `pkg/tools/tool.go`
- [Scan tool](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/scan.go): mcp tool · Security analysis tool implementation. · `pkg/tools/scan/scan.go`
- [Scan args](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/scan_args.go): scan inputs · Builds scan inputs and execution parameters. · `pkg/tools/scan/scan_args.go`
- [Aqua scan](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/scan/aqua.go): scan backend · Aqua-backed scanning path and execution adapter. · `pkg/tools/scan/aqua.go`
- [Version tool](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/version/version.go): mcp tool · Reports plugin and tool version information. · `pkg/tools/version/version.go`
- [Result format](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/tools/result/findings.go): response formatting · Formats normalized findings for MCP responses. · `pkg/tools/result/findings.go`

### Scan & Findings

Scanning pipeline and normalized output model.

- [Findings model](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/finding.go): domain model · Normalized finding identity, severity, list, and storage semantics. · `pkg/findings/finding.go`
- [Finding store](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/store.go): persistence model · Finding collection and storage behavior. · `pkg/findings/store.go`
- [Severity](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/findings/severity.go): classification · Severity representation and ordering. · `pkg/findings/severity.go`

### Integrations

External auth and report format boundaries.

- [Aqua report](https://github.com/aquasecurity/trivy-mcp/blob/main/pkg/types/aqua_report.go): report schema · Models the Aqua report format used in translation. · `pkg/types/aqua_report.go`
- [Credentials](https://github.com/aquasecurity/trivy-mcp/blob/main/internal/creds/aqua.go): auth boundary · Aqua credential handling and verification. · `internal/creds/aqua.go`
- [Verify access](https://github.com/aquasecurity/trivy-mcp/blob/main/internal/creds/verify.go): credential check · Credential validation and access verification helpers. · `internal/creds/verify.go`

### Repo Support

Docs and automation around the core runtime.

- [Docs](https://github.com/aquasecurity/trivy-mcp/blob/main/docs/README.md): guides · Installation, configuration, authentication, and IDE setup. · `docs/README.md`
- [CI pipeline](https://github.com/aquasecurity/trivy-mcp/blob/main/.github/workflows/test.yml): automation · Lint, test, and release workflows. · `.github/workflows/test.yml`

## Connections

- 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.
