{
  "schema_version": "1.0",
  "name": "ghost-layer-mcp",
  "display_name": "Ghost Layer — Dual-Chain Bridge + Execution Matrix MCP",
  "description": "MCP server for Ghost Layer cross-chain bridge and on-chain Execution Matrix. Settle RLUSD (XRPL), XAH (Xahau), and USDC (Base/EVM) micropayments synchronously with full compliance receipts. Mint 54-block programmable routing state.",
  "version": "2.4.0",
  "server_url": "https://ghost-layer.onrender.com",
  "mcp_endpoint": "https://ghost-layer.onrender.com/mcp",
  "payment_required": true,
  "payment_protocol": "x402",
  "payment_assets": ["RLUSD/XRPL", "XAH/Xahau", "USDC/Base"],
  "networks": {
    "xrpl": {"rpc": "https://xrplcluster.com", "currency": "RLUSD", "issuer": "rMxCKbEDwqr76QuheSUMdEGf4B9xJ8m5De"},
    "xahau": {"rpc": "https://xahau.network", "currency": "XAH", "native": true, "hooks_enabled": true},
    "base": {"currency": "USDC", "contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}
  },
  "tools": [
    {
      "name": "ghost_layer_bridge",
      "description": "Execute a cross-chain bridge transaction synchronously. For XRPL, provide signer/signature. For Base, provide the nested eip3009 authorization object. Deducts a toll fee.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/bridge/execute",
      "input_schema": {
        "type": "object",
        "properties": {
          "source_wallet": {"type": "string"},
          "destination_wallet": {"type": "string"},
          "gross_amount": {"type": "string", "description": "Amount to bridge as decimal string"},
          "fee_basis_points": {"type": "integer"},
          "signer": {"type": "string"},
          "signature": {"type": "string"},
          "message_hash": {"type": "string"},
          "eip3009": {
            "type": "object",
            "properties": {
              "valid_after": {"type": "string"},
              "valid_before": {"type": "string"},
              "nonce": {"type": "string"},
              "v": {"type": "integer"},
              "r": {"type": "string"},
              "s": {"type": "string"}
            }
          }
        },
        "required": ["source_wallet", "destination_wallet", "gross_amount", "fee_basis_points"]
      }
    },
    {
      "name": "ghost_agent_loyalty",
      "description": "Check the settlement loyalty tier and effective fee discount for an agent wallet.",
      "endpoint": "GET https://ghost-layer.onrender.com/api/agent/{addr}/stats",
      "input_schema": {
        "type": "object",
        "properties": {
          "addr": {"type": "string", "description": "Agent wallet address"}
        },
        "required": ["addr"]
      }
    },
    {
      "name": "ghost_x402_dispense",
      "description": "Fetch a premium product from the Ghost Layer X402 vending machine (e.g., routing.telemetry). The MCP client will automatically intercept the HTTP 402 Payment Required challenge, pay it, and retry.",
      "endpoint": "GET https://ghost-layer.onrender.com/v1/x402/dispense/{pid}",
      "input_schema": {
        "type": "object",
        "properties": {
          "pid": {"type": "string", "description": "Product ID to dispense (e.g., routing.telemetry)"}
        },
        "required": ["pid"]
      }
    },
    {
      "name": "decision_notarize",
      "description": "Mint any AI decision as an immutable URIToken on Xahau. Pay via X402 using product_id 'decision.notarize' (0.001 RLUSD, STANDARD), 'decision.notarize.certified' (0.01 RLUSD, adds Ed25519 certificate), or 'decision.notarize.sovereign' (0.05 RLUSD, SOVEREIGN grade). Loyalty discounts applied automatically. Returns decision_hash, xahau_tx, verify_url, and (for CERTIFIED/SOVEREIGN) a signed certificate.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/notarize",
      "payment_required": true,
      "payment_protocol": "x402",
      "products": [
        {"id": "decision.notarize",           "price_rlusd": 0.001, "grade": "STANDARD"},
        {"id": "decision.notarize.certified",  "price_rlusd": 0.010, "grade": "CERTIFIED"},
        {"id": "decision.notarize.sovereign",  "price_rlusd": 0.050, "grade": "SOVEREIGN"}
      ],
      "input_schema": {
        "type": "object",
        "required": ["payload", "agent_wallet"],
        "properties": {
          "payload":      {"type": "object",  "description": "The AI decision object to notarize"},
          "model":        {"type": "string",  "description": "Model identifier (e.g., claude-sonnet-4-6)"},
          "agent_wallet": {"type": "string",  "description": "Your XRPL wallet address (for loyalty tier)"},
          "endpoint":     {"type": "string",  "description": "API endpoint that produced this decision"}
        }
      }
    },
    {
      "name": "credit_post_listing",
      "description": "Post a service offer to the Agent Credit Marketplace. Set min_buyer_tier to gate access by loyalty tier (BRONZE/SILVER/GOLD/PLATINUM/DIAMOND). Ghost Layer enforces the gate — buyers below the threshold cannot request a quote.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/credit/listing",
      "input_schema": {
        "type": "object",
        "required": ["seller_wallet", "description", "price_drops"],
        "properties": {
          "seller_wallet":  {"type": "string",  "description": "Your XRPL wallet address"},
          "description":    {"type": "string",  "description": "Service description (max 500 chars)"},
          "price_drops":    {"type": "integer", "description": "Price in RLUSD drops (1 RLUSD = 1,000,000 drops)"},
          "min_buyer_tier": {"type": "string",  "description": "Minimum buyer tier: BRONZE/SILVER/GOLD/PLATINUM/DIAMOND"},
          "ttl_seconds":    {"type": "integer", "description": "Listing TTL in seconds (default 3600, max 2592000)"}
        }
      }
    },
    {
      "name": "credit_get_listings",
      "description": "Browse active Agent Credit Marketplace listings. Pass wallet to filter by your credit tier — only listings your tier can access are returned.",
      "endpoint": "GET https://ghost-layer.onrender.com/v1/credit/listings",
      "input_schema": {
        "type": "object",
        "properties": {
          "wallet": {"type": "string", "description": "Your XRPL wallet address for tier-filtered results"}
        }
      }
    },
    {
      "name": "credit_quote",
      "description": "Get escrow parameters for a listing. Returns condition_hex to put in your XRPL EscrowCreate, plus amount and seller wallet. Ghost Layer enforces min_buyer_tier here — returns ERR_TIER_INSUFFICIENT if you don't qualify.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/credit/quote",
      "input_schema": {
        "type": "object",
        "required": ["listing_id", "buyer_wallet"],
        "properties": {
          "listing_id":   {"type": "string", "description": "ID from GET /v1/credit/listings"},
          "buyer_wallet": {"type": "string", "description": "Your XRPL wallet address"}
        }
      }
    },
    {
      "name": "credit_register_escrow",
      "description": "After submitting EscrowCreate to XRPL, register the on-chain sequence number with Ghost Layer. Use the OfferSequence from your EscrowCreate transaction.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/credit/escrow/register",
      "input_schema": {
        "type": "object",
        "required": ["escrow_id", "offer_sequence"],
        "properties": {
          "escrow_id":      {"type": "string",  "description": "escrow_id from /v1/credit/quote"},
          "offer_sequence": {"type": "integer", "description": "OfferSequence of your EscrowCreate tx"}
        }
      }
    },
    {
      "name": "credit_release",
      "description": "Confirm delivery and release escrow to seller. Ghost Layer fires EscrowFinish with the PREIMAGE-SHA-256 fulfillment — funds flow escrow → seller directly on XRPL. Both parties earn loyalty volume.",
      "endpoint": "POST https://ghost-layer.onrender.com/v1/credit/escrow/{id}/release",
      "input_schema": {
        "type": "object",
        "required": ["escrow_id", "buyer_wallet"],
        "properties": {
          "escrow_id":   {"type": "string", "description": "Escrow ID to release"},
          "buyer_wallet":{"type": "string", "description": "Your XRPL wallet address (must match buyer)"}
        }
      }
    },
    {
      "name": "credit_get_escrow",
      "description": "Get the current state of an escrow: PENDING_ESCROW / ESCROWED / DELIVERED / RELEASED / CANCELLED.",
      "endpoint": "GET https://ghost-layer.onrender.com/v1/credit/escrow/{id}",
      "input_schema": {
        "type": "object",
        "required": ["escrow_id"],
        "properties": {
          "escrow_id": {"type": "string", "description": "Escrow ID to query"}
        }
      }
    },
    {
      "name": "credit_profile",
      "description": "Get your Agent Credit profile: loyalty tier, lifetime volume, effective BPS, accessible marketplace tiers, and upgrade threshold.",
      "endpoint": "GET https://ghost-layer.onrender.com/api/agent/{addr}/credit",
      "input_schema": {
        "type": "object",
        "required": ["addr"],
        "properties": {
          "addr": {"type": "string", "description": "XRPL wallet address"}
        }
      }
    },
    {
      "name": "x402_attestation_pubkey",
      "description": "Retrieve Ghost Layer's Ed25519 public key to independently verify CERTIFIED/SOVEREIGN decision certificates.",
      "endpoint": "GET https://ghost-layer.onrender.com/v1/x402/attestation/pubkey",
      "input_schema": {"type": "object", "properties": {}}
    },
    {
      "name": "cube_state_mint",
      "description": "Mint the Ghost Layer Execution Matrix state as a URIToken on Xahau. Submit the full 54-block payload. Server validates all face centers via the equation center=clamp(weighted_sum(edges)×coefficient(corners), min, max), verifies the CUBE-XXXXXXXX hash.",
      "endpoint": "POST https://ghost-layer.onrender.com/api/cube/state",
      "price_rlusd": 0,
      "input_schema": {
        "type": "object",
        "required": ["cube_hash", "faces"],
        "properties": {
          "cube_hash": {
            "type": "string",
            "description": "CUBE-XXXXXXXX deterministic djb2 hash of the 54-block state"
          },
          "faces": {
            "type": "object",
            "description": "6 face objects keyed px/nx/py/ny/pz/nz",
            "properties": {
              "px": {"$ref": "#/definitions/Face"},
              "nx": {"$ref": "#/definitions/Face"},
              "py": {"$ref": "#/definitions/Face"},
              "ny": {"$ref": "#/definitions/Face"},
              "pz": {"$ref": "#/definitions/Face"},
              "nz": {"$ref": "#/definitions/Face"}
            },
            "definitions": {
              "Face": {
                "type": "object",
                "required": ["center", "edges", "corners"],
                "properties": {
                  "center": {"type": "integer", "description": "Computed center value (server re-validates)"},
                  "edges": {"type": "array", "items": {"type": "integer"}, "minItems": 4, "maxItems": 4},
                  "corners": {"type": "array", "items": {"type": "number"}, "minItems": 4, "maxItems": 4}
                }
              }
            }
          }
        }
      }
    }
  ]
}
