RGB-MCP-SERVERv2

Quigles1337/RGB-MCP-SERVERv2

3.3

If you are the rightful owner of RGB-MCP-SERVERv2 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

RGB MCP Server v1 is a Model Context Protocol server designed to facilitate RGB smart contracts with trustlines protocol and XRPL bridge functionality.

Tools
16
Resources
0
Prompts
0

RGB MCP Server v1

A Model Context Protocol (MCP) server for RGB smart contracts with trustlines protocol and XRPL bridge functionality

GitHub Release CI Status Node Version TypeScript MCP Tools RGB Protocol XRPL

🌟 Overview

RGB MCP Server v1 is a comprehensive MCP server that brings RGB smart contract functionality to AI assistants like Claude, with advanced features including:

  • RGB Smart Contracts: Issue, transfer, and manage RGB assets on Bitcoin/Lightning
  • Bilateral Credit Lines (Trustlines): Enable credit-based transfers without immediate asset movement
  • Payment Channels: Bidirectional channels for off-chain RGB asset transfers
  • XRPL Bridge: Cross-chain bridge between RGB and XRP Ledger via payment channels
  • Full MCP Integration: 18+ tools for complete RGB ecosystem interaction

šŸ—ļø Architecture

RGB Assets (Bitcoin/Lightning)
         ↕
  Trustlines Protocol (Credit Lines)
         ↕
  Payment Channels (Off-Chain)
         ↕
  XRPL Bridge (Cross-Chain)
         ↕
  XRPL Ledger (IOUs)

Key Components

  1. RGB Service: Interface for RGB protocol operations (asset issuance, transfers, validation)
  2. Trustlines Service: Bilateral credit line protocol ported from Stacks implementation
  3. Payment Channels Service: Bidirectional channels for RGB assets
  4. Bridge Service: RGB ↔ XRPL cross-chain bridge using payment channels
  5. XRPL Service: Integration with XRP Ledger for IOU minting/burning

šŸ“¦ Installation

Prerequisites

  • Node.js >= 18.0.0
  • RGB node (for production use)
  • Bitcoin node (testnet/mainnet)
  • Lightning node (optional, for Lightning Network RGB)
  • XRPL node access (or use public nodes)

Setup

# Clone the repository
git clone https://github.com/Quigles1337/RGB-MCP-SERVERv1.git
cd RGB-MCP-SERVERv1

# Install dependencies
npm install

# Build TypeScript
npm run build

# Or run in development mode
npm run dev

Configuration

Create a .env file (see .env.example):

# RGB Configuration
RGB_NETWORK=testnet
RGB_NODE_URL=http://localhost:3000

# Bitcoin Configuration
BITCOIN_NETWORK=testnet
BITCOIN_RPC_URL=http://localhost:18332
BITCOIN_RPC_USER=user
BITCOIN_RPC_PASSWORD=password

# XRPL Configuration
XRPL_NETWORK=testnet
XRPL_NODE_URL=wss://s.altnet.rippletest.net:51233

# Bridge Configuration
BRIDGE_ENABLED=true
BRIDGE_FEE_PERCENT=0.3
BRIDGE_MIN_AMOUNT=10
BRIDGE_MAX_AMOUNT=100000

# Trustlines Configuration
TRUSTLINES_ENABLED=true
TRUSTLINES_DEFAULT_LIMIT=1000000

# Payment Channels Configuration
PAYCHAN_ENABLED=true
PAYCHAN_EXPIRY_BLOCKS=1440
PAYCHAN_MIN_DEPOSIT=1000

šŸ”§ MCP Integration

Cursor IDE

Create .cursor/mcp.json:

{
  "mcpServers": {
    "rgb-mcp-server": {
      "command": "node",
      "args": ["C:/Users/YourName/RGB-MCP-SERVERv1/dist/server.js"],
      "env": {
        "RGB_NETWORK": "testnet",
        "XRPL_NETWORK": "testnet",
        "BRIDGE_ENABLED": "true",
        "TRUSTLINES_ENABLED": "true"
      }
    }
  }
}

Or for development:

{
  "mcpServers": {
    "rgb-mcp-server": {
      "command": "npx",
      "args": ["tsx", "C:/Users/YourName/RGB-MCP-SERVERv1/src/server.ts"]
    }
  }
}

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "rgb-mcp-server": {
      "command": "node",
      "args": ["/path/to/RGB-MCP-SERVERv1/dist/server.js"]
    }
  }
}

šŸ› ļø Available Tools

RGB Smart Contract Tools (5 tools)

rgb_issue_asset

Issue a new RGB fungible asset.

{
  ticker: "RGB",           // Asset ticker (max 10 chars)
  name: "RGB Token",       // Full name
  description: "...",      // Description
  precision: 8,            // Decimal places
  supply: "1000000000",    // Initial supply in base units
  seal: "txid:vout"        // Bitcoin UTXO that owns the asset
}
rgb_transfer_asset

