使用说明
OSV MCP服务器
MCP(模型上下文协议)服务器,提供对 OSV(开源漏洞)数据库.
概述
该项目实现了一个基于SSE的MCP服务器,该服务器允许LLM供电 应用程序查询OSV数据库以获取漏洞信息。服务器 提供以下工具:
- 查询特定包版本或提交的漏洞
- 批量查询多个包或提交的漏洞
- 按ID获取特定漏洞的详细信息
安装
先决条件
从源头构建
# Clone the repository
git clone https://github.com/StacklokLabs/osv-mcp.git
cd osv-mcp
# Build the server
task build
用法
使用ToolHive运行(推荐)
运行OSV MCP服务器的最简单方法是使用 ToolHive这提供了安全, MCP服务器的容器化部署:
# Install ToolHive (if not already installed)
# See: https://docs.stacklok.com/toolhive/guides-cli/install
# Register a supported client so ToolHive can auto-configure your environment
thv client setup
# Run the OSV MCP server (packaged as 'osv' in ToolHive)
thv run osv
# List running servers
thv list
# Get detailed information about the server
thv registry info osv
该服务器将可供您的MCP兼容客户端使用,并可以查询 用于漏洞信息的OSV数据库。
从源头运行
服务器配置
可以使用环境变量配置服务器:
-
MCP_PORT:运行服务器的端口号(默认值:8080)- 必须是介于0和65535之间的有效整数
- 如果无效或未设置,服务器将使用端口8080
-
MCP_TRANSPORT:服务器的传输模式(默认值:sse)- 支持的值:
sse,streamable-http - 如果无效或未设置,服务器将使用SSE传输模式
- 支持的值:
例子:
# Run on port 3000
MCP_PORT=3000 ./build/osv-mcp-server
# Run on default port 8080
./build/osv-mcp-server
MCP工具
服务器提供以下MCP工具:
查询脆弱性
查询影响特定包版本或提交的漏洞。
输入架构:
{
"type": "object",
"properties": {
"commit": {
"type": "string",
"description": "The commit hash to query for. If specified, version should not be set."
},
"version": {
"type": "string",
"description": "The version string to query for. If specified, commit should not be set."
},
"package_name": {
"type": "string",
"description": "The name of the package."
},
"ecosystem": {
"type": "string",
"description": "The ecosystem for this package (e.g., PyPI, npm, Go)."
},
"purl": {
"type": "string",
"description": "The package URL for this package. If purl is used, package_name and ecosystem should not be set."
}
}
}
查询_漏洞_匹配
一次查询影响多个包或提交的漏洞。
输入架构:
{
"type": "object",
"properties": {
"queries": {
"type": "array",
"description": "Array of query objects",
"items": {
"type": "object",
"properties": {
"commit": {
"type": "string",
"description": "The commit hash to query for. If specified, version should not be set."
},
"version": {
"type": "string",
"description": "The version string to query for. If specified, commit should not be set."
},
"package_name": {
"type": "string",
"description": "The name of the package."
},
"ecosystem": {
"type": "string",
"description": "The ecosystem for this package (e.g., PyPI, npm, Go)."
},
"purl": {
"type": "string",
"description": "The package URL for this package. If purl is used, package_name and ecosystem should not be set."
}
}
}
}
},
"required": ["queries"]
}
get_vulbility
按ID获取特定漏洞的详细信息。
输入架构:
{
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "The OSV vulnerability ID"
}
},
"required": ["id"]
}
例子
查询包的漏洞
{
"package_name": "lodash",
"ecosystem": "npm",
"version": "4.17.15"
}
查询提交的漏洞
{
"commit": "6879efc2c1596d11a6a6ad296f80063b558d5e0f"
}
批量查询漏洞
{
"queries": [
{
"package_name": "lodash",
"ecosystem": "npm",
"version": "4.17.15"
},
{
"package_name": "jinja2",
"ecosystem": "PyPI",
"version": "2.4.1"
}
]
}
获取漏洞详细信息
{
"id": "GHSA-vqj2-4v8m-8vrq"
}
发展
运行测试
task test
代码检查
task lint
格式化代码
task fmt
贡献
我们欢迎对MCP服务器的贡献!如果你想捐款,请 查看 贡献指南 有关如何获取的详细信息 起动。
如果您遇到错误或有功能请求,请
打开一个问题 在
存储库或加入我们 #mcp-servers 我们的频道
社区Discord服务器.
许可证
此项目在Apache v2许可证下获得许可-请参阅License文件 细节。
