Skip to main content
Glama
CVE Search MCP Server

CVE Search MCP Server

by Arnabdaz
README.md
# CVE Search MCP Server

A Model Context Protocol (MCP) server for CVE and vulnerability searching, optimized for PR reviews. It answers the question a reviewer actually asks — *"is this dependency at this version vulnerable, and what's the fix?"* — and covers CVEs newer than an LLM's training data.

## Features

- **10 tools**: precise dependency checks (single + batch), CVE lookup (single + bulk), keyword and product search, recent and high-severity CVEs, CVSS breakdown, data-source health
- **Current APIs**: CIRCL Vulnerability-Lookup, NVD CVE API 2.0, GitHub security advisories, OSV.dev
- **Best available CVSS**: v4.0 > v3.1 > v3.0 > v2.0, scored from the vector when a source only gives a vector
- **Compact output**: one small record shape per vulnerability (no multi-KB raw JSON unless asked), so a PR review can call several tools
- **Honest results**: every result carries `sources: {name: "ok" | "error: …"}` and `partial: true` when a source failed, so a failed source is never reported as "no vulnerabilities"
- **Rate-limit aware**: one shared NVD limiter (5 req/30 s without a key, 50 with); a call waits at most 20 s for NVD capacity, then returns partial results that say so
- **3 transports**: stdio (default), SSE, Streamable HTTP

## Installation

