Skip to main content
Glama
io.github.daedalus/mcp-cryptography

io.github.daedalus/mcp-cryptography

by daedalus

mcp-cryptography

MCP server exposing cryptography library functionality.

PyPI Python Ruff

mcp-name: io.github.daedalus/mcp-cryptography

Install

pip install mcp-cryptography

Related MCP server: Azure Key Vault MCP

Usage

from mcp_cryptography import mcp

# Run the MCP server
if __name__ == "__main__":
    mcp.run()

Available Tools

The server provides the following cryptographic tools:

Key Generation

  • generate_symmetric_key - Generate a Fernet symmetric key

  • generate_rsa_key - Generate an RSA key pair

  • generate_x25519_key - Generate an X25519 key pair

Symmetric Encryption

  • fernet_encrypt / fernet_decrypt - Fernet encryption

  • aes_encrypt / aes_decrypt - AES encryption (CBC/GCM modes)

Asymmetric Encryption

  • rsa_encrypt / rsa_decrypt - RSA OAEP encryption

  • rsa_sign / rsa_verify - RSA digital signatures

Hashing

  • hash_sha256 - SHA-256 hash

  • hash_sha512 - SHA-512 hash

  • hash_sha1 - SHA-1 hash

HMAC

  • hmac_sign - Generate HMAC

  • hmac_verify - Verify HMAC

Key Derivation

  • pbkdf2_derive - PBKDF2 key derivation

  • scrypt_derive - Scrypt key derivation

X.509 Certificates

  • generate_self_signed_cert - Generate self-signed certificate

  • parse_certificate - Parse X.509 certificate

Utilities

  • generate_random_bytes - Generate random bytes

  • generate_random_base64 - Generate random base64 bytes

Development

git clone https://github.com/daedalus/mcp-cryptography.git
cd mcp-cryptography
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mcp_cryptography src/

Available Tools

22 tools
aes_decryptA

Decrypt AES ciphertext.

Args: key: Hex-encoded AES key. ciphertext: Hex-encoded ciphertext. iv: Hex-encoded initialization vector. mode: Encryption mode - 'CBC' or 'GCM' (default CBC).

Returns: Decrypted string.

Raises: ValueError: If key size is invalid.

Inputs: iv (required), key (required), ciphertext (required), mode. Returns: result

aes_encryptA

Encrypt data using AES.

Args: key: Hex-encoded AES key (16, 24, or 32 bytes). data: String to encrypt. mode: Encryption mode - 'CBC' or 'GCM' (default CBC).

Returns: Dictionary with 'ciphertext' (hex) and 'iv' (hex).

Raises: ValueError: If key size is invalid.

Inputs: key (required), data (required), mode. Returns: object

fernet_decryptA

Decrypt Fernet ciphertext.

Args: key: Base64-encoded Fernet key. ciphertext: Base64-encoded ciphertext.

Returns: Decrypted plain text string.

Raises: cryptography.fernet.InvalidToken: If decryption fails.

Inputs: key (required), ciphertext (required). Returns: result

fernet_encryptA

Encrypt data using Fernet symmetric encryption.

Args: key: Base64-encoded Fernet key. data: Plain text string to encrypt.

Returns: Base64-encoded ciphertext.

Example: >>> key = generate_symmetric_key() >>> ciphertext = fernet_encrypt(key, "Hello, World!") >>> len(ciphertext) > 0 True

Inputs: key (required), data (required). Returns: result

generate_random_base64A

Generate random bytes encoded as base64.

Args: length: Number of bytes to generate (default 32).

Returns: Base64-encoded random string.

Inputs: length. Returns: result

generate_random_bytesA

Generate random bytes.

Args: length: Number of bytes to generate (default 32).

Returns: Hex-encoded random bytes.

Example: >>> generate_random_bytes(16) 'a1b2c3d4e5f6...'

Inputs: length. Returns: result

generate_rsa_keyA

Generate an RSA key pair.

Args: key_size: Key size in bits (default 2048). Must be at least 2048.

Returns: Dictionary with 'public_key' and 'private_key' in PEM format.

Raises: ValueError: If key_size is less than 2048.

Inputs: key_size. Returns: object

generate_self_signed_certA

Generate a self-signed X.509 certificate.

Args: common_name: Common name for the certificate subject. organization: Organization name (optional). days_valid: Number of days the certificate is valid (default 365).

Returns: Dictionary with 'certificate' (PEM) and 'private_key' (PEM).

Inputs: common_name (required), days_valid, organization. Returns: object

generate_symmetric_keyA

Generate a Fernet symmetric key.

Returns: Base64-encoded 32-byte key suitable for Fernet encryption.

Example: >>> key = generate_symmetric_key() >>> len(key) # 44 characters base64 encoded 44

Inputs: no named parameters. Returns: result

generate_x25519_keyA

Generate an X25519 key pair for key exchange.

Returns: Dictionary with 'public_key' and 'private_key' in PEM format.

