Skip to main content
Uniplex Agent-to-Agent Commerce enables bilateral metered billing for AI agent tool usage. Gates issue signed receipts (consumption attestations) after each tool execution, which agents can verify and aggregate for billing.

How It Works

1

Agent generates nonce

Before calling a tool, the agent creates a unique nonce to prevent receipt fabrication.
2

Tool executes

The gate executes the tool and records execution time/units.
3

Gate issues receipt

The gate signs a consumption attestation with the nonce, cost, and platform fee.
4

Agent verifies

The agent verifies the signature, nonce, and cost computation.
5

Aggregate for settlement

Both parties aggregate attestations for periodic billing.

Consumption Attestations

A consumption attestation is a signed receipt issued by a gate after tool execution:
{
  "attestation_type": "consumption",
  "attestation_id": "catt_1707091234_abc123",
  "gate_id": "gate_weather-api",
  "agent_id": "agent_travel-planner",
  "passport_id": "passport_xyz789",
  "permission_key": "weather:forecast",
  "catalog_version": 1,
  "request_nonce": "nonce_1707091234_def456",
  "effective_constraints": {
    "pricing": {
      "per_call_cents": 10,
      "currency": "USD"
    },
    "platform_fee": {
      "basis_points": 200
    }
  },
  "consumption": {
    "units": 1,
    "cost_cents": 10,
    "platform_fee_cents": 1,
    "timestamp": "2026-02-04T12:00:00Z"
  },
  "proof": {
    "type": "JWS",
    "kid": "gate_weather-api#key-1",
    "sig": "eyJhbGciOi..."
  }
}

Usage

import { 
  issueConsumptionAttestation, 
  verifyConsumptionAttestation,
  generateRequestNonce,
  aggregateAttestations,
  computePlatformFee 
} from 'uniplex-mcp-sdk';

// Gate issues receipt after tool execution
const receipt = await issueConsumptionAttestation({
  gate_id: 'gate_weather-api',
  agent_id: 'agent_travel-planner',
  passport_id: 'passport_123',
  permission_key: 'weather:forecast',
  catalog_version: 1,
  effective_constraints: {
    'core:pricing:per_call_cents': 10,
    'core:pricing:currency': 'USD',
    'core:platform_fee:basis_points': 200
  },
  sign: async (payload) => signWithGateKey(payload),
  signing_key_id: 'gate_weather-api#key-1'
});

// Agent verifies receipt
const verification = await verifyConsumptionAttestation({
  attestation: receipt,
  expected_nonce: myNonce,
  gate_public_key: gatePublicKey,
  verify: async (payload, sig, key) => verifySignature(payload, sig, key)
});

// Aggregate for billing
const billing = aggregateAttestations(receipts, '2026-02-01', '2026-02-28');
// → { total_calls: 150, total_cost_cents: 1500, total_platform_fee_cents: 30 }

Pricing Constraints

Define pricing in your permission catalog:
ConstraintTypeDescription
core:pricing:per_call_centsintegerCost per tool call in cents
core:pricing:per_minute_centsintegerCost per minute for time-based billing
core:pricing:currencystringISO 4217 currency code (e.g., “USD”)
core:pricing:modelstring”per_call”, “per_minute”, “subscription”, “usage”
core:pricing:free_tier_callsintegerFree calls before billing starts

SLA Constraints

Define service level guarantees:
ConstraintTypeDescription
core:sla:uptime_basis_pointsintegerUptime guarantee (9999 = 99.99%)
core:sla:response_time_msintegerAverage response time
core:sla:p99_response_msinteger99th percentile response time

Platform Fees

Platform fees use ceiling rounding (always rounds up):
computePlatformFee(1000, 200)  // 2% of $10.00 = 20 cents
computePlatformFee(101, 200)   // 2% of $1.01 = 3 cents (ceil of 2.02)
computePlatformFee(1, 200)     // 2% of $0.01 = 1 cent (ceil of 0.02)

Enable Commerce

TypeScript

const server = new UniplexMCPServer({
  gate_id: 'gate_weather-api',
  tools: [forecastTool],
  commerce: {
    enabled: true,
    issue_receipts: true  // Auto-issue after each tool call
  }
});

Python

server = UniplexMCPServer(
    gate_id='gate_weather-api',
    tools=[forecast_tool],
    commerce_enabled=True,
    issue_receipts=True
)

Types Reference

import type {
  ConsumptionAttestation,  // Receipt after tool execution
  ConsumptionData,         // Units, cost, timestamp
  PricingConstraints,      // per_call_cents, per_minute_cents, currency
  SLAConstraints,          // uptime_basis_points, response_time_ms
  PlatformFeeConstraints,  // basis_points, recipient
  BillingPeriod,           // Aggregated settlement
  RequestNonce,            // For bilateral verification
  DiscoveryQuery,          // Find services by price/capability
  DiscoveryResult          // Matching gates
} from 'uniplex-mcp-sdk';

Service Discovery

Find services by price, capability, or SLA:
import { matchesDiscoveryCriteria, meetsSLARequirements } from 'uniplex-mcp-sdk';

// Filter by price
matchesDiscoveryCriteria(pricing, { max_price_cents: 50, currency: 'USD' });

// Filter by SLA
meetsSLARequirements(sla, { min_uptime_basis_points: 9990, max_response_time_ms: 200 });