wjdwo951219

MCP-Cipher

Community wjdwo951219
Updated

MCP-Cipher

MCP-Cipher is a Java-based Model Context Protocol (MCP) compatible tool that provides cryptographic operations such as AES/RSA encryption, hashing, HMAC, and key generation.

It is designed to be used by any AI agent or tool host that supports the MCP specification.

โšก Secure, Extensible, and Lightweight

MCP-Cipher is designed to be:

  • Secure, using standard Java crypto libraries (AES, RSA, SHA, HMAC)
  • Extensible, with modular classes (AESTool, RSATool, HashTool)
  • Lightweight, using no external cryptography dependencies

Installation

Please refer to the ๐Ÿ“„llms-install.md file for step-by-step installation instructions for Claude Desktop, MCP CLI, and more.

Features by Category

๐Ÿ” AES (AESTool)

  • encryptAES(plainText, key) โ€“ AES encryption (ECB mode, Base64)
  • decryptAES(cipherText, key) โ€“ AES decryption
  • encryptAESWithIV(plainText, key) โ€“ AES CBC mode with random IV (returns IV:cipherText)
  • decryptAESWithIV(cipherWithIV, key) โ€“ AES CBC decryption
  • generateAESKey(bitSize) โ€“ Generate 128/192/256-bit AES key
  • validateAESKey(key) โ€“ Check key validity (length, non-null)
  • encryptJSON(json, key) โ€“ AES CBC encryption for JSON
  • decryptJSON(cipher, key) โ€“ AES CBC decryption for JSON
  • toHex(byte[]) / fromHex(hex) โ€“ Hex encoding/decoding

๐Ÿ” RSA (RSATool)

  • generateRSAKeyPair() โ€“ Generates a Base64 public/private key pair
  • encryptRSA(plainText, publicKey) โ€“ Encrypt using public key
  • decryptRSA(cipherText, privateKey) โ€“ Decrypt using private key
  • encryptLongRSA(plainText, publicKey) โ€“ Encrypt long string (chunked)
  • decryptLongRSA(cipherText, privateKey) โ€“ Decrypt long RSA text
  • signData(data, privateKey) โ€“ Sign data using RSA private key
  • verifySignature(data, signature, publicKey) โ€“ Verify RSA signature
  • formatKeyToPEM(base64Key, isPublic) โ€“ Convert Base64 key to PEM format
  • decryptPEMKey(pem, isPublic) โ€“ Extract Base64 from PEM
  • signJSON(json, privateKey) โ€“ Sign full JSON document
  • validateRSAKey(base64Key) โ€“ Check if Base64 RSA key looks valid

๐Ÿ”’ Hashing (HashTool)

  • generateSHA256(input) โ€“ SHA-256 hash (hex)
  • generateSHA512(input) โ€“ SHA-512 hash (hex)
  • generateMD5(input) โ€“ MD5 hash (hex)
  • compareHash(input, expectedHash, algorithm) โ€“ Compare string with hash
  • generateSaltedHash(input, salt, algorithm) โ€“ Salted hash
  • generateRandomSalt(length) โ€“ Generate secure random salt
  • isHash(input) โ€“ Check if string looks like a valid hash
  • isHashMatchWithSalt(input, salt, expectedHash, algorithm) โ€“ Salted hash comparison
  • hashBase64(input, algorithm) โ€“ Generate Base64-encoded hash

โ„น๏ธ All functions are annotated with @Tool and can be auto-discovered by any compliant MCP host at runtime.

Usage Examples

Once installed in an MCP-compatible host:

  • encryptAES("hello", "mys3cretKey") โ†’ Base64EncryptedText
  • decryptAESWithIV("IV:Base64Cipher", "mys3cretKey") โ†’ hello
  • generateRSAKeyPair() โ†’ { publicKey, privateKey }
  • signData("important", privateKey) โ†’ Base64Signature
  • generateSHA256("secure") โ†’ HexSHA256Hash

Technical Details

  • Built with Spring Boot and spring-ai-mcp-server-spring-boot-starter
  • MCP-compatible methods are annotated with @Tool
  • manifest.json is automatically generated using ClassGraph to scan the tool package
  • Executable jar is placed under ./libs for use by MCP hosts

Build Instructions

./gradlew clean build

This will:

  • Build the executable Spring Boot jar
  • Generate manifest.json
  • Copy the jar to ./libs for publication

Output

The following files will be generated and should be committed:

  • libs/MCP-Cipher-0.0.1-SNAPSHOT.jar
  • manifest.json

License

This project is licensed under the MIT License. See the LICENSE file for details.

ยฉ 2025 JUNG JE KIM Original author and maintainer: JUNG JE KIM

Author

MCP Server ยท Populars

MCP Server ยท New