# Agentic payments with x402 protocol

Agentic payments enable AI agents to autonomously run Apify Actors using third-party payment providers, without requiring traditional Apify user accounts. This allows agents to discover, execute, and pay for web scraping and automation tasks independently.

Apify supports agentic payments through the [x402 protocol](https://www.x402.org/), an open standard for internet-native payments.

Experimental feature

Agentic payments are an experimental feature and may change significantly as payment protocols and AI technologies evolve.

## What is x402

The [x402 protocol](https://www.x402.org/) is an open standard for internet-native payments. It enables direct on-chain payments using USDC on the [Base](https://www.base.org/) blockchain.

The Apify MCP server implements an MCP extension of this protocol to support agentic payments. The client automatically detects payment requirements in the tool's metadata and signs a USDC payment on the Base blockchain (mainnet). This payment is included with the tool call - no human intervention needed.

## Use x402 with Apify MCP server

The [Apify MCP server](https://pr-2390.preview.docs.apify.com/platform/integrations/mcp.md) provides the simplest way for agents to access Apify's Actor library using x402 payments.

### Prerequisites

* *`mcpc` CLI* - Install the [mcpc CLI](https://github.com/apify/mcp-cli) (`npm install -g @apify/mcpc`), the Universal MCP command-line client.
* *USDC on Base* - A wallet funded with USDC on the [Base](https://www.base.org/) mainnet blockchain.

### Setup

Set up a local wallet and connect to the Apify MCP server with x402 payment support.

1. Create or import a wallet:


   ```
   # Create a new wallet (generates a random private key)
   mcpc x402 init

   # Or import an existing wallet from a private key
   mcpc x402 import <private-key>

   # Verify your wallet address
   mcpc x402 info
   ```


2. Fund the wallet with USDC on Base mainnet.

3. Connect to the Apify MCP server with x402 payment mode enabled. Add the `?payment=x402` query parameter to the server URL and pass the `--x402` flag to `mcpc`:


   ```
   mcpc connect "mcp.apify.com?payment=x402" @apify --x402
   ```


4. Call tools as usual. Payments are handled automatically:


   ```
   mcpc @apify tools-call call-actor actor:="apify/rag-web-browser" input:='{"query": "latest AI news"}'
   ```


### How it works

When x402 payment mode is enabled, the agent handles the full payment flow autonomously:

1. The Apify MCP server advertises payment requirements in each paid tool's metadata.
2. When `mcpc` calls a paid tool, it automatically signs a USDC payment using your local wallet and includes it in the request.
3. The server verifies and settles the payment on-chain, then executes the tool and returns the result.
4. If a tool is called without a payment, the server responds that payment is required and `mcpc` signs and retries automatically.

The Apify MCP server requires a minimum transaction of $1.00. The server tracks the payment as a balance. Subsequent tool calls draw from this balance without requiring a new on-chain transaction. When the balance runs out, `mcpc` automatically signs a new payment to top it up. After a period of inactivity, the server refunds any remaining unused balance to the client's wallet address on the Base blockchain.
