Skip to main content

dcert (Python)

CI/CD Pipeline PyPI version License: MIT

A Python MCP wrapper for the dcert Rust server.

The package uses FastMCP to run a transparent proxy around the dcert-mcp Rust binary and exposes all TLS certificate tools over the Model Context Protocol. Tools added to the Rust binary are discovered at runtime, so the Python layer never needs to change.

Requirements

  • Python 3.12 or later
  • The dcert-mcp Rust binary. Platform wheels bundle it; the universal wheel downloads it on first use after verifying its SHA256 checksum.

Installation

pip install dcert

Platform wheels exist for Linux x86_64 (glibc 2.35 or later), macOS Intel, macOS Apple Silicon and Windows x86_64. The universal wheel works everywhere else that a release archive exists for.

Quick start

As a server

from dcert import create_server

create_server().run()  # stdio transport

As a client

import asyncio
from dcert import create_client

async def main() -> None:
    async with create_client() as client:
        tools = await client.list_tools()
        result = await client.call_tool("analyze_certificate", {"target": "example.com"})
        print(len(tools), result)

asyncio.run(main())

Typed async tool functions

The functional API opens a session (a subprocess plus its resilience stack) and passes it to plain async functions:

import asyncio
from dcert import analyze_certificate, check_expiry, create_session, export_pem

async def main() -> None:
    async with create_session(timeout=60.0) as session:
        cert = await analyze_certificate(target="example.com", session=session)
        expiry = await check_expiry(target="example.com", days=90, session=session)
        pem = await export_pem(target="example.com", output_path="chain.pem", session=session)
        raw = await session.call("tls_connection_info", {"target": "example.com"})

asyncio.run(main())

Leaving out session uses a shared default session that is created on first use and reused afterwards; close_default_session() shuts it down.

Function Description
analyze_certificate() Decode and analyse TLS certificates
check_expiry() Check certificate expiry within N days
check_revocation() Check OCSP revocation status
compare_certificates() Compare certificates between two targets
tls_connection_info() TLS connection details (cipher, protocol, latency)
export_pem() Export the certificate chain as PEM
verify_key_match() Verify a private key matches a certificate
convert_pfx_to_pem() Convert PKCS12/PFX to PEM files
convert_pem_to_pfx() Convert PEM cert and key to PKCS12/PFX
create_keystore() Create a PKCS12 keystore (Java compatible)
create_truststore() Create a PKCS12 truststore from CA certs

The network facing functions accept the shared mTLS and connection options (client_cert, client_key, pkcs12, cert_password, ca_cert, connect_to, resolve, proxy, noproxy) as keyword arguments.

Error handling

from dcert import (
    DcertError,            # base class
    DcertTimeoutError,     # the call exceeded its timeout
    DcertConnectionError,  # the subprocess died or the circuit breaker is open
    DcertToolError,        # the tool returned an error result (has .tool)
)

Only transport failures are retried, with exponential backoff and full jitter. TypeError and ValueError surface immediately and cancellation is never swallowed.

Command line

dcert-python                                   # stdio (for MCP clients such as Claude Code)
dcert-python --transport http --port 8080      # HTTP; bind 0.0.0.0 only behind a gateway
dcert-python --setup                           # download the binary and exit
dcert-python --binary /usr/local/bin/dcert-mcp # explicit binary
dcert-python --rate-limit 20 --bulkhead-max 4  # resilience flags
dcert-python --help                            # every option

dcert and dcert-mcp are thin wrappers that exec the Rust binaries with all arguments.

Configuration

Defaults live in the packaged dcert/config.yaml: the release URL, download limits, the platform table, the environment variables forwarded to the subprocess, the server bind address and every resilience value. dcert.load_config() returns them as an immutable record.

Resilience values can be overridden with DCERT_MCP_* environment variables (listed in dcert/resilience.py) and the dcert-python flags override those.

The proxy reads each tool's MCP annotations before applying caching or retries:

  • Caching (--cache) replays results only for tools marked read-only and idempotent. Tools that generate keys, issue or sign certificates, or change Vault state (create_csr, vault_issue, vault_sign, vault_renew, …) are always run.
  • Retry after a transport failure applies only to read-only or idempotent tools. Any other call surfaces the error instead of running a second time, because the first attempt may already have issued a certificate.

