MCP Hub
Back to servers

mcp-bitcoin-cli

Enables Claude to interact with Bitcoin's OP_RETURN functionality to embed documents, create on-chain timestamps, and manage BRC-20 tokens.

Tools
16
Updated
Jan 12, 2026

MCP Bitcoin CLI

Embed and read data on the Bitcoin blockchain through Claude

MIT License 16 Tools OP_RETURN 100KB Python >= 3.11

Quick Start | Tools | Configuration | Contributing


What is this?

An MCP (Model Context Protocol) server that enables Claude to interact with Bitcoin's OP_RETURN functionality. Store documents, create timestamps, deploy tokens, and build custom protocols—all through natural language.

Works with Claude Desktop, Cursor, and any MCP-compatible client.

Supports Bitcoin Core v30+ with up to ~100KB OP_RETURN data.


Quick Start

# Install from source
git clone https://github.com/EricGrill/mcp-bitcoin-cli.git
cd mcp-bitcoin-cli
pip install -e .

# Run the server
mcp-bitcoin-cli

Add to your Claude Desktop config and start working with Bitcoin:

"Create a timestamp for this document on Bitcoin testnet"


Why Use This?

FeatureDescription
Document StorageEmbed documents up to 100KB directly on-chain
TimestampingCreate immutable SHA-256/SHA3 hash commitments
BRC-20 TokensDeploy, mint, and transfer tokens using the BRC-20 standard
Custom ProtocolsBuild your own OP_RETURN protocols with the BTCD envelope format
Offline-CapableEncode/decode data without a running Bitcoin node
Safety FirstTestnet default, dry-run mode, fee warnings

Available Tools

Low-Level Primitives

Offline-capable tools for data encoding and transaction building.

ToolDescription
encode_op_returnEncode arbitrary data into OP_RETURN script format
decode_op_returnParse and extract data from OP_RETURN scripts
build_op_return_transactionConstruct transactions with OP_RETURN outputs
parse_envelopeParse BTCD envelope structure from raw bytes

Bitcoin Core Interface

Tools for interacting with a running Bitcoin node.

ToolDescription
get_node_infoCheck connection status and network info
list_utxosList available UTXOs for funding transactions
broadcast_transactionSend signed transactions (dry-run by default)
get_transactionFetch and decode transaction details
search_op_returnsScan blocks for OP_RETURN transactions

Token Operations (BRC-20)

Create and manage tokens using the BRC-20 standard.

ToolDescription
create_token_deployDeploy a new BRC-20 token
create_token_mintMint tokens from an existing deployment
create_token_transferCreate a transfer inscription

Document Storage

Store and retrieve documents on the blockchain.

ToolDescription
embed_documentPrepare documents for on-chain storage
read_documentParse and extract documents from transactions

Timestamping & Attestation

Create cryptographic proofs of existence.

ToolDescription
create_timestampCreate SHA-256/SHA3 hash commitments
verify_timestampVerify data against on-chain timestamps

Data Envelope Format

All data uses the BTCD envelope format for discoverability and proper parsing:

┌─────────────────────────────────────────────────────────┐
│ OP_RETURN Envelope (variable size, up to ~100KB)        │
├──────────┬──────────┬──────────┬────────────────────────┤
│ Magic    │ Version  │ Type     │ Payload                │
│ (4 bytes)│ (1 byte) │ (1 byte) │ (variable)             │
├──────────┼──────────┼──────────┼────────────────────────┤
│ "BTCD"   │ 0x01     │ See below│ Type-specific data     │
└──────────┴──────────┴──────────┴────────────────────────┘
TypeHexDescription
RAW0x00Raw bytes, no structure
TEXT0x01UTF-8 text
JSON0x02JSON document
HASH0x03Hash commitment (timestamp)
TOKEN0x04Token operation (BRC-20)
FILE0x05File with content-type
CUSTOM0x80+User-defined protocols

Configuration

Claude Desktop Setup

Add to your Claude Desktop config:

PlatformConfig Path
macOS~/Library/Application Support/Claude/claude_desktop_config.json
Windows%APPDATA%\Claude\claude_desktop_config.json
Linux~/.config/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "bitcoin": {
      "command": "mcp-bitcoin-cli",
      "env": {
        "BITCOIN_NETWORK": "testnet",
        "BITCOIN_CLI_PATH": "/usr/local/bin/bitcoin-cli"
      }
    }
  }
}

Configuration File

Create ~/.mcp-bitcoin-cli/config.toml:

[connection]
method = "cli"              # "cli" or "rpc"
network = "testnet"         # "mainnet", "testnet", "signet", "regtest"

