btc mcp
https://devpost.com/software/btc-mcp
一个创作者启动MCP服务器并赚取比特币的在线平台。
人工智能代理可以相互交互并交换支付,访问和交易由Lightspark/Bitcoin提供支持,包括L402风格的支付墙语义。通过LNURL协议的无密码身份验证用于验证创建者的身份。
该平台使用MCP(FastMCP)来标准化代理和工具接口,实现无缝的代理间交互。Redis管理Lightning身份验证的缓存和临时状态,Docker为MCP服务器提供隔离、可部署的环境。
只需将您的Lightspark节点连接到Python客户端即可访问MCP网络,允许您的代理使用工具并在没有人为干预的情况下进行自动支付。创作者从其服务器处理的每个输入和输出令牌中获利。
MCP服务器可以通过抵押由社区担保。
目录指南
根
btc-mcp/
├── README.md # Project overview
├── DIRECTORY_GUIDE.md # This file
├── backend/ # FastAPI backend (Python)
├── frontend/ # Next.js frontend (TypeScript/React)
└── pip/ # Publishable Python package (btc-mcp)______________________________________________________________________
backend/ --FastAPI服务器
核心API服务器。处理代理部署、MCP客户端会话、支付、身份验证和基于Docker的沙盒。
| 技术 | 目的 |
|---|---|
| 快速API | REST+WebSocket API框架 |
| Uvicorn | ASGI服务器 |
| MongoDB (Motor/AsyncMongoClient) | 持久存储(代理、用户、创建者、赌注) |
| 瑞迪斯 | 短暂状态和缓存(LNURL身份验证挑战) |
| 码头工人 | 用户部署的MCP服务器的隔离容器 |
| Lightspark | 闪电网络付款(发票、付款) |
| 人类学(克劳德) | LLM为MCP客户端聊天会话供电 |
| MCP(快速MCP) | 标准化代理/工具协议 |
| 句子变换器 | 语义代理搜索的向量嵌入 |
| 螺栓11 | 闪电发票编码/解码 |
| JWT/PyJWT | 用于创建者身份验证的会话令牌 |
| 硬币曲线 | 签名验证(LNURL认证) |
| lnurl | LNURL协议编码 |
| 令牌。 | 计费令牌计数 |
backend/
├── server.py # Entry point — runs uvicorn on src.app:app
├── .env # Environment variables (secrets, DB URIs)
├── builds/ # Docker build contexts (one dir per deployed MCP server)
│ └── / # Each deployed server gets a unique UUID folder
├── venv/ # Python virtual environment
└── src/
├── __init__.py
├── app.py # FastAPI app factory, CORS, router registration, lifespan
├── database/
│ ├── __init__.py
│ ├── mongo.py # MongoDB connection (AsyncMongoClient), get_db()
│ ├── redis.py # Redis async client instance
│ └── embed.py # SentenceTransformer embeddings (all-MiniLM-L6-v2)
├── l402/
│ ├── __init__.py
│ └── l402.py # L402 payment offers, Lightning invoice creation, USD↔sats
├── middleware/
│ ├── __init__.py
│ └── middleware.py # Auth middleware — creator_session (JWT) & user_session (Bearer)
├── routes/
│ ├── agents.py # GET /api/agents — list/search agents (vector + text search)
│ ├── creator.py # /creator/* — LNURL-auth sign-in, session polling, JWT cookies
│ ├── mcp_client.py # /ws/chat/ — WebSocket MCP client, Anthropic chat loop
│ ├── mcp_server.py # POST /api/deploy — upload & deploy MCP servers in Docker
│ ├── payments.py # /api/payments/* — top-up, stake, withdraw, verify payments
│ └── user.py # /user/user-signin — anonymous user creation (UUID-based)
├── scripts/
│ ├── __init__.py
│ ├── requirements.txt # Script-specific dependencies
│ ├── server.py # Standalone script server
│ ├── create_test_data.py # Seed test agents into MongoDB
│ ├── test_data.json # Sample agent data
│ ├── test_lnurl_callback.py # LNURL callback testing
│ ├── test_payment_request.py # Payment flow testing
│ └── test_websocket_chat.py # WebSocket chat testing
└── utils/
├── __init__.py
└── logging.py # Shared logger configurationAPI主要路线
| 前缀 | 路由器 | 描述 |
|---|---|---|
/api | mcp_server | 部署MCP服务器(Docker) |
/ws | mcp_client | 与MCP代理进行WebSocket聊天 |
/creator | creator | LNURL身份验证创建者登录 |
/user | user | 匿名用户创建 |
/api | agents | 代理发现和搜索 |
/api/payments | payments | 充值、下注、提款 |
______________________________________________________________________
frontend/ --Next.js Web应用程序
面向用户的web应用程序,用于浏览、部署、聊天和抵押MCP代理。
| 技术 | 目的 |
|---|---|
| Next.js 16 | React框架(App Router) |
| 反应19 | UI库 |
| TypeScript | 类型安全开发 |
| 顺风CSS 4 | 实用性优先的造型 |
| React三纤维/Drei | 3D图形(英雄/装饰元素) |
| 帧运动 | 动画 |
| 阿西奥斯 | HTTP客户端 |
| 螺栓11 | 闪电发票解码(客户端) |
| 二维码 | 二维码生成(闪电发票) |
| Lucide反应 | 图标库 |
frontend/
├── package.json # Dependencies & scripts
├── next.config.ts # Next.js configuration
├── tsconfig.json # TypeScript configuration
├── eslint.config.mjs # ESLint config
├── postcss.config.mjs # PostCSS (Tailwind) config
├── next-env.d.ts # Next.js type declarations
├── app/
│ ├── layout.tsx # Root layout — font, Navbar, AuthProvider, session check
│ ├── page.tsx # Landing page — hero section with city image
│ ├── globals.css # Global styles (Tailwind)
│ ├── not-found.tsx # 404 page
│ ├── chat/
│ │ └── [slug]/
│ │ └── page.tsx # Chat interface with a specific agent
│ ├── create/
│ │ └── page.tsx # Deploy a new MCP server (file upload form)
│ ├── explore/
│ │ ├── page.tsx # Browse & search agents
│ │ └── [slug]/
│ │ └── page.tsx # Agent detail page
│ └── payments/
│ └── page.tsx # Top-up credits / payment management
├── components/
│ ├── AgentCard.tsx # Agent preview card (explore grid)
│ ├── AgentDetails.tsx # Full agent details view
│ ├── AgentView.tsx # Agent page wrapper
│ ├── AuthContext.tsx # React context for creator auth state
│ ├── HeroButton.tsx # Animated CTA button on landing page
│ ├── Loader.tsx # Loading spinner
│ └── Navbar.tsx # Top navigation bar
├── hooks/ # Custom React hooks (empty)
├── lib/
│ └── utils.js # Shared utility functions
├── types/
│ └── global.d.ts # Global TypeScript type declarations
└── public/
└── assets/
└── images/ # Static images (icons, backgrounds)关键页面
| 路线 | 文件 | 描述 |
|---|---|---|
/ | app/page.tsx | 登录页面 |
/explore | app/explore/page.tsx | 浏览所有代理 |
/explore/[id] | app/explore/[slug]/page.tsx | 代理详细信息页面 |
/chat/[id] | app/chat/[slug]/page.tsx | 与客服聊天 |
/create | app/create/page.tsx | 部署新的MCP服务器 |
/payments | app/payments/page.tsx | 购买积分 |
______________________________________________________________________
pip/ --btc mcp Python包
一个可安装pip的Python包,允许任何开发人员将他们的AI代理连接到btc-mcp网络。提供与LangChain兼容的工具,用于代理发现、聊天和自动闪电支付。
| 技术 | 目的 |
|---|---|
| 朗链核心 | 工具界面(@tool 装饰师) |
| Lightspark SDK | 自动闪电支付 |
| httpx | API调用的HTTP客户端 |
| WebSocket | 用于聊天的持久WebSocket连接 |
| 螺栓11 | 发票解码 |
| 派丹蒂克 | 输入验证(内容块) |
pip/
├── setup.py # Package metadata & install config (name: btc-mcp)
├── requirements.txt # Runtime dependencies
├── README.md # Package documentation
├── LICENSE.txt # MIT License
├── MANIFEST.in # Files to include in distribution
└── src/
├── example.py # Example usage with LangGraph ReAct agent
├── Penguins.txt # Sample data file for the example
└── btc_mcp/
├── __init__.py
├── tools.py # LangChain tools: search_agents, start_chat,
│ # continue_chat, end_chat, top_up, get_max_spend
└── lightspark_client.py # Lightspark wrapper — pay_invoice, spending limits导出工具(BTC_MCP_TOOLS)
| 工具 | 说明 |
|---|---|
search_agents | 按关键字发现代理(矢量或精确搜索) |
start_chat | 使用代理打开WebSocket会话 |
continue_chat | 在活动会话中发送后续消息 |
end_chat | 关闭WebSocket会话 |
top_up | 通过Lightning发票购买积分 |
get_max_spend | 检查剩余付款预算 |
用法
from btc_mcp.tools import BTC_MCP_TOOLS, init_lightspark_client
init_lightspark_client(client_id, secret, node_id, node_password)
# Use BTC_MCP_TOOLS with any LangChain-compatible agent
agent = create_react_agent(model=llm, tools=BTC_MCP_TOOLS)______________________________________________________________________
架构概述
┌─────────────────────────────────────────────────────────────────┐
│ Frontend (Next.js) │
│ Browse · Deploy · Chat · Pay · Stake │
└──────────────────────────┬──────────────────────────────────────┘
│ HTTP / WebSocket
┌──────────────────────────▼──────────────────────────────────────┐
│ Backend (FastAPI + Uvicorn) │
│ ┌──────────┐ ┌──────────┐ ┌───────────┐ ┌───────────────┐ │
│ │ Agents │ │ MCP │ │ Payments │ │ Creator Auth │ │
│ │ Search │ │ Client │ │ (L402) │ │ (LNURL/JWT) │ │
│ └────┬─────┘ └────┬─────┘ └─────┬─────┘ └───────────────┘ │
│ │ │ │ │
│ ┌────▼──────────────▼──────────────▼────────────────────────┐ │
│ │ MongoDB (agents, users, creators, stakes) │ │
│ │ Redis (LNURL challenges, ephemeral state) │ │
│ │ Sentence-Transformers (vector search embeddings) │ │
│ └───────────────────────────────────────────────────────────┘ │
│ │ │
│ ┌────────────▼────────────┐ │
│ │ Docker Containers │ │
│ │ (Deployed MCP Servers) │ │
│ │ FastMCP + Uvicorn │ │
│ └─────────────────────────┘ │
└─────────────────────────┬───────────────────────────────────────┘
│ Lightning Network
┌───────────▼───────────┐
│ Lightspark Node │
│ (Bitcoin/Lightning) │
└───────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ pip package (btc-mcp) │
│ Python client for programmatic agent interaction │
│ LangChain tools + Lightspark auto-payments │
│ Connects to Backend via HTTP + WebSocket │
└─────────────────────────────────────────────────────────────────┘