Bitcoin - MCP 扩展是一个用于比特币数据查询和处理的工具,它提供了便捷的接口来获取比特币的区块、交易等信息,同时支持闪电网络功能,能帮助开发者更高效地进行比特币相关开发。
要使用 Bitcoin - MCP 扩展,请按照以下步骤操作:
首先,您需要从 GitHub 克隆 Bitcoin - MCP 仓库:
git clone https://github.com/abdelstark/bitcoin-mcp.git
进入项目目录后,安装所需的依赖项:
npm install
创建一个 config.json 文件,并添加以下内容:
{
"network": "mainnet", // 网络环境:mainnet、testnet 或 regtest
"mempoolUrl": "http://localhost:8081" // Mempool Connect 实例 URL
}
npm start
输入命令:
curl http://localhost:3000/api/block/latest
输出结果:
{
"height": 709642,
"hash": "0000000000000000bda5f8c196a0e9d6931b8727e14ae195614ab14ed861efdf",
"time": "2023-10-05T12:34:56Z",
"difficulty": 2398721.456,
"txCount": 2145
}
输入命令:
curl http://localhost:3000/api/tx/abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890
输出结果:
{
"hash": "abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"size": 258,
"fee": 0.0015,
"vin": [
{
"txid": "1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s",
"vout_index": 1
}
],
"vout": [
{
"value": 0.5,
"script_pub_key": "OP_DUP OP_HASH160 ... OP_EQUALVERIFY OP_CHECKSIG"
},
{
"value": 0.4985,
"script_pub_key": "OP_HASH160 ... OP_EQUAL"
}
]
}
有关详细的开发设置,请参阅开发指南。
要使用闪电网络功能,需要配置 LNBits 连接信息:
{
"lnbits": {
"url": "http://localhost:3000",
"api_key": "your_api_key_here"
}
}
无法连接到 Mempool Connect
mempoolUrl 是否正确。404 页面未找到
内部服务器错误 (500)
git clone https://github.com/abdelstark/bitcoin-mcp.gitgit checkout -b feature/new-featuregit add . && git commit -m '添加新特性'git push origin feature/new-feature⚠️ 重要提示
- 避免在配置文件中明文存储敏感信息。建议使用环境变量或加密方式存储密钥。
- 确保测试环境与生产环境网络隔离,防止数据泄露和未授权访问。
本项目遵循 MIT 协议。请在使用或修改代码时遵守相关许可条款。