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 decryptionencryptAESWithIV(plainText, key)
โ AES CBC mode with random IV (returns IV:cipherText)decryptAESWithIV(cipherWithIV, key)
โ AES CBC decryptiongenerateAESKey(bitSize)
โ Generate 128/192/256-bit AES keyvalidateAESKey(key)
โ Check key validity (length, non-null)encryptJSON(json, key)
โ AES CBC encryption for JSONdecryptJSON(cipher, key)
โ AES CBC decryption for JSONtoHex(byte[])
/fromHex(hex)
โ Hex encoding/decoding
๐ RSA (RSATool)
generateRSAKeyPair()
โ Generates a Base64 public/private key pairencryptRSA(plainText, publicKey)
โ Encrypt using public keydecryptRSA(cipherText, privateKey)
โ Decrypt using private keyencryptLongRSA(plainText, publicKey)
โ Encrypt long string (chunked)decryptLongRSA(cipherText, privateKey)
โ Decrypt long RSA textsignData(data, privateKey)
โ Sign data using RSA private keyverifySignature(data, signature, publicKey)
โ Verify RSA signatureformatKeyToPEM(base64Key, isPublic)
โ Convert Base64 key to PEM formatdecryptPEMKey(pem, isPublic)
โ Extract Base64 from PEMsignJSON(json, privateKey)
โ Sign full JSON documentvalidateRSAKey(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 hashgenerateSaltedHash(input, salt, algorithm)
โ Salted hashgenerateRandomSalt(length)
โ Generate secure random saltisHash(input)
โ Check if string looks like a valid hashisHashMatchWithSalt(input, salt, expectedHash, algorithm)
โ Salted hash comparisonhashBase64(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
- Email: [email protected]
- GitHub: @key824999