Binary discovery

  1. DCERT_MCP_BINARY (or DCERT_PATH for the dcert CLI)
  2. The bundled binary in the package bin/ directory
  3. A compiled dcert-mcp on PATH (pip console script wrappers are skipped)
  4. Download from GitHub Releases: https only, redirects restricted to GitHub hosts, size capped, SHA256 verified before extraction, installed atomically under a lock

Environment variables forwarded to the binary

Category Variables
Proxy HTTP_PROXY, HTTPS_PROXY, NO_PROXY (and lowercase variants)
TLS SSL_CERT_FILE, SSL_CERT_DIR, REQUESTS_CA_BUNDLE
dcert DCERT_PATH, DCERT_MCP_TIMEOUT, DCERT_MCP_CONNECTION_TIMEOUT, DCERT_MCP_READ_TIMEOUT

Development

cd python
pip install -e ".[dev]"
ruff check src tests ../scripts
ruff format --check src tests ../scripts
mypy
pytest

License

MIT

Metadata

Release files for dcert 3.0.49

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dcert 3.0.49
File Size Uploaded
dcert-3.0.49.tar.gz 49.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for dcert 3.0.49
File
dcert-3.0.49-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
dcert-3.0.49-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details
dcert-3.0.49-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
dcert-3.0.49-py3-none-macosx_10_15_x86_64.whl Python 3 none macOS 10.15+ x86-64 Details
dcert-3.0.49-py3-none-any.whl Python 3 none any Details

Total release size: 45.9 MB

Release files / dcert-3.0.49.tar.gz

Download URL dcert-3.0.49.tar.gz
Size 49.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8793845705e75c099f4ad50aab422fc94d3559872c221cd5215a7acd715dc64d
BLAKE2b-256 checksum
How to use checksums
b94b54d1e76d1b6202489e09cbe3877c642c91435809455ba815a3209867daa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / dcert-3.0.49-py3-none-win_amd64.whl

Download URL dcert-3.0.49-py3-none-win_amd64.whl
Size 13.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
9def8a6a006891e6c68c7fd6abe3bd6a58788aaed51a3472dd6805f4415e233e
BLAKE2b-256 checksum
How to use checksums
36cdf3b7cfffcfa161f20800e8b679c3ff879ceab27c07ab94542ff10342748a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / dcert-3.0.49-py3-none-manylinux_2_35_x86_64.whl

Download URL dcert-3.0.49-py3-none-manylinux_2_35_x86_64.whl
Size 11.4 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
9a17603632c9aac0a7baf6851d267e7bbc558218460e3aa53f3aa54d8e10002c
BLAKE2b-256 checksum
How to use checksums
f96283683299794baf1c3cf2945aedc76d7af7fef3b47b3242a028e8d5d1474f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / dcert-3.0.49-py3-none-macosx_11_0_arm64.whl

Download URL dcert-3.0.49-py3-none-macosx_11_0_arm64.whl
Size 10.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aaa25d8da89090c44185cfaf9dd3b1f24034cdaf54c9740d4b1b3d87b41c0cb2
BLAKE2b-256 checksum
How to use checksums
84590512bfda2d56441ed14318fb3f4b3e5d00dff5d2815a32612718aa7cad12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / dcert-3.0.49-py3-none-macosx_10_15_x86_64.whl

Download URL dcert-3.0.49-py3-none-macosx_10_15_x86_64.whl
Size 10.8 MB
Tags Python 3 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
42b62cb806b97d2b2e2e3d3842ea745bfeeae6101f5b291b42452d5ab42f3619
BLAKE2b-256 checksum
How to use checksums
1fce0fdb267384aae77339c35820b40b4df68667f5aea322727e2997fe82b651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / dcert-3.0.49-py3-none-any.whl

Download URL dcert-3.0.49-py3-none-any.whl
Size 33.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b401788a0ef7b378e805d5a90c0c9bbbffcd131abffec5375cb7899d1e3604c
BLAKE2b-256 checksum
How to use checksums
e3d673f31bc4a2b37d25c4bb8ae962949e51d75ae2677bc933b1e98f5d3e0855
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page