๐ BTCPayServer Model Context Protocol Server (Beta)
A comprehensive Model Context Protocol (MCP) server for BTCPayServer integration, offering tools for payment processing, store management, user administration, webhook handling, etc., with full API coverage.
๐ Quick Start
The BTCPayServer MCP Server is a powerful tool for interacting with BTCPayServer APIs. It provides a set of streamlined tools and access to the complete API ecosystem of BTCPayServer.
โจ Features
- Full API Coverage: Offers a wide range of tools for interacting with BTCPayServer APIs, covering payment processing, store management, user administration, and more.
- AI Assistant Integration: Supports integration with AI assistants like Claude Desktop.
- Comprehensive Service Catalog: Provides access to all services in the BTCPayServer API ecosystem.
- Error Handling: Offers comprehensive error handling for various scenarios.
๐ฆ Installation
- Clone this repository:
git clone <repository-url>
cd btcpayserver-mcp
- Install dependencies:
npm install
- Build the project:
npm run build
๐ป Usage Examples
Basic Usage
The following steps show how to interact with the BTCPayServer API through MCP:
1. Discover: Use get_service_info to explore available methods
get_service_info(serviceName: "invoices")
2. Understand: Use get_method_info to learn parameter requirements
get_method_info(serviceName: "invoices", methodName: "create")
3. Execute: Use btcpay_request to perform the operation
btcpay_request(serviceName: "invoices", methodName: "create", parameters: {storeId: "your-store-id", amount: "10.00", currency: "USD"})
Running the MCP Server
npm start
For development:
npm run dev
Development and Debugging
Using MCP Inspector:
The MCP Inspector provides a visual interface for testing:
npm run build
npx @modelcontextprotocol/inspector node dist/index.js
Development Workflow:
- Clone the repository
- Install dependencies:
npm install
- Start development mode:
npm run build
- Run the server:
node dist/index.js
- Test your changes using the MCP Inspector
๐ Documentation
Tool Reference
The BTCPayServer MCP Server provides a streamlined set of tools for interacting with BTCPayServer APIs:
| Tool |
Description |
Primary Use |
get_service_info |
Discover methods available for a service |
Exploration and discovery |
get_method_info |
Get detailed parameter requirements |
Request preparation |
btcpay_request |
Execute API calls to BTCPayServer |
Performing operations |
Integration with AI Assistants
Claude Desktop Integration
For Claude Desktop integration, add this configuration to your claude_desktop_config.json:
{
"mcpServers": {
"btcpayserver-mcp": {
"command": "node",
"args": ["path/to/btcpayserver-mcp/dist/index.js"],
"env": {
"BTCPAY_BASE_URL": "https://your-btcpay-instance.com",
"BTCPAY_API_KEY": "your_api_key_here",
"BTCPAY_STORE_ID": "your_default_store_id"
}
}
}
}
Service Catalog
BTCPayServer MCP provides access to BTCPayServer's complete API ecosystem. Check out the BTCPayServer API Documentation for detailed information about each service:
Payment Services
| Service |
Description |
invoices |
Create, manage, and track Bitcoin invoices for payments |
payment-requests |
Create payment requests for donations or recurring billing |
lightning-internal |
Manage internal Lightning Network operations |
lightning-store |
Store-level Lightning Network configurations |
lightning-address |
Lightning Address management and setup |
Store Management
| Service |
Description |
stores |
Store creation, configuration, and management |
stores-email |
Configure and manage store email settings and SMTP |
stores-payment-methods |
Manage available payment methods for stores |
stores-payout-processors |
Configure automated payout processing |
stores-payouts |
Manage and process store payouts |
stores-rates |
Exchange rate configuration and management |
stores-users |
Store user access and permissions management |
stores-wallet |
Store wallet management and operations |
User & Access Management
| Service |
Description |
users |
User account management and administration |
api-keys |
API key creation and permission management |
authorization |
OAuth and authorization flow management |
Integration & Automation
| Service |
Description |
webhooks |
Real-time event notifications and webhook management |
notifications |
System notifications and alerts |
apps |
BTCPayServer app integrations and plugins |
pull-payments |
Pull payment requests and refund management |
System
| Service |
Description |
server-info |
Server status, version, and configuration information |
Configuration
The MCP server requires the following environment variables:
BTCPAY_BASE_URL - Your BTCPayServer instance URL (e.g., https://btcpay.example.com)
BTCPAY_API_KEY - Your BTCPayServer API key
BTCPAY_STORE_ID - (Optional) Default store ID for operations
Setting up BTCPayServer API Key
- Log into your BTCPayServer instance
- Go to Account โ Manage Account โ API Keys
- Click Generate Key
- Select the required permissions for your use case:
- Store management:
btcpay.store.canmodifystoresettings
- Payment requests:
btcpay.store.cancreateinvoice
- User management:
btcpay.user.canmodifyprofile
- Webhooks:
btcpay.store.webhooks.canmodifywebhooks
- etc..
- Copy the generated API key
Environment Setup
Create a .env file in your project root:
BTCPAY_BASE_URL=https://your-btcpay-instance.com
BTCPAY_API_KEY=your_api_key_here
BTCPAY_STORE_ID=your_default_store_id
Or set environment variables directly:
export BTCPAY_BASE_URL=https://your-btcpay-instance.com
export BTCPAY_API_KEY=your_api_key_here
export BTCPAY_STORE_ID=your_default_store_id
๐ง Technical Details
Project Structure
src/
โโโ index.ts # Main MCP server implementation
โโโ services/ # BTCPayServer service implementations
โ โโโ base-service.ts # Base service class
โ โโโ invoices.ts # Invoice management
โ โโโ payment-requests.ts # Payment request handling
โ โโโ stores.ts # Store management
โ โโโ webhooks.ts # Webhook management
โ โโโ ... # Other service modules
โโโ utils/
โ โโโ btcpay-client.ts # BTCPayServer API client
โโโ types.ts # TypeScript type definitions
Building
npm run build
Running in Development
npm run dev
Error Handling
The MCP server provides comprehensive error handling:
- Configuration Errors: Missing environment variables
- API Errors: BTCPayServer API communication issues
- Validation Errors: Invalid input parameters
- Authentication Errors: Invalid or expired API keys
All errors are properly formatted and returned with descriptive messages.
๐ License
MIT License - see LICENSE file for details.
๐ก Usage Tip
- API Key Security: Never commit API keys to version control.
- Environment Variables: Use secure environment variable management.
- Webhook Secrets: Always use webhook secrets for verification.
- HTTPS: Ensure BTCPayServer instance uses HTTPS.
- Permissions: Use principle of least privilege for API key permissions.
โ ๏ธ Important Note
- Some methods might not be working properly. Please help us by reporting requirements and making pull requests to improve them. Also, to keep it up with the latest API version, we need to continue updating it.
- This MCP server is compatible with BTCPayServer v1.7.0 and later. It uses the official BTCPayServer REST API v1.
๐ค Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
๐ Support
For issues and questions:
- Check the BTCPayServer documentation
- Review the API reference
- Open an issue in this repository