Skip to content

A Model Context Protocol (MCP) server for calculating hashes and HMAC. Works with Claude Desktop & VSCode.

License

Notifications You must be signed in to change notification settings

congito/MCP-Hashing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server for Comprehensive Cryptographic Hashing

A comprehensive Model Context Protocol (MCP) server supporting all Python hashing algorithms, HMAC operations, and algorithm discovery. This server enables LLMs to perform a wide range of cryptographic hashing operations efficiently.

Available Tools

The server offers 4 main tools:

  • hash: Universal hashing tool supporting all Python hashlib algorithms (MD5, SHA family, SHA-3, BLAKE2, etc.)
  • hmac: Hash-based Message Authentication Code using any supported hash algorithm

Available Resources

The server provides 2 resources for algorithm discovery:

  • algorithms://available: Lists all available hashing algorithms
  • algorithms://properties/{algorithm}: Provides properties for a specific algorithm

Supported Algorithms

The server dynamically discovers and supports all algorithms available in your Python installation, typically including:

  • MD Family: md5
  • SHA-1: sha1
  • SHA-2: sha224, sha256, sha384, sha512
  • SHA-3: sha3_224, sha3_256, sha3_384, sha3_512
  • BLAKE2: blake2b, blake2s
  • Others: ripemd160, and more depending on your system

Tool Usage Examples

Universal Hash Tool

# Basic SHA-256 hashing
await hash(data="hello world", algorithm="sha256")
# Returns: "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"

# MD5 with base64 output
await hash(data="test", algorithm="md5", output_format="base64")
# Returns: "CY9rzUYh03PK3k6DJie09g=="

# BLAKE2b with custom digest size
await hash(data="hello", algorithm="blake2b", kwargs='{"digest_size": 16}')
# Returns: 32-character hex string (16 bytes)

# SHA-3 hashing
await hash(data="secure data", algorithm="sha3_256")
# Returns: SHA-3 256-bit hash

HMAC Tool

# HMAC with SHA-256
await hmac(data="message", key="secret_key", algorithm="sha256")
# Returns: HMAC-SHA256 digest

# HMAC with MD5 and base64 output
await hmac(data="data", key="key", algorithm="md5", output_format="base64")
# Returns: Base64-encoded HMAC-MD5 digest

Algorithm Discovery

# Get all available algorithms
algorithms = await access_resource("algorithms://available")
# Returns: JSON with hash_algorithms array

# Get properties for SHA-256
properties = await access_resource("algorithms://properties/sha256")
# Returns: JSON with digest_size, block_size, category, description

Server in Action

The server processes requests and returns corresponding cryptographic hashes for any supported algorithm. It works with Claude Desktop, VS Code, and other MCP clients.

Prerequisites

  • To Run via Docker: Docker installed and running.
  • To Run Directly: Python 3.13+ and a virtual environment tool (venv, uv).
  • To Contribute/Develop: Git, Python 3.13+, uv (recommended) or pip, Docker (optional, for testing build).

Option 1: Running the Server with Docker (Recommended)

This is the simplest way to run the server without managing Python environments directly.

1. Get the Docker Image:

  • Pull from Docker Hub (Easiest):
docker pull kunalpathak13/mcp-hashing-server:latest

2. Configure Your MCP Client:

  • VS Code (settings.json):

    "mcp": {
        "servers": {
            "hashing-docker": {
                "command": "docker",
                "args": [
                    "run",
                    "-i",      // Keep STDIN open for communication
                    "--rm",    // Clean up container after exit
                    "kunalpathak13/mcp-hashing-server:latest" // Change the tag to your version if needed e.g. "mcp-hashing-server:X.Y.Z"
                ]
            }
        }
    }
  • Claude Desktop (claude_desktop_config.json):

    {
    	"mcpServers": {
    		"hashing-docker": {
    			"command": "docker",
    			"args": [
    				"run",
    				"-i",
    				"--rm",
    				"kunalpathak13/mcp-hashing-server:latest" // Change the tag to your version if needed e.g. "mcp-hashing-server:X.Y.Z"
    			]
    		}
    	}
    }
  • Other Clients: Adapt according to their docs, using docker as the command and run -i --rm IMAGE_NAME as arguments. Refer to their official documentation for precise configuration steps:

3. Test the Integration:

Ask your MCP client questions like:

  • "Calculate the SHA-256 hash of 'hello world'"
  • "Generate an HMAC-SHA256 for 'message' with key 'secret'"
  • "What hashing algorithms are available?"
  • "Show me the properties of the BLAKE2b algorithm"

Option 2: Running the Server Directly (Python Environment)

Use this method if you prefer not to use Docker or for development purposes.

1. Set Up Environment & Install:

# Create a dedicated directory and navigate into it
mkdir my_mcp_setup && cd my_mcp_setup

# Create & Activate Virtual Environment
uv venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows

# Install the package
uv pip install mcp-hashing-server

2. Find the Executable Path:

# On Linux/macOS:
which mcp-hashing-server

# On Windows:
where mcp-hashing-server

3. Configure Your MCP Client:

Use the absolute path in your client configuration:

  • VS Code (settings.json):

    "mcp": {
        "servers": {
            "hashing": {
                "command": "/full/path/to/your/virtualenv/bin/mcp-hashing-server"
            }
        }
    }
  • Claude Desktop (claude_desktop_config.json):

    {
    	"mcpServers": {
    		"hashing": {
    			"command": "/full/path/to/your/virtualenv/bin/mcp-hashing-server"
    		}
    	}
    }

Contributing / Development Setup

1. Clone the Repository:

git clone https://github.com/kanad13/MCP-Server-for-Hashing.git
cd MCP-Server-for-Hashing

2. Set Up Development Environment:

# Create & Activate Virtual Environment
uv venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows

# Install in editable mode with development dependencies
uv pip install -e ".[dev]"

(This installs the package such that code changes in src/ take effect immediately without reinstalling. It also installs tools defined in [project.optional-dependencies.dev] like pytest)

3. Running Locally During Development: Ensure your development virtual environment is active. You can run the server using:

# Run the installed script (available due to -e flag)
mcp-hashing-server

4. Running Locally During Development:

# Run the installed script
mcp-hashing-server

# Or execute the module directly
python -m mcp_hashing.cli

API Reference

Hash Tool

async def hash(
    data: str,                    # Data to hash
    algorithm: str,               # Algorithm name (e.g., 'sha256', 'blake2b')
    encoding: str = "utf-8",      # Text encoding
    output_format: str = "hex",   # 'hex' or 'base64'
    **kwargs                      # Algorithm-specific parameters
) -> str

HMAC Tool

async def hmac(
    data: str,                    # Data to authenticate
    key: str,                     # Secret key
    algorithm: str,               # Hash algorithm to use
    encoding: str = "utf-8",      # Text encoding
    output_format: str = "hex"    # 'hex' or 'base64'
) -> str

Security Features

  • Input Length Limits: Prevents DoS attacks with configurable limits (default: 1MB)
  • Algorithm Validation: Only allows algorithms available in the system
  • Parameter Sanitization: Validates all input parameters
  • Secure Key Handling: Proper handling of HMAC keys
  • Comprehensive Logging: Detailed logging for monitoring and debugging

Where to Find This Package

License

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

Acknowledgements

About

A Model Context Protocol (MCP) server for calculating hashes and HMAC. Works with Claude Desktop & VSCode.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.3%
  • Shell 18.8%
  • Dockerfile 3.9%