Agent side

Connect an agent

Discover and call resources from an agent over MCP, plain HTTP, A2A or ACP.

Agents need no account and no API key: agent routes are open by design, and paid resources are protected by payment. Start by reading what the gateway offers, then call it over the protocol your agent speaks.

Discover

bash
curl -s https://gateway.example.com/.well-known/agent-commerce
curl -s https://gateway.example.com/api/resources

Call a resource

bash
npm install @modelcontextprotocol/sdk
agent.tstypescript
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';

const client = new Client({ name: 'my-agent', version: '1.0.0' }, { capabilities: {} });
await client.connect(
  new StreamableHTTPClientTransport(new URL('https://gateway.example.com/mcp')),
);

const { tools } = await client.listTools();
// Paid tools state their price in the description and accept `_payment`.

const result = await client.callTool({
  name: 'basic_weather',
  arguments: { city: 'Berlin' },
});

A paid tool called without a proof returns isError: true with the payment envelope in structuredContent. Continue with Handle a payment.

Handle errors

Failures use one envelope with a typed code and a retryable flag. Retry only when retryable is true — PAYMENT_PROVIDER_UNAVAILABLE, AUTHORIZATION_PROVIDER_UNAVAILABLE, BACKEND_TIMEOUT and GATEWAY_BUSY. See Errors.