Transfer RGB asset to another owner.

{
  assetId: "...",              // RGB asset contract ID
  amount: "1000",              // Amount in base units
  recipientBlindedUtxo: "...", // Recipient blinded UTXO
  changeUtxo: "..."            // Optional change UTXO
}
rgb_get_asset_info

Get detailed information about an RGB asset.

rgb_get_balance

Get RGB asset balance (available, pending, total).

rgb_validate_contract

Validate RGB contract for correctness.


Trustlines Tools (5 tools)

trustline_create

Create bilateral credit line between two participants.

{
  assetId: "...",          // RGB asset ID
  participant1: "...",     // First participant address
  participant2: "...",     // Second participant address
  limit1: "10000",         // Credit limit P1 → P2
  limit2: "10000"          // Credit limit P2 → P1
}
trustline_transfer_credit

Transfer credit through trustline (off-chain, instant).

{
  trustlineId: "...",
  from: "...",
  to: "...",
  amount: "100"
}
trustline_settle

Settle trustline exposure with RGB asset transfer (on-chain).

{
  trustlineId: "...",
  from: "...",      // Debtor
  to: "...",        // Creditor
  amount: "100"     // Amount to settle
}
trustline_get_info

Get detailed trustline information including exposures.

trustline_list

List trustlines filtered by participant and/or asset.


Payment Channels Tools (1 tool shown)

paychan_open

Open bidirectional payment channel for RGB asset.

{
  assetId: "...",
  participant1: "...",
  participant2: "...",
  deposit1: "1000",     // P1's deposit
  deposit2: "1000",     // P2's deposit
  expiryBlocks: 1440    // Optional: blocks until expiry
}

Bridge Tools (3 tools)

bridge_to_xrpl

Swap RGB asset for XRPL IOU (backed 1:1 by actual RGB).

How it works: User transfers RGB to operator, receives XRPL IOU from operator's inventory.

{
  rgbAssetId: "...",      // RGB asset to swap
  amount: "100",          // Amount to swap
  rgbSender: "...",       // Your RGB address
  xrplDestination: "rAddress...",  // Your XRPL address
  xrplIssuer: "rIssuer..."  // Bridge operator's XRPL address
}
bridge_to_rgb