Requires Python 3.10+ and [uv](https://github.com/astral-sh/uv).

```bash
cd cve-search
uv sync
```

### Development

```bash
uv sync --extra dev
uv run pytest                   # unit tests (no network)
uv run ruff check src tests
uv run mypy src
uv run python test_server.py    # live smoke test against the real APIs
```

## Configuration

| Env var | Default | Description |
|---|---|---|
| `NVD_API_KEY` | none | **Recommended.** Raises NVD's limit from 5 to 50 requests / 30 s, so recent/high-severity searches don't come back partial. Free at [nvd.nist.gov](https://nvd.nist.gov/developers/request-an-api-key). |
| `GITHUB_TOKEN` | none | Raises the GitHub advisory API limit from 60 to 5,000 requests/hour (used by `search_cve_by_id` for fix versions). |
| `CVE_SEARCH_TIMEOUT` | `20` | HTTP request timeout in seconds. |

## Running

```bash
uv run python main.py                                                  # stdio (Claude Desktop / IDEs)
uv run python main.py --transport sse --host 127.0.0.1 --port 8000
uv run python main.py --transport streamable-http --host 127.0.0.1 --port 8000
```

### Claude Desktop config

```json
{
  "mcpServers": {
    "cve-search": {
      "command": "uv",
      "args": ["--directory", "/path/to/cve-search", "run", "python", "main.py"],
      "env": { "NVD_API_KEY": "your-key", "GITHUB_TOKEN": "your-token" }
    }
  }
}
```

## Tools

| Tool | Use it for | Source |
|---|---|---|
| `check_dependencies` | **Dependencies added or bumped in a PR** — up to 100 `{ecosystem, name, version}` at once | OSV |
| `check_package_vulnerabilities` | One package at one exact version → `vulnerable`, `recommended_version`, per vulnerability its CVE/GHSA ids, `affected` ranges with fixes and `fix_for_version` | OSV |
| `search_cve_by_id` | One CVE in detail: best CVSS, CWEs, affected products, EPSS, GHSA ids, `fixed_in` | CIRCL, NVD, GitHub |
| `bulk_cve_lookup` | Up to 20 CVE ids, compact | CIRCL, NVD |
| `search_by_keyword` | Technology/library keyword, newest first ("log4j", "spring boot") | NVD, CIRCL |
| `search_vulnerabilities_by_product` | Vendor + product, paged (`page`, `next_page`) | CIRCL |
| `get_recent_cves` | Published in the last 1–120 days, optional `min_severity` | NVD |
| `check_high_severity_cves` | High/Critical (v3 or v4) in the last 1–120 days, worst first | NVD |
| `cvss_score_lookup` | Every CVSS version NVD has for a CVE, plus the best score | NVD |
| `get_vulnerability_stats` | Size and last update of each data source | CIRCL |

### Dependency checks

- **Ecosystems** use OSV's names — `PyPI`, `npm`, `Maven`, `Go`, `crates.io`, `RubyGems`, `NuGet`, `Packagist`, `Hex`, `Pub`, … — and common aliases (`pip`, `node`, `cargo`, `golang`, `composer`, `gem`, `java`, `dotnet`).
- **Maven** names are `group:artifact`, e.g. `org.apache.logging.log4j:log4j-core`.
- **Versions must be exact** (from the lockfile). Ranges like `^4.17.0`, `>=2.0`, `[1.0,2.0)` or `1.x`, placeholders like `${version}` or `latest`, and — for npm, crates.io, Go, Pub, Hex and NuGet — short versions like `1.0` (a range in those manifests) are rejected, because checking them could wrongly report "not vulnerable". Without a version, all known vulnerabilities are listed and flagged `version_checked: false`.
- **The fix for your version**: each vulnerability lists `affected` ranges paired with their fix, and `fix_for_version` — the fix of the range that contains *your* version (a vulnerability can have several ranges, e.g. log4j-core CVE-2021-45046: `<2.12.2` and `>=2.13.0, <2.16.0`; for 2.14.1 the fix is 2.16.0, not 2.12.2). `recommended_version` is the lowest version that fixes everything listed.
- GHSA/PYSEC/CVE duplicates of the same vulnerability are merged per package.
- `check_package_vulnerabilities` lists up to 20 vulnerabilities, worst first, with `total` and `truncated`. `check_dependencies` stays compact for 100 packages: the worst 5 per package in a slim form (150 in total), clean packages in one `not_vulnerable` list, details fetched for at most 200 vulnerabilities, and `truncated` when anything was cut.

```
check_dependencies([
  {"ecosystem": "Maven", "name": "org.apache.logging.log4j:log4j-core", "version": "2.14.1"},
  {"ecosystem": "npm",   "name": "lodash", "version": "4.17.20"},
  {"ecosystem": "PyPI",  "name": "requests", "version": "2.32.3"}
])
```

## PR review workflow

1. **Dependencies changed?** Take exact versions from the lockfile diff → `check_dependencies([...])`. Recommend `recommended_version` (or each vulnerability's `fix_for_version`).
2. **Need more on one CVE?** `search_cve_by_id("CVE-…")` for exploit likelihood (`epss`), affected products and GitHub's `fixed_in`.
3. **New technology without a package version** (e.g. a service or base image)? `search_by_keyword("…")` or `search_vulnerabilities_by_product(vendor, product)`.
4. **Context for a release**: `check_high_severity_cves(7)`.

## Project structure

```
cve-search/
├── src/mcp_server_cve_search/
│   ├── config.py              # Config from env vars
│   ├── server.py              # FastMCP app + transport dispatch
│   ├── tools/
│   │   ├── common.py          # CVE id validation, per-source status, client bundle
│   │   ├── dependencies.py    # check_package_vulnerabilities, check_dependencies
│   │   ├── cve_lookup.py      # search_cve_by_id, bulk_cve_lookup
│   │   ├── keyword_search.py  # search_by_keyword
│   │   ├── product_search.py  # search_vulnerabilities_by_product
│   │   ├── recent_cves.py     # get_recent_cves, check_high_severity_cves
│   │   ├── cvss.py            # cvss_score_lookup
│   │   └── stats.py           # get_vulnerability_stats
│   ├── sources/
│   │   ├── http.py            # shared HTTP helper; failures raise SourceError
│   │   ├── ratelimit.py       # shared NVD rate limiter
│   │   ├── circl.py           # CIRCL Vulnerability-Lookup
│   │   ├── nvd.py             # NVD CVE API 2.0
│   │   ├── github.py          # GitHub security advisories (lookup by CVE)
│   │   └── osv.py             # OSV.dev
│   └── utils/
│       ├── cvss.py            # CVSS v2/v3/v4 scoring and precedence
│       ├── records.py         # compact record normalisers + merge
│       ├── ecosystems.py      # OSV ecosystem names, exact-version validation
│       ├── formatting.py      # severity summaries
│       ├── normalization.py   # keyword normalisation
│       └── severity.py        # score → severity level
├── tests/                     # unit tests; fixtures recorded from the live APIs
├── examples/
├── main.py
└── test_server.py             # live smoke test (one call per tool)
```

Test fixtures are trimmed real responses. If an upstream API changes shape, re-record them with `uv run python tests/fixtures/record_fixtures.py`.

## Data sources

| Source | Endpoint | Used for |
|---|---|---|
| [OSV.dev](https://osv.dev) | `api.osv.dev/v1` | Package/version checks, fixed versions |
| [CIRCL Vulnerability-Lookup](https://vulnerability.circl.lu) | `vulnerability.circl.lu/api` | CVE records (CVE JSON 5), product and full-text search, EPSS, source stats |
| [NVD](https://nvd.nist.gov) | `services.nvd.nist.gov/rest/json/cves/2.0` | Keyword search, date/severity windows, CVSS detail |
| [GitHub advisories](https://github.com/advisories) | `api.github.com/advisories` | CVE → GHSA ids and patched versions |

## License

MIT License

TDQS

A4/5.0

Scored across 8 tools

Disambiguation4/5

Tools have mostly distinct purposes, but get_recent_cves and check_high_severity_cves both retrieve recent CVEs, differing only by severity filter. Bulk vs single CVE lookup also overlap slightly. Descriptions help disambiguate.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with underscores and are descriptive, e.g., search_by_keyword, get_recent_cves. No mixing of conventions.

Tool Count5/5

8 tools is well-scoped for a CVE search server, covering various lookup methods and utility functions without being excessive.

Completeness4/5

Covers key CVE lookup methods (by ID, keyword, product, date range, severity) and stats. Missing advanced features like subscription or CVE creation, but core search is complete.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues