Skip to main content

MCP server for Railgun privacy protocol - private DeFi made easy

Project description

🛡️ Railgun MCP Server

PyPI Version License: MIT Python Version

A comprehensive Model Context Protocol (MCP) server for interacting with the Railgun privacy protocol. This server enables AI assistants and other MCP clients to perform private DeFi transactions on Ethereum, Arbitrum, Polygon, and BSC with zero-knowledge privacy guarantees.

✨ Features

🔐 Complete Privacy Suite

  • Wallet Management - Create, import, and manage Railgun wallets with both public (0x) and private (0zk) addresses
  • Private Transactions - Send tokens privately between 0zk addresses with zero-knowledge proofs
  • Shield/Unshield - Move tokens between public and private balances seamlessly
  • Multi-Wallet Operations - Batch operations, token distribution, and privacy mixing

🧩 Advanced DeFi Integration

  • Recipe System - Create and execute complex DeFi operations privately
  • Private Swaps - Trade tokens without revealing amounts or addresses
  • Relayer Network - Enhanced privacy through decentralized relayer integration
  • Gas Optimization - Smart gas estimation and transaction batching

🤖 Plain-English AI Tools

  • Smart Affordability Checker - "Can I afford this transaction?"
  • Cost Explainer - "Why is this so expensive?"
  • Simple Money Sending - "Just send 100 USDC to alice.eth privately"
  • Token Finder - "Where are my tokens?"
  • Privacy Optimizer - "How can I be more private?"
  • Emergency Exit - "Get all my funds out quickly"

🌐 Multi-Network Support

  • Ethereum - Full feature support
  • Arbitrum - L2 privacy with low fees
  • Polygon - Fast and cheap private transactions
  • BSC - Binance Smart Chain integration

🚀 Quick Start

Installation

# Install from PyPI (recommended)
pip install railgun-mcp

# Or install from source
git clone https://github.com/railgun-org/railgun-mcp.git
cd railgun-mcp
pip install -e .

Configuration

Option 1: Environment Variables

export RAILGUN_API_KEY="your-api-key-here"
export RAILGUN_WALLET_PASSWORD="your-secure-password"
export ETHEREUM_RPC_URL="https://eth-mainnet.g.alchemy.com/v2/your-key"

Option 2: Config File Create ~/.railgun/config.json:

{
  "api_key": "your-railgun-api-key-here",
  "wallet_password": "your-secure-wallet-password",
  "rpc_endpoints": {
    "ethereum": "https://eth-mainnet.g.alchemy.com/v2/your-key",
    "arbitrum": "https://arb-mainnet.g.alchemy.com/v2/your-key",
    "polygon": "https://polygon-mainnet.g.alchemy.com/v2/your-key"
  }
}

Run the Server

# Start the MCP server
python -m railgun_mcp

# Or use the command line tool
railgun-mcp

Connect with MCP Client

Add to your MCP client configuration:

{
  "mcpServers": {
    "railgun": {
      "command": "python",
      "args": ["-m", "railgun_mcp"],
      "env": {
        "RAILGUN_API_KEY": "your-api-key"
      }
    }
  }
}

🛠️ Available Tools

👛 Wallet Management

  • create_wallet - Create a new Railgun wallet
  • import_wallet - Import existing wallet from private key
  • list_wallets - List all configured wallets
  • create_wallet_batch - Create multiple wallets for enhanced privacy

💰 Balance & Transactions

  • get_balance - Check public and private balances
  • shield_tokens - Move tokens to private balance
  • unshield_tokens - Move tokens to public balance
  • private_transfer - Transfer between 0zk addresses
  • get_transaction_history - View transaction history
  • distribute_tokens - Distribute tokens across multiple wallets

🔄 DeFi Operations

  • create_recipe - Create custom DeFi recipes
  • execute_recipe - Execute recipes privately
  • create_swap_recipe - Pre-built swap recipes
  • estimate_recipe_gas - Estimate gas costs

🤖 AI-Friendly Tools

  • can_i_afford_this - Check if you can afford an action
  • why_is_this_so_expensive - Explain transaction costs
  • just_send_money - Send money the easiest way
  • where_are_my_tokens - Find all your tokens
  • fix_stuck_transaction - Help with stuck transactions
  • optimize_my_privacy - Get privacy improvement tips
  • emergency_exit - Quick fund extraction

🌐 Network & Utilities

  • get_relayers - Find available relayers
  • get_supported_tokens - List supported tokens
  • check_config - Verify configuration
  • verify_proof - Verify zero-knowledge proofs

📖 Usage Examples

Basic Wallet Operations

# Create a wallet
create_wallet(network="ethereum", password="secure-password")

# Shield tokens into private balance  
shield_tokens(
    wallet_id="wallet-123",
    token_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",  # USDC
    amount="1000000000"  # 1000 USDC
)

# Private transfer
private_transfer(
    wallet_id="wallet-123", 
    token_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    amount="500000000",  # 500 USDC
    recipient_0zk_address="0zk1234..."
)

AI-Friendly Operations

# Simple English commands
can_i_afford_this(wallet_id="wallet-123", action="swap", amount="1000", token="USDC")

just_send_money(
    wallet_id="wallet-123",
    to="alice.eth", 
    amount="100 USDC",
    keep_private=True
)

where_are_my_tokens(wallet_id="wallet-123")

Advanced Privacy Features

# Create multiple wallets for privacy
create_wallet_batch(count=5, network="ethereum", password_prefix="secure")

# Distribute tokens across wallets
distribute_tokens(
    source_wallet_id="wallet-123",
    token_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    total_amount="5000000000",  # 5000 USDC
    destination_wallet_ids=["wallet-124", "wallet-125", "wallet-126"],
    distribution_type="equal"
)

# Mix tokens for enhanced privacy
mix_tokens(
    wallet_ids=["wallet-123", "wallet-124", "wallet-125"],
    token_address="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    mixing_rounds=3
)

🔒 Security Best Practices

  • Never commit API keys or private keys to version control
  • Use environment variables or secure config files for sensitive data
  • Always verify transaction details before execution
  • Keep wallet passwords secure and use strong, unique passwords
  • Enable 2FA on all related accounts (RPC providers, etc.)
  • Regular security audits of your configuration

🧪 Development

# Clone the repository
git clone https://github.com/railgun-org/railgun-mcp.git
cd railgun-mcp

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black railgun_mcp/
isort railgun_mcp/

# Type checking
mypy railgun_mcp/

# Run with debug logging
export LOG_LEVEL=DEBUG
python -m railgun_mcp

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Run the test suite
  5. Submit a pull request

📄 License

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

🔗 Links

⚠️ Disclaimer

This software is provided "as is" without warranties. Always verify transactions and use at your own risk. The Railgun protocol is experimental technology - please understand the risks before using with significant funds.

Project details


Download files

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

Source Distribution

railgun_mcp-0.2.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

railgun_mcp-0.2.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file railgun_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: railgun_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for railgun_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 930a4e310c9a295c05ca53205f364c16e426a7155928924d63b6364a4b4cc968
MD5 39ada42995105bec904ff74a7b30e465
BLAKE2b-256 5879132a325ec223bcdf56136af74c1e5da4904ada5f9f9bfcb1e6a7fc7a16b9

See more details on using hashes here.

File details

Details for the file railgun_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: railgun_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for railgun_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1398f25ba3e1842dae2cc9d1cecdd22ad361185d7f4fe9c583432b34a2987cde
MD5 6a1f3e8351ea10de0b54f44cd6447200
BLAKE2b-256 de9f8b327630f5695f708adb089702621b9f2228a1ab2c48078915b412a863ae

See more details on using hashes here.

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