Real-time and historical Bitcoin network data via mempool.space API
MCP Mempool ๐
๋นํธ์ฝ์ธ mempool.space WebSocket & REST API๋ฅผ ์ํ Model Context Protocol (MCP) ์๋ฒ
๐ ๊ฐ์
MCP Mempool์ mempool.space์ WebSocket๊ณผ REST API๋ฅผ MCP (Model Context Protocol) ํํ๋ก ๋ํํ์ฌ AI Agent์ ์ธ๋ถ ์ ํ๋ฆฌ์ผ์ด์ ์ด ๋นํธ์ฝ์ธ ๋คํธ์ํฌ ๋ฐ์ดํฐ๋ฅผ ์ฝ๊ฒ ํ์ฉํ ์ ์๋๋ก ํ๋ ์๋ฒ์ ๋๋ค.
โจ ์ฃผ์ ๊ธฐ๋ฅ
๐ WebSocket ๊ธฐ๋ฅ (์ค์๊ฐ)
- ์ค์๊ฐ ๋ธ๋ก ๋ฐ์ดํฐ: ์ ๋ธ๋ก ์์ฑ ์ ์ฆ์ ์๋ฆผ
- ๋ฉคํ ๋ธ๋ก ํ ํ๋ฆฟ: ์์๋๋ ๋ค์ ๋ธ๋ก ์ ๋ณด
- ๋คํธ์ํฌ ํต๊ณ: ๋ฉ๋ชจ๋ฆฌํ ์ํ ์ค์๊ฐ ๋ชจ๋ํฐ๋ง
- ์ฃผ์ ์ถ์ : ํน์ ๋นํธ์ฝ์ธ ์ฃผ์์ ๊ฑฐ๋ ์ค์๊ฐ ์ถ์
- ๋ผ์ด๋ธ ์ฐจํธ: ์์๋ฃ ๋ณํ ์ถ์ด ์ค์๊ฐ ๋ฐ์ดํฐ
๐ REST API ๊ธฐ๋ฅ (์ฟผ๋ฆฌ)
- ์ฃผ์ ์ ๋ณด ์กฐํ: ์์ก, ๊ฑฐ๋ ๋ด์ญ, UTXO ๋ชฉ๋ก
- ๊ฑฐ๋ ์ ๋ณด: ๊ฐ๋ณ ๊ฑฐ๋ ์์ธ ์ ๋ณด ๋ฐ ์ํ
- ๋ธ๋ก ๋ฐ์ดํฐ: ๋ธ๋ก ์ ๋ณด, ๊ฑฐ๋ ๋ชฉ๋ก, ์ต์ ๋์ด
- ์์๋ฃ ์ ๋ณด: ์ถ์ฒ ์์๋ฃ์จ, ๋ฉคํ ๋ธ๋ก๋ณ ์์๋ฃ
- ๋ฉคํ ์ํ: ํ์ฌ ๋ฉคํ ์ ๋ณด ๋ฐ ์ต๊ทผ ๊ฑฐ๋
- ์ฃผ์ ๊ฒ์ฆ: ๋นํธ์ฝ์ธ ์ฃผ์ ์ ํจ์ฑ ๊ฒ์ฌ
๐ ๋น ๋ฅธ ์์
Docker๋ก ์คํ (๊ถ์ฅ)
# ๊ฐ๋ฐ ํ๊ฒฝ
docker-compose up mcp-mempool-dev
# ํ๋ก๋์
ํ๊ฒฝ
docker-compose up mcp-mempool-prod
์๋ฒ๊ฐ ์คํ๋๋ฉด http://localhost:8000 ์์ ์ ๊ทผ ๊ฐ๋ฅํฉ๋๋ค.
๋ก์ปฌ ์ค์น
# ์์กด์ฑ ์ค์น
uv sync
# ์๋ฒ ์คํ
uv run python -m mempool_ws_mcp_server.main
๐ง ํ๊ฒฝ ๋ณ์ ์ค์
# ์๋ฒ ์ค์
MCP_HOST=0.0.0.0 # ์๋ฒ ํธ์คํธ
MCP_PORT=8000 # ์๋ฒ ํฌํธ
LOG_LEVEL=INFO # ๋ก๊ทธ ๋ ๋ฒจ
# Mempool API ์ค์
MEMPOOL_WS_URL=wss://mempool.space/api/v1/ws # WebSocket URL
MEMPOOL_API_URL=https://mempool.space/api # REST API URL
# WebSocket ์ค์
WS_RECONNECT_INTERVAL=5 # ์ฌ์ฐ๊ฒฐ ๊ฐ๊ฒฉ (์ด)
WS_MAX_RECONNECT_ATTEMPTS=10 # ์ต๋ ์ฌ์ฐ๊ฒฐ ์๋
WS_PING_INTERVAL=30 # Ping ๊ฐ๊ฒฉ (์ด)
WS_PING_TIMEOUT=10 # Ping ํ์์์ (์ด)
# HTTP ํด๋ผ์ด์ธํธ ์ค์
HTTP_TIMEOUT=30 # HTTP ์์ฒญ ํ์์์ (์ด)
HTTP_MAX_RETRIES=3 # ์ต๋ ์ฌ์๋ ํ์
# ์ฑ๋ฅ ์ค์
MAX_MESSAGE_QUEUE_SIZE=1000 # ๋ฉ์์ง ํ ์ต๋ ํฌ๊ธฐ
MESSAGE_BATCH_SIZE=10 # ๋ฉ์์ง ๋ฐฐ์น ํฌ๊ธฐ
# ๋ณด์ ์ค์
CORS_ENABLED=true # CORS ํ์ฑํ
ALLOWED_ORIGINS=* # ํ์ฉ๋ ์ค๋ฆฌ์ง (์ฝค๋ง ๊ตฌ๋ถ)
# ๊ฐ๋ฐ ๋ชจ๋
DEBUG=false # ๋๋ฒ๊ทธ ๋ชจ๋
RELOAD=false # ์๋ ์ฌ์์
๐ MCP ํด๋ผ์ด์ธํธ ์ค์
Claude Desktop
claude_desktop_config.json ํ์ผ์ ์ถ๊ฐ:
{
"mcpServers": {
"mcp-mempool": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:8000/mcp"]
}
}
}
{
"mcpServers": {
"mcp-mempool": {
"transport": "streamable-http",
"url" : "http://127.0.0.1:8000/mcp" //๋ฐฐํฌ์ ์ค์ ์๋น url
}
}
}
Amazon Q Developer
.aws/amazonq/mcp.json ํ์ผ์ ์ถ๊ฐ:
{
"mcpServers": {
"mcp-mempool": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:8000/mcp"],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
}
}
}
}
๐ก ์ฌ์ฉ ๊ฐ๋ฅํ ๋๊ตฌ๋ค
WebSocket ๋๊ตฌ (์ค์๊ฐ ์คํธ๋ฆฌ๋ฐ)
`subscribe_blocks`
์ ๋ธ๋ก ์์ฑ ์ ์ค์๊ฐ ์๋ฆผ์ ๋ฐ์ต๋๋ค.
`subscribe_mempool_blocks`
์์๋๋ ๋ค์ ๋ธ๋ก ํ ํ๋ฆฟ ์ ๋ณด๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ฐ์ต๋๋ค.
`subscribe_stats`
๋คํธ์ํฌ ๋ฉ๋ชจ๋ฆฌํ ํต๊ณ๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ชจ๋ํฐ๋งํฉ๋๋ค.
`subscribe_live_chart`
2์๊ฐ ๋ผ์ด๋ธ ์์๋ฃ ์ฐจํธ ๋ฐ์ดํฐ๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ฐ์ต๋๋ค.
`track_address`
ํน์ ๋นํธ์ฝ์ธ ์ฃผ์์ ๊ฑฐ๋๋ฅผ ์ค์๊ฐ์ผ๋ก ์ถ์ ํฉ๋๋ค.
address: ์ถ์ ํ ๋นํธ์ฝ์ธ ์ฃผ์
`get_connection_status`
WebSocket ์ฐ๊ฒฐ ์ํ๋ฅผ ํ์ธํฉ๋๋ค.
`unsubscribe_client`
ํด๋ผ์ด์ธํธ์ ๋ชจ๋ ๊ตฌ๋ ์ ํด์ ํฉ๋๋ค.
client_id: ๊ตฌ๋ ํด์ ํ ํด๋ผ์ด์ธํธ ID
REST API ๋๊ตฌ (์ฟผ๋ฆฌ)
์ฃผ์ ๊ด๋ จ
get_address_info - ์ฃผ์์ ๋ชจ๋ ์ ๋ณด ์กฐํ
address: ๋นํธ์ฝ์ธ ์ฃผ์
get_address_balance - ์ฃผ์ ์์ก ์กฐํ
address: ๋นํธ์ฝ์ธ ์ฃผ์
get_address_utxos - ์ฃผ์์ UTXO ๋ชฉ๋ก ์กฐํ
address: ๋นํธ์ฝ์ธ ์ฃผ์
get_address_transactions - ์ฃผ์์ ๊ฑฐ๋ ๋ด์ญ ์กฐํ
address: ๋นํธ์ฝ์ธ ์ฃผ์after_txid(์ ํ): ํน์ ๊ฑฐ๋ ์ดํ์ ๊ฑฐ๋๋ค๋ง ์กฐํ
๊ฑฐ๋ ๊ด๋ จ
get_transaction_info - ๊ฑฐ๋ ์ ๋ณด ์กฐํ
txid: ๊ฑฐ๋ ID
get_block_info - ๋ธ๋ก ์ ๋ณด ์กฐํ
hash_or_height: ๋ธ๋ก ํด์ ๋๋ ๋์ด
get_block_height - ํ์ฌ ๋ธ๋ก ๋์ด ์กฐํ
์์๋ฃ & ๋ฉคํ
get_recommended_fees - ์ถ์ฒ ์์๋ฃ์จ ์กฐํ
get_mempool_info - ํ์ฌ ๋ฉคํ ์ ๋ณด ์กฐํ
์ ํธ๋ฆฌํฐ
validate_bitcoin_address - ๋นํธ์ฝ์ธ ์ฃผ์ ์ ํจ์ฑ ๊ฒ์ฌ
address: ๊ฒ์ฆํ ์ฃผ์
๐ป ์ฌ์ฉ ์์
์ฃผ์ ์์ก ์กฐํ
# MCP ํด๋ผ์ด์ธํธ์์ ์ฌ์ฉ
get_address_balance address="1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
์ค์๊ฐ ์์๋ฃ ๋ชจ๋ํฐ๋ง
# ์ค์๊ฐ ๋ฉคํ ๋ธ๋ก ๊ตฌ๋
subscribe_mempool_blocks
# ์ถ์ฒ ์์๋ฃ ์กฐํ
get_recommended_fees
์ฃผ์ ์ถ์
# ํน์ ์ฃผ์ ์ค์๊ฐ ์ถ์
track_address address="1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
๐ ๊ฐ๋ฐ
๊ฐ๋ฐ ํ๊ฒฝ ์ค์
# ํ๋ก์ ํธ ํด๋ก
git clone <repository-url>
cd mcp-mempool
# ๊ฐ๋ฐ ์์กด์ฑ ์ค์น
uv sync --dev
# ๊ฐ๋ฐ ์๋ฒ ์คํ
uv run python -m mempool_ws_mcp_server.main
ํ ์คํธ ์คํ
# ๋ชจ๋ ํ
์คํธ ์คํ
uv run pytest
# ์ปค๋ฒ๋ฆฌ์ง ํฌํจ
uv run pytest --cov=mempool_ws_mcp_server
์ฝ๋ ํ์ง ๋๊ตฌ
# ๋ฆฐํ
uv run ruff check .
# ํฌ๋งทํ
uv run ruff format .
# ํ์
์ฒดํฌ
uv run mypy src/
๐ณ Docker ๋น๋
# ์ด๋ฏธ
Tools (17)
subscribe_blocksReceive real-time notifications when new blocks are created.subscribe_mempool_blocksGet real-time information on expected next block templates.subscribe_statsMonitor network mempool statistics in real-time.subscribe_live_chartReceive real-time 2-hour live fee chart data.track_addressTrack transactions for a specific Bitcoin address in real-time.get_connection_statusCheck the WebSocket connection status.unsubscribe_clientUnsubscribe all subscriptions for a client.get_address_infoRetrieve all information for a specific Bitcoin address.get_address_balanceCheck the balance of a Bitcoin address.get_address_utxosRetrieve the list of UTXOs for an address.get_address_transactionsRetrieve transaction history for an address.get_transaction_infoRetrieve detailed information and status for a specific transaction ID.get_block_infoRetrieve block information by hash or height.get_block_heightRetrieve the current block height.get_recommended_feesRetrieve recommended fee rates.get_mempool_infoRetrieve current mempool information.validate_bitcoin_addressValidate a Bitcoin address.Environment Variables
MCP_HOSTServer host addressMCP_PORTServer portMEMPOOL_WS_URLWebSocket URL for mempool.spaceMEMPOOL_API_URLREST API URL for mempool.spaceConfiguration
{
"mcpServers": {
"mcp-mempool": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:8000/mcp"]
}
}
}