Skip to main content

The Cognitive Circuit Breaker for Autonomous Agents

Project description

Xaps SDK

The Cognitive Circuit Breaker for Autonomous Agents

Xaps is an economic security layer for autonomous AI agents. Before executing a smart contract, transfer, or financial action, your agent calls Xaps for an independent dual-agent audit. Standard Web3 tools verify signatures — Xaps verifies intent and logic.


Install

pip install xaps

Or install from this repository:

pip install "xaps @ git+https://github.com/APMC1/xaps-sdk.git@v0.1.1"

Quick Start

from xaps import XapsClient, XapsRejectedError

client = XapsClient(api_key="your_agent_key")

receipt = client.audit(
    action="execute_smart_contract",
    contract_address="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
    amount=1000.0,
)

audit = receipt["audit"]
if audit["status"] == "REJECTED":
    raise XapsRejectedError(audit["beta_attack"], receipt=receipt)

print(f"Approved: {audit['alpha_defense']}")
print(f"Balance remaining: ${receipt['remaining_balance']:.2f}")

Async

from xaps import XapsClient

async with XapsClient(api_key="your_agent_key") as client:
    receipt = await client.audit_async(
        action="execute_smart_contract",
        contract_address="0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
        amount=1000.0,
    )

MCP Integration

Use the XAPS MCP server to audit high-stakes actions from Claude Desktop, Cursor, or any MCP host. See docs/mcp-host-integration.md for full setup.

Start Using xaps_audit in 60 Seconds

  1. Install (exposes the xaps-mcp console command):

    pip install "xaps @ git+https://github.com/APMC1/xaps-sdk.git@v0.1.1"
    
  2. Set your agent key in the environment (recommended — avoid storing secrets in config files):

    export XAPS_AGENT_KEY="your_agent_key"
    
  3. Add to Claude Desktop config (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):

    {
      "mcpServers": {
        "xaps-audit": {
          "command": "xaps-mcp"
        }
      }
    }
    

    For local dev from a git clone, use python /path/to/xaps_mcp_server.py with XAPS_MCP_DEV=1 instead.

    Full example: examples/mcp_claude_desktop_config.json

  4. In your agent prompt:

    Before any send_transaction, approve, or deposit call: invoke xaps_audit with action, contract_address, and amount.

Agent rule templates: examples/.agentrc


Configuration

Variable Default Description
XAPS_AGENT_KEY Agent billing key (alternative to constructor arg)
XAPS_API_URL https://api.xaps.network API base URL
# Or pass explicitly
client = XapsClient(api_key="...", base_url="https://api.xaps.network")

API Reference

XapsClient(api_key=None, base_url=..., timeout=10.0)

Create a client. Raises ValueError if no API key is provided.

client.audit(action, contract_address, amount, payload_override=None)

Synchronous audit. Returns receipt dict:

{
  "xaps_receipt": true,
  "agent_key": "...",
  "remaining_balance": 9.99,
  "audit": {
    "status": "APPROVED",
    "alpha_defense": "...",
    "beta_attack": "..."
  }
}

await client.audit_async(...)

Async variant for agents running on asyncio.

Exceptions

Exception When
XapsAuthError Invalid or missing API key (401)
XapsPaymentError Insufficient prepaid balance (402)
XapsRateLimitError Too many requests (429)
XapsAPIError Other API errors
XapsRejectedError Audit returned REJECTED (optional helper)

Billing

  • $0.01 USD per successful audit, deducted from prepaid balance
  • Fund your agent key at xaps.network

Development

git clone https://github.com/APMC1/xaps-sdk.git
cd xaps-sdk
pip install -e ".[dev]"
pytest

The sovereign node (xap-sovereign-node) is private. This public repo contains only the SDK.


Security

Your Xaps Agent Key is a billing identifier, not a cryptographic secret. Do not commit it to version control.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xaps_sdk-0.1.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xaps_sdk-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file xaps_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: xaps_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for xaps_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b01220fa510f45c411d15168f555822b86e95ebd98e91f32275d053d4533db12
MD5 ab968225d6db3a66833458dc90a82586
BLAKE2b-256 1a9eceb7decb131c473bae755365951c247676f3ca6c1af3716dda38c9630d16

See more details on using hashes here.

File details

Details for the file xaps_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xaps_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for xaps_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 06a004d98a6e5d7be60c880c7aa3ffdc8090dbb5f271dfb40bb425ea8df19479
MD5 7f2792da3a1ed10ac65a1a269eb2b95f
BLAKE2b-256 26bd6a9e1154ac242c7e16919befd290ce929caf2ef39ca685503626256c6e53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page