Trivy MCP 服务器插件
该插件启动一个模型上下文协议 (MCP) 服务器,将 Trivy 的安全扫描功能与 VS Code 和其他支持 MCP 的工具集成在一起。
这是 MCP 服务器的早期开发阶段,因此您应该假设目前情况不会很好
特征
自然语言扫描:用自然语言询问有关安全问题
多种扫描类型:
本地项目的文件系统扫描
容器镜像漏洞扫描
远程存储库安全性分析
与 Aqua 平台集成:可选与 Aqua Security 平台集成,以增强扫描功能
灵活传输:支持 stdio 和 SSE(服务器发送事件)传输协议
VS Code 集成:与 VS Code 的聊天界面无缝集成
Related MCP server: Algolia
安装插件
要安装插件,您可以使用 Trivy 的插件管理系统
trivy plugin install mcp将安装最新版本的插件
启动插件
现在您可以启动插件了,这将启动一个可与 Cursor 或 VSCode 交互的 MCP 服务器。目前,本指南将主要介绍 VSCode。
trivy mcp可用选项
选项 | 价值观 | 默认 | 描述 |
|
|
| MCP 服务器的传输协议 |
| 23456 | SSE 传输模式的端口 | |
| 自定义 Trivy 二进制路径(可选) | ||
|
|
| 启用 Aqua 平台集成 |
|
|
| 启用调试日志记录 |
验证
MCP 服务器通过auth命令支持与 Aqua 平台集成:
# Save Aqua Platform credentials
trivy mcp auth login --key "YOUR_AQUA_KEY" --secret "YOUR_AQUA_SECRET" --region "YOUR_REGION"
# Clear saved credentials
trivy mcp auth logout
# Verify saved credentials
trivy mcp auth status可用的身份验证选项
选项 | 描述 |
| Aqua 平台 API 密钥 |
| Aqua 平台 API 机密 |
| Aqua 平台区域(例如“us-east-1”) |
配置凭据后,您可以通过使用--use-aqua-platform标志启动服务器来使用 Aqua Platform 功能:
trivy mcp --use-aqua-platform凭证安全地存储在特定于平台的密钥链中。
在 VSCode 中配置 MCP 服务器
现在,我们需要在 VSCode 中配置服务器以开始用作代理
先决条件
= VS Code 版本 1.99.0
配置插件
您可以配置 Trivy mcp 自行启动或使用 sse http 端点
配置 stdio
在 VS Code 中,按
F1搜索
"Preferences: Open User Settings (JSON)"查找或创建
"mcp"块并添加服务器,如下所示"mcp": { "servers": { "Trivy MCP": { "command": "trivy", "args": [ "mcp", "-t", "stdio" ] } } }保存后,将出现一条注释以
Start服务器
配置 SSE HTTP
启动 MCP 服务器
trivy mcp -t sse -p 23456在 VS Code 中,按
F1搜索
"Preferences: Open User Settings (JSON)"查找或创建
"mcp"块并添加服务器,如下所示"mcp": { "servers": { "Trivy SSE": { "type": "sse", "url": "http://localhost:23456/sse" } } }保存后,将出现一条注释以
Start服务器
示例查询
重要提示:请确保在
Agent模式下使用聊天窗口,而不是在Ask模式下
本地项目分析
Are there any vulnerabilities or misconfigurations in this project?Find all HIGH severity vulnerabilities in this codebaseGenerate a CycloneDX SBOM for this project容器镜像扫描
Does the python:3.12 image have any vulnerabilities?Show me all critical security issues in the nginx:latest imageWhat are the licenses used by dependencies in the node:18 image?存储库分析
What are the vulnerabilities in github.com/aquasecurity/trivy-ci-test?Check for misconfigurations in kubernetes/kubernetes repository高级用法
Scan this project for secrets and license issues onlyGenerate an SPDX SBOM and show me any dependency vulnerabilitiesWhat security issues were fixed in the latest version of this image?This server cannot be installed
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.