Let an AI agent buy one exact x402 resource after a human grants it, and get back a receipt you can audit, without giving the agent a wallet key.
Agent Capability Middleware is an Apache-2.0 SDK for teams integrating paid APIs into agents. The first example uses a market-risk snapshot.
Developer preview. The protected buyer flow is implemented and tested on Base Sepolia testnet only. Seller and data-exchange helpers are experimental local previews. They do not settle payments or prove buyer demand.
The published v0.1.0-preview.25 GitHub tag provides the
SDK and older CLI commands. The local MCP demo uses a newer pinned GitHub commit.
A person wants their agent to fetch one current BTC market-risk snapshot. ACM turns that into three objects.
1. The exact resource. The agent can pay for this, and nothing else:
| Field | Value |
|---|---|
| Resource | GET https://omniterminal.app/api/x402/v1/market-risk/BTC?scope=current |
| Price | 0.010 USDC |
| Network | Base Sepolia (eip155:84532) |
| Asset | Base Sepolia USDC 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
| Payee | 0x733f40A4FA0cd13d59aBADE04b9eD2e9acAc6457 |
| Expected schema | market_risk_snapshot.v1 |
2. The human grant. A human operator issues a scoped, expiring, revocable grant through the protected gateway. The protected gateway holds the payer key. The grant sets the spend, domain, category and settlement limits. The agent presents the grant ID with the exact request and expected quote.
const recipe = {
...createOmniX402Recipe({ kind: "market_risk", symbol: "BTC" }),
resourceUrl: "https://omniterminal.app/api/x402/v1/market-risk/BTC?scope=current",
method: "GET" as const,
};
const grant = await operatorClient.createGrant(
createOmniRecipeGrant("agent_research_bot", [recipe], { expiresInSeconds: 600 }),
);
// scopes: ["x402.pay"]
// spendPolicy: { currency: "USDC", perRequestMax: 0.01, dailyMax: 0.01, approvalRequiredAbove: 0.01 }
// resourcePolicy: { allowedDomains: ["omniterminal.app"], allowedCategories: ["market_intelligence"] }
// settlementPolicy: Base Sepolia, USDC only3. The receipt. The agent receives data only when the payment settled, the gateway returned a receipt, and the body is fresh and has the expected schema.
const result = await agentClient.consumeX402Testnet(
createOmniPaymentRequest(approvedGrantId, recipe, purchaseId),
);
const data = requireFreshPaidResult(result, { expectedSchema: recipe.schema });
// result.decision === "paid", result.receiptId, result.auditEventIdReuse the same purchaseId when reconciling a retry. The operator can revoke the grant before the agent makes another request.
The tool supplies the exact URL, method, purpose, quote and idempotency key. The gateway owns
grant enforcement, signing and reconciliation. requireFreshPaidResult checks the ACM
response for the expected schema, freshness and a receipt. Independent on-chain verification
requires a separate chain lookup.
You need Node.js 20+ and internet access. You do not need a clone, account, wallet, key or funds.
npx --yes https://github.com/InTheta/agent-capability-middleware/archive/refs/tags/v0.1.0-preview.25.tar.gz doctor
npx --yes https://github.com/InTheta/agent-capability-middleware/archive/refs/tags/v0.1.0-preview.25.tar.gz demo buyerdoctorreads Coinbase's public x402 Bazaar catalog and checks the nine canonical Omni routes and the0.010USDC quote above. Success showsok: true,mode: "live_no_spend",spent: falseandsecretsIncluded: false. It creates no signature or payment.demo buyervalidates a syntheticmarket_risk_snapshot.v1result locally. Its0xmock_...receipt is deliberately not a chain transaction, and it creates no real grant.
The step-by-step path is in Getting started. For a short tester run, see Test ACM, then send feedback. Stopped or failed runs are useful too.
npm install github:InTheta/agent-capability-middleware#v0.1.0-preview.25Installing grants no authority and enables no spending. A real paid call needs a protected ACM gateway URL from an operator. The public CLI and SDK do not include public gateway access. See the availability matrix.
Launch the synthetic stdio server with Node.js 20+ and npm. The pinned archive includes the built CLI.
npx --yes https://github.com/InTheta/agent-capability-middleware/archive/7659f4c5168c6c1eb97c2fedc4c497399c10aa5e.tar.gz mcpThis process waits for JSON-RPC on stdin. Configure your MCP host to run npx with the three
arguments shown above. Leave the ACM testnet settings unset for the demo.
Ask the agent to call get_btc_market_risk with a lowercase UUID v4 as idempotencyKey. Expect
one synthetic snapshot, a mock receipt and spent: false. The local server exposes one tool.
The SDK separately supports five paid MCP tool names through a protected Base Sepolia gateway.
A human operator must issue a bounded grant before an agent can use that gateway.
See MCP host configuration, Windows setup and a runnable transcript.
ACM combines a human-issued grant, an exact x402 purchase request, and an auditable receipt. See how that workflow fits alongside wallet policies, hosted payment sessions, and commerce mandates. Competitor comparison
| Capability | Status |
|---|---|
No-spend catalog and quote check (acm doctor, acm inspect) |
Implemented |
Exact request plans for nine Omni x402 route templates (acm recipes) |
Implemented |
| Grant, pay, receipt, revoke and deny through a protected payer | Implemented on Base Sepolia |
One local stdio MCP tool (acm mcp) |
Synthetic by default, with operator-configured Base Sepolia opt-in |
Five bounded paid Omni MCP tools (consumeX402McpTestnet) |
Implemented on Base Sepolia |
| Mainnet spending | Not claimed |
Developer and user seller offers (acm demo developer-seller, user-seller, exchange) |
Experimental, local only |
| Hosted vault, production identity, user-data marketplace, auctions | Not in this repository |
acm recipes prints 25 concrete no-spend request plans over the nine templates. These are not
25 Bazaar listings.
flowchart LR
H["Human grant"] --> G["Protected ACM gateway"]
A["Agent (grant ID only)"] --> G
G -->|"exact resource"| X["x402 seller"]
G -. "bounded settlement" .-> B["Base Sepolia USDC"]
G --> R["Receipt + audit event"]
ACM composes existing standards rather than replacing them. MCP carries tool calls, OAuth or OIDC identifies workloads and users, and x402 carries payment requirements and proofs. More detail is in Architecture and x402 integration.
This is not a public signup. Use the feedback form to express interest. An operator must arrange protected access and confirm a dedicated Base Sepolia payer first. Then follow the private-pilot checklist. It checks one real testnet purchase, the receipt, revocation and denial before a second settlement. No mainnet funds or payer keys are needed from you.
git clone https://github.com/InTheta/agent-capability-middleware.git
cd agent-capability-middleware
npm ci
npm run verifyVerification type-checks the SDK and a consumer, runs tests and privacy checks, exercises the
examples, and installs the packed package in a clean temporary project. CI also fails if the
committed dist/ differs from the TypeScript source. No step spends funds.
This repository contains the public SDK, request builders, a local evidence minimizer, experimental offer helpers, examples and tests. It does not contain private keys, payer custody, a hosted vault, production identity verification, a live user-data marketplace, guaranteed user revenue or a production risk control plane.
- Getting started: one resource, one grant, one receipt
- Test ACM without a wallet
- Comparison with other agent-payment approaches
- SDK API · Runnable examples · Omni agent recipes
- x402 integration · Architecture
- Privacy-safe learning · Security · Roadmap
Preview.25 prices news recipes at 0.010 USDC and adds get_premarket_roundup (0.100 USDC)
to the five-tool paid MCP union. Preview.24 stays immutable with its historical news price and
four-tool union.
Apache-2.0 licensed.
