MCP Server Access
Integrate AI tools into your applications using the Model Context Protocol
What is MCP?
MCP (Model Context Protocol) is an open protocol developed by Anthropic that standardizes how AI applications connect to external data sources and tools. It enables AI assistants like Claude to seamlessly access services through a unified JSON-RPC interface.
- Standardized: Works with any MCP-compatible AI client or application.
- Pay-per-use: Lightning Network micropayments for each service call.
- No Accounts: Privacy-focused access without signup or KYC.
- Interoperable: Designed for AI-to-service communication.
By integrating MCP, Sats4AI provides a standardized way for AI agents and applications to access powerful AI services with Bitcoin payments.Learn more about MCP
API Endpoint
HTTP/JSON-RPC: https://sats4ai.com/api/mcp
Content-Type: application/json
Protocol Version: 2024-11-05
Payment Flow
- 1create_payment → Get Lightning invoice & paymentId
- 2Pay invoice → Using any Lightning wallet
- 3check_payment_status → Verify payment received (optional)
- 4Execute tool → Pass paymentId with your request
Step-by-Step Guide
Step 1: Initialize Connection
First, initialize the MCP connection. This establishes the protocol version and client capabilities.
curl -X POST https://sats4ai.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": { "name": "my-client", "version": "1.0.0" }
}
}'Step 2: List Available Tools (Optional)
You can list all available tools to see what services are offered and their parameters.
curl -X POST https://sats4ai.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}'Step 3: Create Payment
Before using a paid service, create a payment to get a Lightning invoice. Specify the tool you want to use and the model ID.
curl -X POST https://sats4ai.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "create_payment",
"arguments": {
"toolName": "generate_image",
"modelId": 1,
"quantity": 1
}
}
}'Response:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [{
"type": "text",
"text": "{
\"paymentId\": \"abc123\",
\"lightningInvoice\": \"lnbc...<LIGHTNING_INVOICE>\",
\"amountSats\": 50,
\"expiresAt\": \"2024-01-01T12:00:00Z\"
}"
}]
}
}Save the paymentId and pay the lightningInvoice using any Lightning wallet.
Step 4: Pay the Lightning Invoice
Copy the lightningInvoice and pay it using any Lightning-enabled Bitcoin wallet (Phoenix, Muun, Wallet of Satoshi, etc.).
You can optionally verify the payment was received:
curl -X POST https://sats4ai.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "check_payment_status",
"arguments": {
"paymentId": "abc123"
}
}
}'Step 5: Execute the Service
Once payment is confirmed, call the service tool with your paymentId.
curl -X POST https://sats4ai.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "generate_image",
"arguments": {
"paymentId": "abc123",
"prompt": "A futuristic Bitcoin-powered robot",
"modelId": "black-forest-labs/flux-schnell",
"amount": 1
}
}
}'Successful Response:
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [{
"type": "text",
"text": "{\"images\": [\"https://...\"]}",
}]
}
}Available Tools
| Tool | Description | Payment | Async |
|---|---|---|---|
create_payment | Create Lightning invoice for a service | No | No |
check_payment_status | Check if payment has been received | No | No |
generate_image | Generate images from text prompts | Yes | No |
generate_text | AI text generation and chat | Yes | No |
generate_video | Generate videos from text prompts | Yes | Yes |
analyze_image | AI vision and image analysis | Yes | No |
list_models | List all available AI models | No | No |
get_model_pricing | Get pricing for a specific model | No | No |
check_job_status | Check status of async jobs | No | No |
get_job_result | Get result of completed async jobs | No | No |
Tool Schemas
create_payment
{
"toolName": "generate_image", // Tool to pay for
"modelId": 1, // AI model database ID
"quantity": 1, // Number of outputs
"additionalCharge": 0 // Extra sats (optional)
}generate_image
{
"paymentId": "abc123",
"prompt": "A futuristic city at sunset",
"modelId": "black-forest-labs/flux-schnell",
"amount": 1,
"imageBase64": "..." // Optional, for img2img
}generate_text
{
"paymentId": "abc123",
"prompt": "Explain Bitcoin in simple terms",
"modelId": 2,
"systemPrompt": "You are a helpful assistant", // Optional
"maxTokens": 2048 // Optional
}generate_video
{
"paymentId": "abc123",
"prompt": "A rocket launching into space",
"modelId": 5,
"duration": "5", // "5" or "10" seconds
"cameraFixed": false // Optional
}Async Operations
Some operations like video generation are asynchronous. They return a requestId immediately, and you need to poll for the result.
// Step 1: Generate video (returns requestId)
const videoJob = await mcpRequest('tools/call', {
name: 'generate_video',
arguments: {
paymentId: 'abc123',
prompt: 'A rocket launching into space',
modelId: 5,
duration: '5'
}
});
// Returns: { requestId: 'xyz789', status: 'IN_PROGRESS' }
// Step 2: Poll status until complete
let status;
do {
await sleep(5000);
status = await mcpRequest('tools/call', {
name: 'check_job_status',
arguments: { requestId: 'xyz789', jobType: 'video' }
});
} while (status.status === 'IN_PROGRESS');
// Step 3: Get the result
const result = await mcpRequest('tools/call', {
name: 'get_job_result',
arguments: { requestId: 'xyz789', jobType: 'video' }
});
// Returns: { videoUrl: 'https://...' }Note: Async operations include: generate_video, generate_video_from_image, and generate_3d_model. Use check_job_status and get_job_result to handle these.
Error Handling
Errors are returned in standard JSON-RPC format:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Payment has not been received yet"
}
}Common Error Codes
| Code | Meaning |
|---|---|
-32700 | Parse error - Invalid JSON |
-32600 | Invalid request - Missing required fields |
-32601 | Method not found |
-32602 | Invalid params - Wrong parameter types |
-32603 | Internal error - Service execution failure |
MCP Resources
The MCP server also exposes resources that can be read by MCP clients:
| URI | Description |
|---|---|
sats4ai://models | List of all available AI models with specs and pricing |
sats4ai://pricing | Pricing information for all services |
Need Help?
If you have questions or run into issues, visit our contact page or check out the official MCP documentation.