Skip to main content
Glama
README.md
# `certguard-mcp` — Offline X.509 Chain, SPKI Key Parity & RFC 6125 SAN MCP Server, CLI & GitHub Action

[![z121245017-ai/certguard-mcp MCP server](https://glama.ai/mcp/servers/z121245017-ai/certguard-mcp/badges/score.svg)](https://glama.ai/mcp/servers/z121245017-ai/certguard-mcp)

Zero-dependency, 100% offline **Model Context Protocol (`MCP`) Server**, **CLI**, and **GitHub Action** enabling AI coding agents (Claude Desktop, Claude Code, Cursor, Windsurf, Antigravity) and pull-request CI pipelines to audit **X.509 PEM/DER certificate chains**, prove mathematical **`SubjectPublicKeyInfo` (`SPKI`) parity across Certificate, CSR, and Private Key without exposing private key scalars**, validate **RFC 6125 wildcard `SubjectAltName` coverage**, and extract **gateway hexadecimal serial numbers & SHA-256 SPKI pins**.

## MCP Tools Exposed (`stdio`)

| Tool | Purpose | Safety Annotations |
| :--- | :--- | :--- |
| `audit_x509_pem_chain` | Decodes X.509 PEM or Base64 DER bundles, detects scrambled `Leaf -> Intermediate` order, missing intermediates, weak SHA-1/`<2048-bit` RSA keys, and expiry countdowns, plus emits topologically healed `Leaf -> Intermediate` `fullchain.pem`. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `verify_spki_key_and_csr_match` | Verifies mathematical `SubjectPublicKeyInfo` match across Certificate, PKCS#10 CSR, and PKCS#8/PKCS#1/SEC1 Private Key locally in memory without ever outputting private key scalar bytes. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `check_hostname_rfc6125_san` | Validates target hostnames and IPv4/IPv6 literals against X.509 `SubjectAltName` DNS/IP entries per RFC 6125, catching bare-apex `*.example.com` and multi-level `a.b.example.com` wildcard traps. | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |
| `extract_cert_serial_and_spki_pins` | Extracts uppercase contiguous Hex serial numbers (`serial_no` for WeChat Pay v3 / mTLS gateways), colon-separated SHA-256 thumbprints, and Base64 SHA-256 SPKI pins (`pin-sha256`). | `readOnlyHint: true`, `destructiveHint: false`, `idempotentHint: true`, `openWorldHint: false` |

## Quick Start (MCP Client & Local CLI)

```bash
# Start MCP server over stdio (supports both NDJSON and Content-Length framing)
npx -y github:z121245017-ai/certguard-mcp

# List MCP tool schemas from terminal
npx -y github:z121245017-ai/certguard-mcp --list

# Audit a fullchain.pem bundle and verify RFC 6125 hostname coverage (exits 2 on blocking findings)
npx -y github:z121245017-ai/certguard-mcp --cert ./certs/fullchain.pem --hostname api.example.com --strict

# Invoke any MCP tool directly via --cli
npx -y github:z121245017-ai/certguard-mcp --cli verify_spki_key_and_csr_match '{"certPath":"./certs/fullchain.pem","keyPath":"./certs/server.key"}'
```

### Claude Desktop / Cursor / Windsurf / Antigravity Config

```json
{
  "mcpServers": {
    "certguard": {
      "command": "npx",
      "args": ["-y", "github:z121245017-ai/certguard-mcp"]
    }
  }
}
```

### Docker (`node:22-alpine`, non-root `USER node`)

```bash
docker build -t certguard-mcp .
docker run -i --rm certguard-mcp
```

## GitHub Action (`z121245017-ai/certguard-mcp@v1`)

Audit public `.pem`, `.crt`, and `.cer` X.509 certificate bundles in pull requests and scheduled workflows for imminent expiry, inverted `Leaf -> Intermediate` chains, weak keys, and RFC 6125 SAN mismatches:

```yaml
name: X.509 Certificate Chain & Expiry Gate

on:
  pull_request:
    paths:
      - 'certs/**'
      - '**/*.pem'
      - '**/*.crt'
  schedule:
    - cron: '15 3 * * 1'

permissions:
  contents: read

jobs:
  certguard:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Audit repository public X.509 certificates
        uses: z121245017-ai/certguard-mcp@v1
        with:
          paths: 'certs'
          min-days-remaining: '30'
          fail-on-expiring: 'true'
```

## Security & Privacy Guarantees

- **Zero Private Scalar Output**: `verify_spki_key_and_csr_match` derives the public `SubjectPublicKeyInfo` digest in memory and verifies RSA/EC mathematical self-consistency (`2^(e*d) === 2 mod n` / curve scalar point match) while **never** returning private scalar `d`, prime factors `p`/`q`, or raw private key PEM/DER bytes.
- **Zero External Dependencies & Zero Network Calls**: Pure JavaScript ASN.1 DER/PEM decoder running locally on Node.js `>= 20`.

## Verification

```bash
npm test
```

## License

MIT License — `0` external npm dependencies, `0` network calls, `100%` local deterministic execution.

TDQS

A3.8/5.0

Scored across 4 tools

Disambiguation5/5

Each tool targets a distinct, non-overlapping check: chain ordering/strength audit, SPKI-to-CSR-to-key matching, RFC 6125 hostname/SAN validation, and serial/thumbprint/pin extraction. There is no plausible scenario where an agent would confuse one for another.

Naming Consistency4/5

All four tools follow a consistent verb_noun snake_case pattern (audit_, verify_, check_, extract_) with descriptive domain qualifiers. Names are long and packed with qualifiers, but the convention is uniform and readable.

Tool Count4/5

Four tightly scoped tools fit a focused certificate-validation server and each earns its place. It is on the lean side, but nothing is redundant or filler.

Completeness3/5

The surface covers chain inspection, key/CSR matching, hostname validation, and pin extraction, but has notable gaps for a cert-guard domain: no revocation checking (OCSP/CRL), no chain signature/trust-anchor verification, and no self-signed or expiry-only summary tool. Agents can work around some of this externally, but revocation is a real dead end.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues