Skip to main content
Glama
README.md
# šŸ›”ļø CryptoMCP: Ultra-Secure Model Context Protocol Crypto & Web3 Gateway

[![License: BSL 1.1](https://img.shields.io/badge/License-BSL%201.1-blue.svg)](LICENSE)
[![Organization: RMAA Holdings](https://img.shields.io/badge/Organization-RMAA%20Holdings-purple.svg)](https://github.com/RMAAPK)
[![Framework: FastMCP](https://img.shields.io/badge/Framework-FastMCP%20TypeScript-teal.svg)](https://github.com/punkpeye/fastmcp)
[![Security: DMCPS Anti--Drainer](https://img.shields.io/badge/Security-DMCPS%20Anti--Drainer-red.svg)](https://github.com/RMAAPK/dmcps)

**CryptoMCP** (engineered by **RMAA Holdings**) is an ultra-hardened Model Context Protocol (MCP) Web3 gateway built with TypeScript and `FastMCP`. 

It enables AI Agents (Claude Desktop, ChatGPT, Gemini, ForgeAI) to query multichain balances, inspect smart contracts, and draft DeFi interactions **with 100x stronger anti-drainer security rails to prevent catastrophic wallet loss, honeypot scams, and prompt injection drainers**.

---

## šŸ›”ļø 100x Hardened Anti-Drainer Security Rails

On-chain cryptocurrency transactions are permanent and non-reversible. CryptoMCP implements mathematical defenses inspired by [DMCPS](https://github.com/RMAAPK/dmcps):

```
+-------------------------------------------------------------------------------------------------+
|                               CRYPTOMCP ANTI-DRAINER ARCHITECTURE                               |
+-------------------------------------------------------------------------------------------------+
|   AI AGENT (Claude / GPT / Gemini)                                                              |
|         │                                                                                       |
|         ā–¼  JSON-RPC (FastMCP / Stdio / Stream)                                                  |
|   [CRYPTOMCP SECURITY INTERCEPTOR] ──► Emergency Freeze Active? ──────────► [INSTANT BLOCK]     |
|         │                                                                                       |
|         ā”œā”€ā”€ā–ŗ Infinite Token Allowance (type(uint256).max)? ───────────────► [INSTANT BLOCK]     |
|         ā”œā”€ā”€ā–ŗ Non-Whitelisted Contract / Wallet Address? ──────────────────► [INSTANT BLOCK]     |
|         ā”œā”€ā”€ā–ŗ Value Exceeds Single Tx Cap ($100 USD)? ─────────────────────► [INSTANT BLOCK]     |
|         ā”œā”€ā”€ā–ŗ Value Exceeds Cumulative Daily Cap ($500 USD)? ──────────────► [INSTANT BLOCK]     |
|         │                                                                                       |
|         ā”œā”€ā”€ā–ŗ Value >= $25 USD (Human Challenge Gate)? ────────────────────► [REQUIRES TOKEN]    |
|         │                                                                         │             |
|         │                                                                         ā–¼             |
|         │                                                           [DMCPS ANTI-DRAINER UI]     |
|         │                                                           Human Cryptographic Sign    |
|         │                                                                         │             |
|         ā–¼                                                                         │             |
|   [BLOCKCHAIN BROADCAST & SIGNING (ETH / Polygon / Solana / BTC)] ā—„ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜             |
+-------------------------------------------------------------------------------------------------+
```

### 1. Mathematical Anti-Drainer (Infinite Approval Blocker)
- **The Attack:** 95% of phishing dApps trick users or agents into approving `type(uint256).max` (`0xffffffff...`), granting the smart contract unlimited permission to drain all ERC-20 tokens at any future point.
- **The Defense:** CryptoMCP inspects the calldata selector (`0x095ea7b3`) and automatically drops any transaction attempting infinite or unbounded allowances.

### 2. Strict Destination Whitelisting
- The AI **cannot** send funds or interact with unverified contract addresses extracted from untrusted web pages or prompts.
- All target addresses (e.g. 1inch, Uniswap, Aave) must be explicitly registered and assigned a daily budget by the human owner in the Dashboard.

### 3. Human-In-The-Loop (HITL) Cryptographic Challenge Gate
- Any transaction value greater than or equal to `$25.00 USD` triggers an unforgeable challenge token (`CRYPTO_AUTH_...`) with a 10-minute expiry.
- The transaction cannot be broadcast to the blockchain until the human owner confirms the details in the Dashboard or passes the token back to `submit_crypto_approval_token`.

### 4. Cold Wallet Emergency Killswitch
- One click on the Dashboard instantly freezes all signing operations and rejects any inbound agent tool calls.

---

## šŸ› ļø MCP Tools Exposed to AI

| Tool Name | Risk Level | Description |
| :--- | :--- | :--- |
| `list_wallets` | 🟢 Safe (Read) | Lists managed public wallet addresses, chains, and token balances. |
| `list_whitelisted_contracts` | 🟢 Safe (Read) | Lists authorized DEX routers, lending pools, and recipient entities. |
| `transfer_crypto` | šŸ”“ High (Gated)| Initiates transfer or contract interaction; guarded by Anti-Drainer rules. |
| `submit_crypto_approval_token`| 🟔 Auth (Commit)| Submits human challenge token to sign and broadcast high-value transaction. |
| `get_crypto_security_status` | 🟢 Safe (Read) | Audits active USD spend caps, remaining daily budget, and freeze status. |

---

## šŸš€ Quickstart & Dashboard

### 1. Install & Build
```bash
npm install
npm run build
```

### 2. Configure Environment
```bash
cp .env.example .env
```
Edit `.env` credentials:
```env
PORT=8090
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your_secure_password_here
MAX_SINGLE_TX_USD=100
MAX_DAILY_TX_USD=500
HUMAN_APPROVAL_THRESHOLD_USD=25
BLOCK_INFINITE_ALLOWANCE=true
```

### 3. Run the Gateway
```bash
npm start
```
- **Anti-Drainer Control Dashboard:** `http://localhost:8090/dashboard`
- **FastMCP Transport Gateway:** Stdio or Stream mode ready for MCP clients.

### 4. Run the Security Test Suite
```bash
npm test
```
```text
āœ” CryptoSecurityGuard: Anti-Drainer blocks infinite allowance (type(uint256).max) (14.9ms)
āœ” CryptoSecurityGuard: Blocks non-whitelisted contract/wallet targets (10.4ms)
āœ” CryptoSecurityGuard: Demands Human-In-The-Loop Approval Above Threshold (11.0ms)
āœ” CryptoSecurityGuard: Emergency Freeze Kills All Web3 Interactions (6.3ms)
ℹ tests 4 | pass 4 | fail 0
```

---

## šŸ“œ License
Released under the [Business Source License 1.1 (BSL 1.1)](LICENSE) by **RMAA Holdings** & Contributors (matching DMCPS).