Skip to main content

MCP server for TLS certificate analysis via the Model Context Protocol

Project description

dcert (Python)

CI/CD Pipeline PyPI version License: MIT

A Python MCP wrapper for the dcert Rust server.

Uses FastMCP to create a transparent proxy around the dcert-mcp Rust binary, exposing all TLS certificate tools via the Model Context Protocol. New tools added to the Rust binary are automatically available without any Python code changes.

Requirements

  • Python 3.12+
  • The dcert-mcp Rust binary is bundled in platform-specific wheels (no network access needed at runtime)

Installation

pip install dcert

Platform-specific wheels are available for:

  • Linux x86_64 (Ubuntu 22.04+, glibc 2.35+)
  • macOS Intel (x86_64)
  • macOS Apple Silicon (ARM64)

A universal fallback wheel auto-downloads the binary on first use if no platform wheel matches.

Quick Start

As a server

from dcert import create_server

server = create_server()
server.run()  # stdio mode (default)

As a client

import asyncio
from dcert import create_client

async def main():
    async with create_client() as client:
        tools = await client.list_tools()
        print(f"Available tools: {len(tools)}")

        result = await client.call_tool(
            "analyze_certificate", {"target": "example.com"}
        )
        print(result)

asyncio.run(main())

Typed async tool wrappers

For production use with type safety, timeouts, and automatic reconnection:

import asyncio
from dcert.tools import DcertClient

async def main():
    async with DcertClient(timeout=60.0) as dcert:
        # Analyze a certificate
        result = await dcert.analyze_certificate(target="example.com")

        # Check expiry with custom threshold
        expiry = await dcert.check_expiry(target="example.com", days=90)

        # Get TLS connection details
        info = await dcert.tls_connection_info(target="example.com")

        # Export PEM chain
        pem = await dcert.export_pem(target="example.com", output_path="chain.pem")

asyncio.run(main())

All 11 tools are available as typed async methods:

Method Description
analyze_certificate() Decode and analyze 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() Get TLS connection details (cipher, protocol, latency)
export_pem() Export certificate chain as PEM
verify_key_match() Verify private key matches a certificate
convert_pfx_to_pem() Convert PKCS12/PFX to PEM files
convert_pem_to_pfx() Convert PEM cert+key to PKCS12/PFX
create_keystore() Create PKCS12 keystore (Java-compatible)
create_truststore() Create PKCS12 truststore from CA certs

Error handling

from dcert.tools import (
    DcertClient,
    DcertError,          # Base exception
    DcertTimeoutError,   # Tool call timed out
    DcertConnectionError,# Subprocess died
    DcertToolError,      # MCP tool returned an error
)

async with DcertClient(timeout=30.0, max_reconnects=3) as dcert:
    try:
        result = await dcert.analyze_certificate(target="example.com")
    except DcertTimeoutError:
        print("Tool call timed out")
    except DcertToolError as e:
        print(f"Tool error: {e} (tool={e.tool})")
    except DcertConnectionError:
        print("Binary subprocess crashed")

CLI

# stdio mode (default, for MCP clients like Claude Code)
dcert-python

# HTTP mode
dcert-python --transport http --host 0.0.0.0 --port 8080

# Pre-download binary (universal wheel only)
dcert-python --setup

# Explicit binary path
dcert-python --binary /usr/local/bin/dcert-mcp

Binary Discovery

The package locates the dcert-mcp Rust binary in this order:

  1. DCERT_MCP_BINARY environment variable
  2. Bundled binary in the package bin/ directory
  3. dcert-mcp on PATH (platform wheels install the binary here)
  4. Auto-download from GitHub Releases (universal wheel fallback, with SHA256 verification)

Environment Variables

The proxy forwards these environment variables to the Rust binary:

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

Scalability

This package uses the MCP proxy pattern: the Python layer never needs to know about individual dcert tools. All tool discovery, input schemas, and invocations are forwarded to the Rust binary via the MCP protocol at runtime. When new capabilities are added to the Rust server, they are immediately available through the Python wrapper.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dcert-3.0.38-py3-none-win_amd64.whl (10.8 MB view details)

Uploaded Python 3Windows x86-64

dcert-3.0.38-py3-none-manylinux_2_35_x86_64.whl (8.1 MB view details)

Uploaded Python 3manylinux: glibc 2.35+ x86-64

dcert-3.0.38-py3-none-macosx_11_0_arm64.whl (7.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

dcert-3.0.38-py3-none-macosx_10_15_x86_64.whl (7.8 MB view details)

Uploaded Python 3macOS 10.15+ x86-64

dcert-3.0.38-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file dcert-3.0.38-py3-none-win_amd64.whl.

File metadata

  • Download URL: dcert-3.0.38-py3-none-win_amd64.whl
  • Upload date:
  • Size: 10.8 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dcert-3.0.38-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bc9b4a024c8914c4351d17356e0fe5d5c1f1d2f6bfaf6406d2a08b0f333c529e
MD5 ab90f6cf1604f2207d723c99dbb51ad3
BLAKE2b-256 5d42d7b365fd3c99784720e0e0d28c663f01b67afa0335421a7a242534dff7e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for dcert-3.0.38-py3-none-win_amd64.whl:

Publisher: ci.yml on SCGIS-Wales/dcert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dcert-3.0.38-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for dcert-3.0.38-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 7614d7e24886b2a3b18d3c86c40687199f8cf6107f10e0b4a3462d9c1dc58166
MD5 539257076f7736115fa31517f16ecb86
BLAKE2b-256 772d621a5e45ed45952138724864ffdcc553bf4329e4a55d679af6224e97cb2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dcert-3.0.38-py3-none-manylinux_2_35_x86_64.whl:

Publisher: ci.yml on SCGIS-Wales/dcert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dcert-3.0.38-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dcert-3.0.38-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 73711ffc4da4dd8b3432fb0d656afefc8ed70559e843518ab4f6b9f013eef9f3
MD5 8f023b454c8f3c3505d863db4710f293
BLAKE2b-256 3488a83ea80eb024f34b79a68b84ea607989df78f04bd55b0a9e54c6024c764d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dcert-3.0.38-py3-none-macosx_11_0_arm64.whl:

Publisher: ci.yml on SCGIS-Wales/dcert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dcert-3.0.38-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for dcert-3.0.38-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d3ff9e80b0f0d01371e5ef8b96e08c1339890b0cd7f307b24d9c92b6c4a981ac
MD5 e1c5647b697303fa5fc2bcfa27950bbb
BLAKE2b-256 aaf75fc2faafbc7ee915ff7c42112f3c49aba98410c2a8081675034b1b283617

See more details on using hashes here.

Provenance

The following attestation bundles were made for dcert-3.0.38-py3-none-macosx_10_15_x86_64.whl:

Publisher: ci.yml on SCGIS-Wales/dcert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dcert-3.0.38-py3-none-any.whl.

File metadata

  • Download URL: dcert-3.0.38-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dcert-3.0.38-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd34049c13c742b97636f1dbb3495d6873e21c75fd8b6c64fc0c0b6da889583
MD5 8e831e7c5c9cef0f336753c73d033423
BLAKE2b-256 45985026ad2822b9d6895321315e1a3cacb1bc9f110114f5d97910409b18b4d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dcert-3.0.38-py3-none-any.whl:

Publisher: ci.yml on SCGIS-Wales/dcert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page