Skip to main content
Glama
crypto-inventory-mcp

crypto-inventory-mcp

README.md
# crypto-inventory-mcp

**Turn a published rule into a check any AI agent can run, keep a human on the decision, and produce evidence in a standard format.**

The first rule-set is encryption. The tool reads a codebase, finds where encryption is used, rates each finding against published NIST, UK NCSC and IETF guidance, and writes:

- a plain-English report with a **human sign-off table** (owner, decision, date), and
- a **CBOM** (Cryptography Bill of Materials) in the open [CycloneDX 1.6](https://cyclonedx.org/capabilities/cbom) format, checked against the official schema in the tests.

It runs as an **MCP server**, so any MCP-compatible agent can call it.

![How it works](docs/how-it-works.png)

## Why

- The UK NCSC asks organisations to carry out a full discovery exercise of what depends on cryptography by 2028 ([timelines](https://www.ncsc.gov.uk/guidance/pqc-migration-timelines)).
- NIST deprecates quantum-vulnerable public-key algorithms (RSA, ECDSA, EdDSA, DH, ECDH) after 2030 and disallows them after 2035 ([NIST IR 8547](https://csrc.nist.gov/pubs/ir/8547/final)).
- More broadly, agent projects stall on governance: controls, evidence and accountable sign-off. This repo is a small, working example of all three.

## Ratings

| Rating | Examples | Source |
|---|---|---|
| Already weak today | MD5, SHA-1, RC4, Triple DES | RFC 6151, NIST SHA-1 transition, RFC 7465, NIST SP 800-131A Rev. 2 |
| At risk from future quantum computers | RSA, DSA, ECDSA, EdDSA, DH, ECDH, X25519 | NIST IR 8547 (Oct 2026) |
| Hybrid (classic + post-quantum) | X25519MLKEM768, mlkem768x25519 | FIPS 203; NCSC: an interim measure |
| Quantum-safe, on watch | ML-KEM, ML-DSA | FIPS 203/204; published research (Nov 2026) lowered long-term confidence in structured lattices |
| Quantum-safe | SLH-DSA | FIPS 205 |
| Not significantly affected | AES, ChaCha20, SHA-2, SHA-3 | NCSC, Next steps in preparing for PQC |

Every rating links to its source in [`rules.py`](rules.py). No rating exists without one.

## Quick start

```bash
pip install -r requirements.txt
python3 scanner.py path/to/code --out out     # report + CBOM + findings
python3 -m pytest -q                          # 14 tests
```

Example outputs from two public open-source libraries are in [`examples/`](examples).

![Example scan](docs/example-scan.png)

## Use from an agent (MCP)

```bash
QI_ALLOWED_ROOT=path/to/code python3 server.py   # MCP over stdio
```

Tools: `scan_folder`, `get_report`, `get_cbom`, `explain_rating`. Runs locally over stdio; a cloud agent platform would need it hosted over HTTP first.

## Safety by design

- **Read-only.** Reads files as text; never runs or changes code.
- **Fenced.** The MCP server only scans inside one allowed folder, resolves links before checking, and never follows linked files out of it.
- **No secrets in output.** Long key-like strings are masked in the findings file; a private key stored in code raises its own warning.

## Limits

It matches algorithm names in code and config. It does not check key sizes, follow how code uses an algorithm, or see running systems, cloud key stores or compiled programs. Whole comment lines are skipped; a comment at the end of a code line is still read. **Every finding needs a person to confirm it**: that is what the sign-off table is for.

## Licence

MIT. See [LICENSE](LICENSE).