MCP Bitcoin CLI
Enables interaction with Bitcoin's blockchain through Claude to embed and read data using OP_RETURN, create timestamps, deploy BRC-20 tokens, and store documents up to 100KB on-chain.
README
<p align="center"> <h1 align="center">MCP Bitcoin CLI</h1> <p align="center"> <strong>Embed and read data on the Bitcoin blockchain through Claude</strong> </p> <p align="center"> <a href="https://github.com/EricGrill/mcp-bitcoin-cli/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT License"></a> <img src="https://img.shields.io/badge/tools-16-green.svg" alt="16 Tools"> <img src="https://img.shields.io/badge/OP__RETURN-100KB-orange.svg" alt="OP_RETURN 100KB"> <img src="https://img.shields.io/badge/python-%3E%3D3.11-blue.svg" alt="Python >= 3.11"> </p> <p align="center"> <a href="#-quick-start">Quick Start</a> | <a href="#-available-tools">Tools</a> | <a href="#%EF%B8%8F-configuration">Configuration</a> | <a href="#-contributing">Contributing</a> </p> </p>
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?
| Feature | Description |
|---|---|
| Document Storage | Embed documents up to 100KB directly on-chain |
| Timestamping | Create immutable SHA-256/SHA3 hash commitments |
| BRC-20 Tokens | Deploy, mint, and transfer tokens using the BRC-20 standard |
| Custom Protocols | Build your own OP_RETURN protocols with the BTCD envelope format |
| Offline-Capable | Encode/decode data without a running Bitcoin node |
| Safety First | Testnet default, dry-run mode, fee warnings |
Available Tools
Low-Level Primitives
Offline-capable tools for data encoding and transaction building.
| Tool | Description |
|---|---|
encode_op_return |
Encode arbitrary data into OP_RETURN script format |
decode_op_return |
Parse and extract data from OP_RETURN scripts |
build_op_return_transaction |
Construct transactions with OP_RETURN outputs |
parse_envelope |
Parse BTCD envelope structure from raw bytes |
Bitcoin Core Interface
Tools for interacting with a running Bitcoin node.
| Tool | Description |
|---|---|
get_node_info |
Check connection status and network info |
list_utxos |
List available UTXOs for funding transactions |
broadcast_transaction |
Send signed transactions (dry-run by default) |
get_transaction |
Fetch and decode transaction details |
search_op_returns |
Scan blocks for OP_RETURN transactions |
Token Operations (BRC-20)
Create and manage tokens using the BRC-20 standard.
| Tool | Description |
|---|---|
create_token_deploy |
Deploy a new BRC-20 token |
create_token_mint |
Mint tokens from an existing deployment |
create_token_transfer |
Create a transfer inscription |
Document Storage
Store and retrieve documents on the blockchain.
| Tool | Description |
|---|---|
embed_document |
Prepare documents for on-chain storage |
read_document |
Parse and extract documents from transactions |
Timestamping & Attestation
Create cryptographic proofs of existence.
| Tool | Description |
|---|---|
create_timestamp |
Create SHA-256/SHA3 hash commitments |
verify_timestamp |
Verify 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 │
└──────────┴──────────┴──────────┴────────────────────────┘
| Type | Hex | Description |
|---|---|---|
| RAW | 0x00 |
Raw bytes, no structure |
| TEXT | 0x01 |
UTF-8 text |
| JSON | 0x02 |
JSON document |
| HASH | 0x03 |
Hash commitment (timestamp) |
| TOKEN | 0x04 |
Token operation (BRC-20) |
| FILE | 0x05 |
File with content-type |
| CUSTOM | 0x80+ |
User-defined protocols |
Configuration
Claude Desktop Setup
Add to your Claude Desktop config:
| Platform | Config 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
| Network | Default RPC Port |
|---|---|
| Mainnet | 8332 |
| Testnet | 18332 |
| Signet | 38332 |
| Regtest | 18443 |
Examples
<details> <summary><b>Timestamping</b></summary>
"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"
</details>
<details> <summary><b>Document Storage</b></summary>
"Embed this JSON configuration on the blockchain"
"Store this text document with content-type text/plain"
"Read the document from transaction def456..."
</details>
<details> <summary><b>BRC-20 Tokens</b></summary>
"Deploy a new token called TEST with max supply 21 million"
"Mint 1000 TEST tokens"
"Create a transfer inscription for 500 TEST"
</details>
<details> <summary><b>Raw Data</b></summary>
"Encode this hex data into an OP_RETURN script"
"Decode the OP_RETURN from this transaction"
"Build a transaction with this message embedded"
</details>
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
| Feature | Description |
|---|---|
| Testnet Default | Network locked to testnet unless explicitly configured |
| Dry-Run Mode | Transactions validated before broadcast by default |
| Fee Warnings | Alerts for unusually high fees |
| Size Validation | Rejects data exceeding configured max before building |
| Network Lock | Can'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
<details> <summary><b>Cannot connect to Bitcoin Core</b></summary>
- Verify Bitcoin Core is running:
bitcoin-cli getblockchaininfo - Check network matches config (testnet vs mainnet)
- Verify RPC credentials if using JSON-RPC mode
</details>
<details> <summary><b>Transaction rejected</b></summary>
- Use
broadcast_transactionwithdry_run=truefirst - Check fee rate is sufficient
- Verify UTXOs have enough confirmations
</details>
<details> <summary><b>Data too large</b></summary>
- Bitcoin Core v30+ supports up to ~100KB OP_RETURN
- Older versions limited to 80 bytes
- Check
max_data_sizein config
</details>
<details> <summary><b>Import errors</b></summary>
# Verify installation
python -c "import mcp_bitcoin_cli; print(mcp_bitcoin_cli.__version__)"
# Reinstall if needed
pip install -e ".[dev]"
</details>
Contributing
Contributions welcome!
- Fork the repository
- Create feature branch:
git checkout -b feature/my-feature - Make changes and test:
pytest - Commit:
git commit -m 'Add my feature' - Push:
git push origin feature/my-feature - Open a Pull Request
Related Projects
- MCP Proxmox Admin - Manage Proxmox VE through Claude
- Model Context Protocol - The protocol specification
- BRC-20 Standard - Bitcoin token standard
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。