Back to MCP directory
publicPublicdnsLocal runtime

Bitcoin MCP Server

一个基于MCP协议的比特币与闪电网络交互服务器,支持密钥生成、地址验证、交易解码等功能。

article

README

🚀 Bitcoin - MCP 扩展

Bitcoin - MCP 扩展是一个用于比特币数据查询和处理的工具,它提供了便捷的接口来获取比特币的区块、交易等信息,同时支持闪电网络功能,能帮助开发者更高效地进行比特币相关开发。

🚀 快速开始

要使用 Bitcoin - MCP 扩展,请按照以下步骤操作:

1. 克隆仓库

首先,您需要从 GitHub 克隆 Bitcoin - MCP 仓库:

git clone https://github.com/abdelstark/bitcoin-mcp.git

2. 安装依赖项

进入项目目录后,安装所需的依赖项:

npm install

3. 配置设置

创建一个 config.json 文件,并添加以下内容:

{
  "network": "mainnet",    // 网络环境:mainnet、testnet 或 regtest
  "mempoolUrl": "http://localhost:8081" // Mempool Connect 实例 URL
}

4. 启动服务器

npm start

💻 使用示例

基础用法

查询比特币数据

示例 1:获取最新区块信息

输入命令:

curl http://localhost:3000/api/block/latest

输出结果:

{
  "height": 709642,
  "hash": "0000000000000000bda5f8c196a0e9d6931b8727e14ae195614ab14ed861efdf",
  "time": "2023-10-05T12:34:56Z",
  "difficulty": 2398721.456,
  "txCount": 2145
}
示例 2:查询交易详情

输入命令:

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"
    }
  ]
}

📚 详细文档

📦 开发设置

有关详细的开发设置,请参阅开发指南

Lightning 网络配置(可选)

要使用闪电网络功能,需要配置 LNBits 连接信息:

{
  "lnbits": {
    "url": "http://localhost:3000",
    "api_key": "your_api_key_here"
  }
}

🚫 错误处理

常见错误及解决方案:

  1. 无法连接到 Mempool Connect

    • 检查 mempoolUrl 是否正确。
    • 确保 Mempool Connect 实例正在运行。
  2. 404 页面未找到

    • 确认 API 路径和参数是否正确。
    • 查看服务器日志以获取更多错误信息。
  3. 内部服务器错误 (500)

    • 检查请求体格式是否符合要求。
    • 查看服务端日志以定位具体问题。

🤝 贡献指南

如何贡献代码:

  1. 克隆仓库git clone https://github.com/abdelstark/bitcoin-mcp.git
  2. 创建功能分支git checkout -b feature/new-feature
  3. 提交更改git add . && git commit -m '添加新特性'
  4. 推送并创建拉取请求git push origin feature/new-feature

如何报告问题:

  • 在 GitHub 仓库中创建新的问题(Issue)。
  • 提供详细的错误信息和复现步骤。

🛡️ 安全注意事项

⚠️ 重要提示

  • 避免在配置文件中明文存储敏感信息。建议使用环境变量或加密方式存储密钥。
  • 确保测试环境与生产环境网络隔离,防止数据泄露和未授权访问。

📄 许可证

本项目遵循 MIT 协议。请在使用或修改代码时遵守相关许可条款。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client