[cli]
path = "bitcoin-cli"        # Path to bitcoin-cli binary
datadir = ""                # Optional: custom datadir

[rpc]
host = "127.0.0.1"
port = 18332                # Testnet default
user = ""
password = ""

[safety]
require_confirmation = true # Prompt before broadcast
dry_run_default = true      # Always dry-run first
max_data_size = 102400      # 100KB limit

Network Ports

NetworkDefault RPC Port
Mainnet8332
Testnet18332
Signet38332
Regtest18443

Examples

Timestamping
"Create a SHA-256 timestamp for this contract"
"Verify this document against timestamp in transaction abc123..."
"Create a SHA3-256 hash commitment for my research paper"
Document Storage
"Embed this JSON configuration on the blockchain"
"Store this text document with content-type text/plain"
"Read the document from transaction def456..."
BRC-20 Tokens
"Deploy a new token called TEST with max supply 21 million"
"Mint 1000 TEST tokens"
"Create a transfer inscription for 500 TEST"
Raw Data
"Encode this hex data into an OP_RETURN script"
"Decode the OP_RETURN from this transaction"
"Build a transaction with this message embedded"

Architecture

┌─────────────────────────────────────────────────────────┐
│                    MCP Server                           │
├─────────────────────────────────────────────────────────┤
│  High-Level Tools                                       │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐   │
│  │ BRC-20 Ops  │ │ Document    │ │ Timestamp/      │   │
│  │ deploy/mint │ │ Storage     │ │ Attestation     │   │
│  └──────┬──────┘ └──────┬──────┘ └────────┬────────┘   │
│         │               │                  │            │
│  ───────┴───────────────┴──────────────────┴─────────  │
│                                                         │
│  Low-Level Primitives                                   │
│  ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐   │
│  │ encode_     │ │ decode_     │ │ build_op_return │   │
│  │ op_return   │ │ op_return   │ │ _transaction    │   │
│  └─────────────┘ └─────────────┘ └─────────────────┘   │
├─────────────────────────────────────────────────────────┤
│  Bitcoin Core Interface (configurable)                  │
│  ┌──────────────────┐  ┌────────────────────────────┐  │
│  │ bitcoin-cli      │  │ JSON-RPC (direct)          │  │
│  │ (subprocess)     │  │                            │  │
│  └──────────────────┘  └────────────────────────────┘  │
└─────────────────────────────────────────────────────────┘

Safety Features

FeatureDescription
Testnet DefaultNetwork locked to testnet unless explicitly configured
Dry-Run ModeTransactions validated before broadcast by default
Fee WarningsAlerts for unusually high fees
Size ValidationRejects data exceeding configured max before building
Network LockCan't switch networks mid-session

Development

# Clone
git clone https://github.com/EricGrill/mcp-bitcoin-cli.git
cd mcp-bitcoin-cli

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

# Run tests
pytest -v

# Run tests with coverage
pytest --cov=mcp_bitcoin_cli

Project Structure

src/mcp_bitcoin_cli/
├── __init__.py          # Public exports
├── server.py            # MCP server with 16 tools
├── envelope.py          # BTCD envelope encoding/decoding
├── primitives.py        # OP_RETURN script encoding/decoding
├── config.py            # Configuration loading
├── node/
│   ├── interface.py     # Abstract node interface
│   ├── cli.py           # bitcoin-cli subprocess
│   └── rpc.py           # JSON-RPC direct connection
└── protocols/
    ├── base.py          # Base protocol class
    └── brc20.py         # BRC-20 token protocol

Troubleshooting

Cannot connect to Bitcoin Core
  1. Verify Bitcoin Core is running: bitcoin-cli getblockchaininfo
  2. Check network matches config (testnet vs mainnet)
  3. Verify RPC credentials if using JSON-RPC mode
Transaction rejected
  1. Use broadcast_transaction with dry_run=true first
  2. Check fee rate is sufficient
  3. Verify UTXOs have enough confirmations
Data too large
  • Bitcoin Core v30+ supports up to ~100KB OP_RETURN
  • Older versions limited to 80 bytes
  • Check max_data_size in config
Import errors
# Verify installation
python -c "import mcp_bitcoin_cli; print(mcp_bitcoin_cli.__version__)"

# Reinstall if needed
pip install -e ".[dev]"

Contributing

Contributions welcome!

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/my-feature
  3. Make changes and test: pytest
  4. Commit: git commit -m 'Add my feature'
  5. Push: git push origin feature/my-feature
  6. Open a Pull Request

Related Projects


License

MIT

Reviews

No reviews yet

Sign in to write a review