This guide documents the complete integration of the Stripe Agent Toolkit MCP server with the Signet Protocol billing system. The integration provides enhanced billing capabilities, automated product management, and seamless payment processing.
-
MCP Server Configuration (
blackbox_mcp_settings.json)- Stripe Agent Toolkit MCP server
- Environment-based API key configuration
- Server name:
github.com/stripe/agent-toolkit
-
Enhanced Billing Module (
server/pipeline/billing_mcp.py)StripeMCPClient: Interface for MCP tool callsEnhancedBillingBuffer: Extended billing with MCP capabilities- Automated product and pricing setup
-
API Endpoints (added to
server/main.py)/v1/billing/setup-products: Create Stripe products via MCP/v1/billing/create-payment-link/{tenant}: Generate payment links/v1/billing/dashboard: Comprehensive billing dashboard/v1/billing/sync-stripe-items: Sync configuration with Stripe
-
Integration Testing (
test_mcp_integration.py)- Complete test suite for MCP integration
- End-to-end billing workflow validation
The Stripe MCP server is configured in blackbox_mcp_settings.json:
{
"mcpServers": {
"github.com/stripe/agent-toolkit": {
"command": "npx",
"args": ["-y", "@stripe/mcp", "--tools=all"],
"env": {
"STRIPE_SECRET_KEY": "sk_live_51RuCKsLcPYf7t6os..."
}
}
}
}The system uses reserved.json for tenant-specific billing configuration:
{
"acme": {
"vex_reserved": 10000,
"fu_reserved": 50000,
"vex_overage_tiers": [
{
"threshold": 5000,
"price_per_unit": 0.01,
"stripe_item": "si_acme_vex_tier1"
}
],
"fu_overage_tiers": [
{
"threshold": 25000,
"price_per_unit": 0.001,
"stripe_item": "si_acme_fu_tier1"
}
]
}
}The integration provides access to comprehensive Stripe functionality:
stripe_create_product: Create new productsstripe_list_products: List existing productsstripe_create_price: Create pricing for productsstripe_list_prices: List all prices
stripe_list_customers: List customersstripe_create_customer: Create new customers
stripe_create_payment_link: Generate payment linksstripe_create_invoice: Create invoicesstripe_create_refund: Process refundsstripe_retrieve_balance: Get account balance
stripe_list_subscriptions: List subscriptionsstripe_cancel_subscription: Cancel subscriptionsstripe_update_subscription: Update subscription details
# Create VEx and FU products with pricing tiers
result = await BB.setup_signet_products()Creates:
- VEx Product: "Signet VEx (Verified Exchange)"
- FU Product: "Signet FU (Fallback Units)"
- Pricing Tiers: Based on
reserved.jsonconfiguration
# Generate payment links for tenant subscriptions
payment_link = await BB.create_customer_payment_link("acme", "monthly")Features:
- Tenant-specific pricing
- Monthly/annual billing options
- Metadata tracking for usage analytics
# Comprehensive billing data
dashboard = await BB.get_billing_dashboard_data()Provides:
- Account balance and status
- Customer list and metrics
- Product and pricing information
- Tenant usage reports
- MCP operation metrics
# Sync Stripe items with local configuration
sync_result = await BB.sync_stripe_items_with_config()Ensures:
- Stripe subscription items match
reserved.json - Pricing consistency across systems
- Automated configuration updates
graph TD
A[Exchange Request] --> B[Validate & Process]
B --> C[Record Usage]
C --> D[Enhanced Billing Buffer]
D --> E[VEx Billing]
D --> F[FU Billing]
E --> G[MCP Stripe Tools]
F --> G
G --> H[Usage Records Created]
graph TD
A[Setup Request] --> B[MCP Client]
B --> C[Create VEx Product]
B --> D[Create FU Product]
C --> E[Create Pricing Tiers]
D --> E
E --> F[Update Configuration]
F --> G[Return Product IDs]
# Start the Signet Protocol server
python -m server.main
# Run integration tests
python test_mcp_integration.pyThe integration test suite covers:
- Health Check: Server availability
- Product Setup: MCP-based product creation
- Payment Links: Tenant-specific payment generation
- Dashboard: Billing data retrieval
- Sync Operations: Configuration synchronization
- Exchange Billing: End-to-end billing workflow
The integration adds new metrics:
# MCP operation tracking
mcp_operations = Counter("signet_mcp_operations_total",
["operation", "status"])
# Product creation tracking
stripe_products_created = Counter("signet_stripe_products_created_total")
stripe_prices_created = Counter("signet_stripe_prices_created_total")- VEx (Verified Exchange) operations
- FU (Fallback Units) token consumption
- Overage tier utilization
- MCP tool call frequency
- Stripe API keys stored in environment variables
- MCP server isolation with dedicated credentials
- Tenant-specific API key validation
- Encrypted communication with Stripe APIs
- Audit logging for all billing operations
- Idempotency key protection against duplicate charges
- Stripe Account: Active account with API keys
- Node.js: For MCP server execution
- VS Code/BlackBox: For MCP client integration
-
Configure MCP Server:
# Update blackbox_mcp_settings.json with Stripe API key -
Restart VS Code: To load MCP configuration
-
Initialize Products:
curl -X POST http://localhost:8000/v1/billing/setup-products \ -H "X-SIGNET-API-Key: your_api_key" -
Verify Integration:
python test_mcp_integration.py
curl -X POST "http://localhost:8000/v1/billing/create-payment-link/acme?plan_type=monthly" \
-H "X-SIGNET-API-Key: your_api_key"curl -X GET "http://localhost:8000/v1/billing/dashboard" \
-H "X-SIGNET-API-Key: your_api_key"curl -X POST "http://localhost:8000/v1/exchange" \
-H "X-SIGNET-API-Key: your_api_key" \
-H "X-SIGNET-Idempotency-Key: unique_key" \
-H "Content-Type: application/json" \
-d '{
"payload_type": "openai.tooluse.invoice.v1",
"target_type": "invoice.iso20022.v1",
"payload": {...}
}'- Real-time MCP Integration: Direct MCP client library usage
- Advanced Analytics: Usage prediction and optimization
- Multi-currency Support: Global billing capabilities
- Webhook Integration: Real-time Stripe event processing
- Custom Pricing Models: Dynamic pricing based on usage patterns
The modular design allows for:
- Additional MCP server integrations
- Custom billing logic implementation
- Third-party payment processor support
- Advanced reporting and analytics
For issues or questions:
- MCP Server Issues: Check VS Code/BlackBox MCP connection
- Stripe Integration: Verify API keys and permissions
- Billing Logic: Review
reserved.jsonconfiguration - Testing: Run integration test suite for diagnostics
Status: ✅ Production Ready
Last Updated: 2024-01-XX
Version: 1.0.0