Example: >>> keys = generate_x25519_key() >>> len(keys['public_key']) > 0 True

Inputs: no named parameters. Returns: object

hash_sha1A

Compute SHA-1 hash.

Note: SHA-1 is considered cryptographically broken. Use only for legacy compatibility.

Args: data: String to hash.

Returns: Hex-encoded hash.

Inputs: data (required). Returns: result

hash_sha256A

Compute SHA-256 hash.

Args: data: String or base64-encoded bytes to hash.

Returns: Hex-encoded hash.

Example: >>> hash_sha256("Hello, World!") 'dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f'

Inputs: data (required). Returns: result

hash_sha512B

Compute SHA-512 hash.

Args: data: String to hash.

Returns: Hex-encoded hash.

Inputs: data (required). Returns: result

hmac_signA

Generate HMAC.

Args: key: Hex-encoded key. data: String to sign. algorithm: Hash algorithm - 'sha256' or 'sha512' (default sha256).

Returns: Hex-encoded HMAC.

Example: >>> hmac_sign("aabbcc", "message") 'c053c4f7...'

Inputs: key (required), data (required), algorithm. Returns: result

hmac_verifyA

Verify HMAC.

Args: key: Hex-encoded key. data: String that was signed. hmac: Hex-encoded HMAC to verify. algorithm: Hash algorithm - 'sha256' or 'sha512'.

Returns: True if HMAC is valid.

Inputs: key (required), data (required), hmac (required), algorithm. Returns: result

parse_certificateB

Parse X.509 certificate.

Args: certificate_pem: Certificate in PEM format.

Returns: Dictionary with 'subject', 'issuer', 'not_valid_before', 'not_valid_after'.

Inputs: certificate_pem (required). Returns: object

pbkdf2_deriveA

Derive key using PBKDF2.

Args: password: Password to derive from. salt: Hex-encoded salt (optional, will generate if not provided). iterations: Number of iterations (default 480000, OWASP recommended).

Returns: Dictionary with 'derived_key' (hex) and 'salt' (hex).

Inputs: password (required), salt, iterations. Returns: object

rsa_decryptB

Decrypt RSA ciphertext using private key.

Args: private_key_pem: RSA private key in PEM format. ciphertext: Base64-encoded ciphertext.

Returns: Decrypted string.

Inputs: ciphertext (required), private_key_pem (required). Returns: result

rsa_encryptA

Encrypt data using RSA with OAEP asymmetric_padding.

Args: public_key_pem: RSA public key in PEM format. data: String to encrypt (max ~446 bytes for 4096-bit key).

Returns: Base64-encoded ciphertext.

Raises: ValueError: If data is too large for the key size.

Inputs: data (required), public_key_pem (required). Returns: result

rsa_signA

Create RSA digital signature.

Args: private_key_pem: RSA private key in PEM format. data: String to sign.

Returns: Base64-encoded signature.

Inputs: data (required), private_key_pem (required). Returns: result

rsa_verifyA

Verify RSA digital signature.

Args: public_key_pem: RSA public key in PEM format. data: Original signed data. signature: Base64-encoded signature.

Returns: True if signature is valid.

Inputs: data (required), signature (required), public_key_pem (required). Returns: result

scrypt_deriveA

Derive key using Scrypt.

Args: password: Password to derive from. salt: Hex-encoded salt (optional, will generate if not provided).

Returns: Dictionary with 'derived_key' (hex) and 'salt' (hex).

Inputs: password (required), salt. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 22 tools

    Disambiguation4/5

    Tools are generally distinct, but generate_symmetric_key and generate_random_bytes both produce random data, which could cause confusion; however, descriptions clarify their purposes.

    Naming Consistency3/5

    Naming conventions vary: some tools use verb_noun (generate_symmetric_key), others use algorithm_verb (fernet_encrypt, aes_encrypt), and hash_sha256 mixes verb and algorithm. Inconsistency reduces predictability.

    Tool Count4/5

    22 tools cover a broad cryptography domain; while slightly above the typical 3-15 range, each tool has a clear purpose and the count is justified.

    Completeness4/5

    Major cryptographic operations are covered: symmetric/asymmetric encryption, hashing, signing, key derivation, certificates. Missing modern algorithms like Ed25519 or ECDSA are minor gaps.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides cryptographic identity and signing capabilities for AI agents, enabling them to create persistent identities, sign actions with private keys, and allow external systems to verify the authenticity and provenance of agent-initiated operations.
      4
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables management of Azure Key Vault secrets and certificates, including creation, retrieval, deletion, format conversion (PEM/CRT to PFX), certificate chain imports, and self-signed certificate generation.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides cryptographic hash and HMAC computation for text, supporting algorithms like md5, sha1, sha256, sha384, and sha512. All operations are performed locally without transmitting or storing input data.
      326 npm
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables cryptographic operations including hashing, encoding/decoding, ID generation, password tools, and JWT inspection via MCP.
      5
      59 npm
      MIT