Swap XRPL IOU back for RGB asset (from operator's inventory).

How it works: User sends IOU to operator, receives actual RGB asset from operator's inventory.

{
  xrplCurrency: "RGB",    // XRPL IOU currency code
  xrplIssuer: "rIssuer...",  // Bridge operator's address
  amount: "100",          // Amount to swap
  xrplSender: "rAddress...",  // Your XRPL address
  rgbDestination: "..."   // Your RGB address
}
bridge_get_status

Get status of bridge operation.


XRPL Tools (2 tools)

xrpl_create_account

Create new XRPL account with optional testnet funding.

{
  fundTestnet: true  // Optional: auto-fund from faucet
}
xrpl_set_trustline

Set XRPL trust line to receive bridged RGB assets as IOUs.

{
  walletSecret: "s...",
  currency: "RGB",
  issuer: "rIssuer...",
  limit: "1000000"
}

šŸ’” Use Cases

1. RGB Asset Management

Issue RGB asset → Transfer to users → Validate contracts

2. Credit-Based Transfers (Trustlines)

Create trustline → Transfer credit (off-chain, instant) → Settle later with RGB

Benefits:

  • Instant transfers without blockchain transactions
  • Credit lines enable liquidity
  • Settlement only when needed
  • Reduces on-chain fees

3. Payment Channels

Open channel → Update state off-chain → Close when done

Benefits:

  • Off-chain RGB transfers
  • Near-instant finality
  • Minimal fees
  • Bridge to XRPL via channels

4. Cross-Chain Bridge (RGB ↔ XRPL)

RGB Asset → Lock in vault → Mint IOU on XRPL → Trade on XRPL DEX
XRPL IOU → Burn → Unlock RGB Asset

Benefits:

  • Access XRPL's 3-5 second finality
  • Trade RGB assets on XRPL DEX
  • Cross-chain liquidity
  • Payment channels facilitate bridge

šŸŒ‰ Bridge Architecture v2.0

āš ļø IMPORTANT: RGB is a PROTOCOL, not a network! There is no "RGB token" to mint or burn.

Liquidity Pool + Trustlines Model

The bridge uses a swap-based model where the bridge operator acts as a market maker:

RGB → XRPL Flow (Swap Operation)

1. User transfers RGB asset to bridge operator
2. Trustline established for credit buffer
3. Operator swaps from XRPL IOU inventory
4. User receives XRPL IOU (backed 1:1 by actual RGB)

XRPL → RGB Flow (Reverse Swap)

1. User sends XRPL IOU to bridge operator
2. Trustline settles credit exposure
3. Operator transfers RGB from inventory
4. User receives actual RGB asset

Key Principles

  • āœ… No Token Minting: Uses actual RGB assets, not synthetics
  • āœ… 1:1 Backing: Every XRPL IOU backed by real RGB in operator inventory
  • āœ… Swap, Not Lock/Mint: Bridge operator is market maker, not custodian
  • āœ… Trustlines: Provide credit buffer for timing mismatches
  • āœ… Auditable: Anyone can verify reserves

Bridge Security

  • Liquidity Pools: Operator maintains RGB inventory on Bitcoin/Lightning
  • Trustlines: Credit-based buffer for instant bridging
  • Proof of Reserves: Verifiable 1:1 backing
  • Market Making: Natural economic incentives

šŸ“– Full Architecture: See for complete details

šŸ“Š Example Workflows

Complete RGB Asset Lifecycle

// 1. Issue RGB asset
Issue asset "MyToken" (MTK) with 1M supply

// 2. Get asset info
Get info for asset abc123

// 3. Transfer to user
Transfer 1000 MTK to user's blinded UTXO

// 4. Check balance
Get balance for asset abc123

Trustlines Workflow

// 1. Create trustline between Alice & Bob
Create trustline for asset abc123 between Alice and Bob with 10,000 limit each

// 2. Alice sends credit to Bob (instant, off-chain)
Transfer 500 credit from Alice to Bob via trustline

// 3. Bob settles debt with RGB asset
Settle 500 from Bob to Alice via trustline xyz

// 4. Check trustline status
Get trustline info for xyz

Bridge Workflow

// 1. Create XRPL account
Create XRPL account with testnet funding

// 2. Set trust line for bridged asset
Set XRPL trustline for currency "RGB" from issuer rXXX with limit 100000

// 3. Bridge RGB to XRPL
Bridge 100 RGB from Alice's address to rXRPL_Address

// 4. Check bridge status
Get bridge status for operation op123

// 5. Bridge back to RGB
Bridge 50 RGB IOU from rXRPL_Address back to Alice

šŸ” Security Considerations

RGB Security

  • Client-side validation ensures trustless operation
  • Bitcoin blockchain provides final settlement
  • Blinded UTXOs provide privacy

Trustlines Security

  • Credit limits prevent unlimited exposure
  • Frozen state for dispute resolution
  • On-chain settlement available anytime

Payment Channels Security

  • Cryptographic signatures prevent cheating
  • Dispute period allows challenge
  • Final state committed on-chain

Bridge Security

  • āš ļø TESTNET ONLY: Not production-ready
  • Requires professional audit before mainnet
  • Multi-sig vault (planned)
  • Proof verification system (planned)

šŸš€ Development

Project Structure

RGB-MCP-SERVERv1/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ server.ts           # Main MCP server
│   ā”œā”€ā”€ config.ts           # Configuration
│   ā”œā”€ā”€ services/           # Core services
│   │   ā”œā”€ā”€ RGBService.ts
│   │   ā”œā”€ā”€ TrustlinesService.ts
│   │   ā”œā”€ā”€ PaychanService.ts
│   │   ā”œā”€ā”€ BridgeService.ts
│   │   └── XRPLService.ts
│   ā”œā”€ā”€ tools/              # MCP tools
│   │   ā”œā”€ā”€ rgb/
│   │   ā”œā”€ā”€ trustlines/
│   │   ā”œā”€ā”€ paychan/
│   │   ā”œā”€ā”€ bridge/
│   │   └── xrpl/
│   └── utils/              # Utilities
ā”œā”€ā”€ contracts/              # Smart contracts
ā”œā”€ā”€ integration_guides/     # Integration docs
└── scripts/                # Helper scripts

Building

# Clean build
npm run clean
npm run build

# Development with auto-reload
npm run watch

# Start server
npm start

# Development mode
npm run dev

Testing

# Test RGB service
Issue test asset

# Test trustlines
Create test trustline

# Test bridge (testnet only)
Bridge test asset to XRPL testnet

šŸ“š Resources

šŸ¤ Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

šŸ“„ License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

šŸ™ Acknowledgments

  • RGB Protocol team for the RGB smart contract system
  • Ripple for the XRPL ledger
  • Anthropic for the Model Context Protocol
  • Stacks community for trustlines protocol inspiration

āš ļø Disclaimer

This software is provided "as is" without warranty. The bridge functionality is experimental and NOT audited. DO NOT USE ON MAINNET UNTIL AUDIT IS COMPLETE. Only use on testnet for development and testing.


Built by Quigles1337 | 2025

Repository: https://github.com/Quigles1337/RGB-MCP-SERVERv1