Error Handling

Building reliable autonomous agents requires robust error handling. This guide covers ClawFirst MCP server error patterns, recovery strategies, and fault tolerance best practices.

Error Response Format

All MCP tool errors follow a consistent JSON structure:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error description",
    "details": {
      "context": "Additional information for debugging"
    },
    "retryable": true
  },
  "timestamp": 1709834400000
}

Error Categories

Authentication Errors

INVALID_WALLET

Solution: Verify wallet file path and permissions (chmod 400).

SIGNATURE_FAILED

Solution: Check HSM connectivity and credentials. Retry with exponential backoff.

Policy Violation Errors

POLICY_VIOLATION

Solution: Adjust transaction amount or update approval policy. Request human approval if configured.

APPROVAL_TIMEOUT

Solution: Re-submit approval request or extend timeout configuration.

Transaction Errors

INSUFFICIENT_BALANCE

Solution: Fund agent wallet with sufficient SOL or USDC.

SESSION_EXPIRED

Solution: Re-initialize payment session with x402.initialize_payment.

TRANSACTION_FAILED

Solution: Review transaction logs and adjust parameters. Ensure account has rent-exempt balance.

Network Errors

NETWORK_ERROR

Solution: Retry with exponential backoff. Check Solana network status.

RPC_ERROR

Solution: Wait for RPC node to sync or use alternative RPC endpoint.

Rate Limit Errors

RATE_LIMIT_EXCEEDED

Solution: Implement exponential backoff. Respect retry_after value.

See Rate Limits for detailed quota management.

Agent Error Handling Patterns

Pattern 1: Exponential Backoff with Jitter

Pattern 2: Circuit Breaker

Pattern 3: Idempotent Retry with Session IDs

Pattern 4: Fallback Chain

Error Handling Best Practices

1. Distinguish Retryable vs. Non-Retryable Errors

2. Log Complete Error Context

3. Implement Graceful Degradation

4. Monitor Error Rates

5. Set Appropriate Timeouts

Testing Error Scenarios

Simulate Network Failures

Simulate Policy Violations

Simulate RPC Failures

Debugging Failed Transactions

Enable Debug Logging

Inspect Transaction Logs

Query Transaction Status

Common Error Resolution Workflows

Error
Immediate Action
Long-term Fix

INSUFFICIENT_BALANCE

Fund agent wallet

Implement balance monitoring and auto-funding

POLICY_VIOLATION

Adjust transaction or request approval

Review and update approval policies

SESSION_EXPIRED

Re-initialize payment session

Reduce agent processing time

RATE_LIMIT_EXCEEDED

Wait and retry

Upgrade plan or implement request queuing

NETWORK_ERROR

Retry with backoff

Configure multiple RPC endpoints

SIGNATURE_FAILED

Check HSM connectivity

Implement HSM health monitoring

Getting Help

If you encounter persistent errors:

  1. Check Status Pagearrow-up-right for system incidents

  2. Review FAQ for common issues

  3. Contact support with:

    • Error code and message

    • Session ID or transaction signature

    • Agent configuration (approval policies, network, etc.)

    • Relevant log excerpts

  4. Join Discord communityarrow-up-right for peer support

Next Steps

Last updated