> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentpay.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Payments for MCP Servers and the Agent Economy.

## What is AgentPay?

As AI agents and the [Model Context Protocol (MCP)](https://modelcontextprotocol.io) ecosystem grow, developers need a frictionless way to charge for usage, and users need a seamless way to pay.

**AgentPay is the payments layer for MCP Servers**, purpose-built for the agent economy.

It integrates with the **latest MCP standards** and tooling, making it effortless for **MCP Developers** to monetize and for **MCP Users** to connect and pay.

<Note>
  AgentPay is currently in **Early Access**. To get early access to AgentPay, please [sign up for the Waitlist here](https://agentpay.me).
</Note>

### Familiar Payments for a New Ecosystem

Before we delve into the architecture of how it works, let's simplify the core concept.

<Frame caption="Typical AI Service">
  ```mermaid theme={null}
      graph
          User[User] <-- Balance, API Keys, Usage, Earnings --> Service[Service]
  ```
</Frame>

Imagine the way you currently interact with many modern AI services (like OpenAI, Anthropic, or various cloud APIs). You typically sign up, get an API key, and preload a balance. Your API key then grants you access, and you're billed against your balance based on your usage.

**AgentPay brings this familiar, battle-tested model to the world of MCP Servers.**

```mermaid theme={null}
    graph
        User[User] <-- Balance & API Keys --> AgentPay(AgentPay)
        AgentPay <-- Usage & Earnings --> MCP1[MCP Server 1]
        AgentPay <-- Usage & Earnings --> MCP2[MCP Server 2]
        AgentPay <-- Usage & Earnings --> MCP3[MCP Server 3]
    
    style AgentPay fill:#00E6E9,stroke:#333,stroke-width:1px,color:#333;
```

* **For MCP Users** ⎯ It's like having a **universal access pass**:
  * You maintain an AgentPay account with a **single balance**.
  * When you want to use a specific MCP Server that's integrated with AgentPay, you obtain a unique **API Key** for that server.
  * You then add your API Key to your MCP client configuration (e.g. Claude, Cursor) to use this key to make requests.
  * If the tool has a cost, AgentPay seamlessly deducts it from your balance upon successful use.
  * No complex per-server payment setups, just straightforward, metered access.

* **For MCP Developers** ⎯ It's your **turnkey monetization solution**:
  * You've built valuable features ⎯ tools, resources, prompts, and more ⎯ on your MCP Server.
  * By integrating AgentPay, you can define a price for each usage of each feature, and start earning immediately.
  * When an authenticated user (with a valid API Key and sufficient balance) successfully uses a feature, AgentPay handles the balance transfer to your earnings, which are then paid out to you.
  * No need to build and maintain your own complex infrastructure for payments, API, or metering, just one simple, flexible integration.

At its heart, AgentPay establishes a clear, trusted, and standardized "pay-as-you-go" relationship between MCP Users and MCP Server Developers, all facilitated by API keys and managed balances, and built to conform with MCP standards. This allows developers to focus on building great tools and users to access them with ease and transparency.

## How does it work?

AgentPay provides a **standardized, end-to-end solution** for MCP Servers to manage access and bill for usage from MCP Clients. It provides **API Keys** for Users and **Service Tokens** for Developers, allowing AgentPay to:

* **Authenticate requests** from MCP Clients to MCP Servers.
* **Track usage** of MCP Server resources.
* **Handle payments**, like user balances and developer payouts.

Generally speaking, there are **three key aspects** to understand:

### 1. Setup: Acquiring Tokens and Keys

In order to use or monetize MCP Servers, **Developers and Users** must first hop on **AgentPay Hub** to get their respective credentials.

* **AgentPay Hub** ⎯ The central AgentPay **web platform** where:
  * **MCP Developers** register their MCP Servers, obtain Service Tokens, manage Server metadata, view revenue dashboards, and configure payouts.
  * **MCP Users** discover MCP Servers, obtain API Keys, and manage their account balance.

```mermaid theme={null}
graph
    subgraph Developer Setup Flow
        Dev((MCP Developer)) -- Registers MCP Server --> Hub[AgentPay Hub]
        Hub -- Issues Service Token --> Dev
        Dev -- Integrates SDK & Token --> Server[MCP Server]
    end
```

* **MCP Developer** ⎯ Developer of the **MCP Server** who:
  * **Registers their MCP Server** on AgentPay Hub.
  * **Receives a Service Token**, which uniquely identifies their server and authenticates its requests to the AgentPay Service (e.g., when reporting usage).
  * **Integrates the AgentPay SDK** in their MCP Server using their Service Token.

```mermaid theme={null}
graph
    subgraph User Setup Flow
        User((MCP User)) -- Activates MCP Server --> Hub2[AgentPay Hub]
        Hub2 -- Issues API Key --> User
        User -- Adds API Key to Config --> Client[MCP Client]
    end
```

* **MCP User** ⎯ User of an MCP Server via an **MCP Client** who:
  * **Activates an MCP Server** they want to access via AgentPay Hub.
  * **Obtains an API Key** for that server, which identifies the user and is used to authorize their requests and track their balance.
  * **Adds the API Key** to their MCP Client configuration.

### 2. Runtime: Processing MCP Requests

Once setup is complete, here's how a typical interaction unfolds when an **MCP Client makes a request to an MCP Server**:

```mermaid theme={null}
sequenceDiagram
    participant C as MCP Client
    participant S as MCP Server (with AgentPay SDK)
    participant AP as AgentPay Service

    C->>S: Request (incl. API Key)
    activate S
    S->>S: SDK: Extract API Key from request
    S->>AP: SDK: Validate API Key
    activate AP
    AP-->>S: Validation Result (e.g. Valid)
    deactivate AP
    S->>S: Process original client request
    note over S, AP: After successful processing, report usage
    S->>AP: SDK: Consume Balance
    activate AP
    AP-->>S: Consumption Result (e.g. Success)
    deactivate AP
    S-->>C: Response to original request
    deactivate S
```

* **MCP Client** (with **API Key** configured) ⎯ When called by the User or Agent:
  * **Makes a request** to the remote MCP Server.
  * **Sends the User's API Key** to the target MCP Server as part of the request (typically in a header).
* **MCP Server** (with **AgentPay SDK** integrated) ⎯ Upon receiving a request:
  * **Extracts the User's API Key** (e.g. using AgentPay SDK auth helpers).
  * (Optionally) **Validates the API Key** via the AgentPay Service.
  * **Processes the client's request** (executes its core tool logic).
  * If the tool logic is successful, it **consumes the User's balance** via the AgentPay Service (using the SDK, the User's API Key, and its own Service Token) for an agreed `amount_cents`.
* **AgentPay Service** (via the **AgentPay SDK**) ⎯ The core AgentPay backend service which:
  * **Validates API Keys** and **Service Tokens**.
  * **Processes usage requests** by debiting the user's balance and crediting the developer's earnings.
  * **Manages the ledger** for all balances and transactions.

### 3. Payment: The Flow of Funds

AgentPay facilitates a direct and transparent flow of funds, enabling users to pay for services and developers to earn revenue.

<Frame>
  ```mermaid theme={null}
  graph
      User[MCP User] -- Adds Funds --> UserBalance[User's AgentPay Balance];
      UserBalance -- Obtains API Key --> Consumption[Server Usage via API Key];
      Consumption -- Processed by AgentPay --> DeveloperEarnings[Developer's Accrued Earnings];
      DeveloperEarnings -- Payout via Configured Method --> Developer[MCP Developer];
  ```
</Frame>

**The process unfolds in these key stages:**

* **MCP User Funds AgentPay Balance:**
  * MCP Users add funds to their AgentPay account, establishing a balance to pay for MCP Server usage.

* **Tool Consumption & Charging:**
  * When an MCP User's client successfully uses a paid feature (tool, resource, etc.) on an MCP Server:
    * The MCP Server, after its own logic succeeds, triggers a charge using the AgentPay SDK.
    * This involves the User's API Key (identifying the payer) and the Developer's Service Token (identifying the payee).

* **Transaction Processing by AgentPay:**
  * AgentPay validates the transaction details (API Key, Service Token, sufficient funds).
  * The specified amount (`amount_cents`) is deducted from the User's balance.
  * The corresponding amount (less any AgentPay service fees) is credited to the MCP Developer's earnings ledger within AgentPay.

* **MCP Developer Payouts:**
  * MCP Developers can view their accumulated earnings on AgentPay Hub.
  * Earnings are typically paid out monthly.
  * Developers configure their preferred payout method (e.g., Stripe Connect for bank transfers, or supported stablecoins).

And that's it! Now you have a complete overview of AgentPay and can start diving deeper into the growing ecosystem of premium MCP Servers.

## Get started

<Note>
  AgentPay is currently in **Early Access**. To get early access to AgentPay, please [sign up for the Waitlist here](https://agentpay.me).
</Note>

Jump right in with the appropriate Quickstart for you.

### Quickstarts

<Columns cols={2}>
  <Card title="MCP Server Developers" icon="server" href="./quickstart/developers">
    For developers looking to integrate AgentPay into their MCP Server.
  </Card>

  <Card title="MCP Client Users" icon="users" href="./quickstart/users">
    For users who want to use MCP Servers that have AgentPay integrated.
  </Card>
</Columns>
