Skip to main content

AgentClose Python

Python SDK and read-only MCP server for AgentClose post-payment reconciliation.

Install

pip install agentclose

Install the MCP extra when exposing AgentClose to an MCP client:

pip install "agentclose[mcp]"

Capture events

from agentclose import AgentCloseClient, Event

with AgentCloseClient("acl_your_api_key") as client:
    client.capture(
        Event(
            type="request.started",
            data={
                "agent_id": "research-agent",
                "task_id": "task_8f2",
                "request_id": "req_4a81",
                "service": "company-data.api",
                "attempt_number": 1,
            },
        )
    )

event_id and occurred_at are generated once when Event is constructed. A retry therefore keeps the same idempotency identity. Capture methods retry transient failures with a bounded backoff and are fail-open by default, so reconciliation telemetry does not break the Agent workflow. Set fail_open=False when delivery must raise an error.

Send 1–100 facts with one request:

events = [
    Event(type="task.started", data={"agent_id": "research-agent", "task_id": "task_8f2"}),
    Event(
        type="payment.confirmed",
        data={
            "agent_id": "research-agent",
            "task_id": "task_8f2",
            "request_id": "req_4a81",
            "payment_id": "pay_72bc",
            "amount": {"minor": 12, "currency": "USD"},
        },
    ),
]

with AgentCloseClient("acl_your_api_key") as client:
    client.capture_batch(events)

AsyncAgentCloseClient provides the same methods for async applications:

from agentclose import AsyncAgentCloseClient, Event

async with AsyncAgentCloseClient("acl_your_api_key") as client:
    await client.capture(Event(type="task.started", data={"task_id": "task_8f2"}))

Observe x402

The observer records an x402 exchange after your runtime has handled payment. It never holds funds, signs a payment, or reads wallet keys.

from agentclose import AgentCloseClient, X402Observation

observation = X402Observation(
    agent_id="research-agent",
    task_id="task_8f2",
    request_id="req_4a81",
    service="company-data.api",
    endpoint="https://company-data.example/query",
    payment_required="base64-payment-required-header",
    payment_response="base64-payment-response-header",
    http_status=200,
    delivery_observed=True,
)

with AgentCloseClient("acl_your_api_key") as client:
    client.observe_x402(observation)

Query reconciliation data

Read methods raise errors instead of failing open:

with AgentCloseClient("acl_your_api_key") as client:
    page = client.list_transactions(status="EXCEPTION", limit=50)
    next_cursor = page["next_cursor"]
    payment_matches = client.get_payment_transactions("pay_72bc")
    usage = client.get_usage()

Run the read-only MCP server

export AGENTCLOSE_API_KEY=acl_your_api_key
agentclose-mcp

The stdio server exposes these tools:

  • list_transactions
  • get_transaction
  • get_task_transactions
  • get_task_cost
  • list_open_exceptions
  • get_payment_status
  • get_usage_summary

Example MCP client configuration:

{
  "mcpServers": {
    "agentclose": {
      "command": "agentclose-mcp",
      "env": {
        "AGENTCLOSE_API_KEY": "acl_your_project_api_key"
      }
    }
  }
}

The MCP process uses the same project-scoped AgentClose API key as the SDK. It only calls read endpoints and cannot capture events, resolve exceptions, rotate keys, or modify data.

Download files

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

Source Distribution

agentclose-0.1.0.tar.gz (74.6 kB view details)

Uploaded Source

Built Distribution

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

agentclose-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file agentclose-0.1.0.tar.gz.

File metadata

  • Download URL: agentclose-0.1.0.tar.gz
  • Upload date:
  • Size: 74.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for agentclose-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34687ba1f25ced02a05ee504d100947d2629d4bbb5b4274e3c2261ceed27193c
MD5 7c79ddd3d924cf130fcced5b4fb0608c
BLAKE2b-256 8b291ac1b8beacad2d9768fad06ce913d625e09f14220ba48cd22135fb8f90a5

See more details on using hashes here.

File details

Details for the file agentclose-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentclose-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for agentclose-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b0d68880a9d44b31616b487ef6294194f985b4b43ad1fd746f2721970fca9b6
MD5 522c093a12f1fc8d1f4c728cfc2a2ca1
BLAKE2b-256 8ba1598df806e657d11a33b402ae3fb115cd3dddae86c8cffa270e606e7d1998

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 Sentry Error logging StatusPage Status page