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

# Agent quickstart

> Use ATXP to build agents that pay for tool calls

Build agents that can safely discover and use paid MCP (Model Context Protocol) tools without creating vendor accounts or managing API keys. With ATXP, your agent brings a wallet and pays per request, so you can start building immediately and ship faster.

## Why build with ATXP?

* **Reduced friction**: Try new tools in minutes—no signups, no keys, no billing setup.
* **Pay-as-you-go cost control**: Per-MCP-tool-call pricing; you only pay for what you use.
* **Better security**: Keep secrets out of your app; requests are authorized with signed payments instead of shared keys.
* **Composable tooling**: Combine multiple paid MCP servers behind a single client and consistent API.

## Build your first ATXP agent

<Steps>
  <Step title="Install the library">
    Install the [ATXP client SDK](https://www.npmjs.com/package/@atxp/client) in your project:

    ```bash theme={null}
    npm install @atxp/client
    ```
  </Step>

  <Step title="Set up your account">
    <Tabs>
      <Tab title="ATXP account">
        <a href="/developers/build-agents/create-account" target="_blank">Create an ATXP account</a> and set your account connection string in an environment variable. The best way to do this is to create a `.env` file in the root of your project and add the following line:

        ```bash .env lines theme={null}
        ATXP_CONNECTION=https://accounts.atxp.ai?connection_token=<random_string>
        ```
      </Tab>

      <Tab title="Base Mini App account">
        You can use ATXP to pay for MCP tool calls made from within a Base Mini App. This approach uses a paymaster to pay for gas on behalf of the Mini App's end-users.

        In order to use a ATXP with a Base Mini App, you must have a Base Mini App API key from the [Coinbase Developer Portal](https://portal.cdp.coinbase.com/projects/api-keys/client-key). You then need to set the Base Mini App API key in an environment variable. The best way to do this is to create a `.env` file in the root of your project and add the following line:

        ```bash .env lines theme={null}
        NEXT_PUBLIC_ONCHAINKIT_API_KEY=<YOUR_NEXT_PUBLIC_ONCHAINKIT_API_KEY>
        ```
      </Tab>

      <Tab title="Base account">
        If you already have a Base wallet, you can use it in your ATXP agent by setting the Base endpoint and your Base private key in environment variables. The best way to do this is to create a `.env` file in the root of your project and add the following lines:

        ```bash .env lines theme={null}
        BASE_RPC_URL=<YOUR_BASE_RPC_URL>
        BASE_PRIVATE_KEY=<YOUR_BASE_PRIVATE_KEY>
        ```
      </Tab>

      <Tab title="Solana account">
        If you already have a Solana wallet, you can use it in your ATXP agent by setting the Solana endpoint and your Solana private key in environment variables. The best way to do this is to create a `.env` file in the root of your project and add the following lines:

        ```bash .env lines theme={null}
        SOLANA_RPC_URL=<YOUR_SOLANA_RPC_URL>
        SOLANA_PRIVATE_KEY=<YOUR_SOLANA_PRIVATE_KEY>
        ```
      </Tab>

      <Tab title="Worldchain account">
        ATXP Worldchain is designed for World Chain Mini Apps using MiniKit. Users authenticate through World App, and transactions are signed via MiniKit's secure interface. No environment variables or private keys are needed - the integration uses World App's wallet functionality directly.
      </Tab>

      <Tab title="Polygon account">
        **For browser applications**: ATXP Polygon works with any EIP-1193 compatible wallet provider (e.g., MetaMask, Coinbase Wallet). Users will sign transactions directly with their wallet and pay gas fees in POL. No environment variables are needed.

        **For server/CLI applications**: If you're building a backend service or CLI tool, set the Polygon endpoint and your Polygon private key in environment variables. The best way to do this is to create a `.env` file in the root of your project and add the following lines:

        ```bash .env lines theme={null}
        POLYGON_RPC_URL=<YOUR_POLYGON_RPC_URL>
        POLYGON_PRIVATE_KEY=<YOUR_POLYGON_PRIVATE_KEY>
        ```
      </Tab>

      <Tab title="Other accounts">
        ATXP is broadly compatible with (Ethereum Virtual Machine) EVM chains and wallets. Please <a href="mailto:devrel@atxp.ai?subject=ATXP%20EVM%20Inquiry">contact us</a> for more information.
      </Tab>
    </Tabs>

    <Warning>
      Never commit your `.env` file to version control. It is a good idea to add your `.env` to your `.gitignore` file to prevent it from being committed.

      ```bash theme={null}
      echo .env >> .gitignore
      ```
    </Warning>
  </Step>

  <Step title="Define the services that you want to use">
    Define the services that you want to use in your client.

    ```typescript theme={null}
    const searchService = {
      mcpServer: 'https://search.mcp.atxp.ai/',
      toolName: 'search_search',
      description: 'search',
      getArguments: (query: string) => ({ query }),
      getResult: (result: any) => result.content[0].text
    };
    ```
  </Step>

  <Step title="Create an ATXP client">
    <Tabs>
      <Tab title="With an ATXP account">
        Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK
        import { atxpClient, ATXPAccount } from '@atxp/client';

        // Read the ATXP account details from environment variables
        const atxpConnectionString = process.env.ATXP_CONNECTION;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new ATXPAccount(atxpConnectionString),
        });
        ```
      </Tab>

      <Tab title="With a BaseApp account">
        Create a client using a Base Mini App account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK
        import { useAccount } from "wagmi";
        import { atxpClient } from '@atxp/client';
        import { BaseAppAccount } from '@atxp/base';

        // Read the Base mini app API key details from the environment variables
        const apiKey = process.env.NEXT_PUBLIC_ONCHAINKIT_API_KEY;
        const { address } = useAccount();

        // Create a BaseAppAccount object using the mini app API key
        const account = await BaseAppAccount.initialize({
          walletAddress: address,
          apiKey,
          appName: 'Mini App with ATXP',
          allowance: BigInt('10000000'), // 10 USDC
          periodInDays: 30,
        });
        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: account,
        });
        ```
      </Tab>

      <Tab title="With a Base account">
        Create a client using a Base account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Base account
        import { atxpClient } from '@atxp/client';
        import { BaseAccount } from '@atxp/base';

        // Read the Base account details from the environment variables
        const baseRpcUrl = process.env.BASE_RPC_URL;
        const basePrivateKey = process.env.BASE_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new BaseAccount(baseRpcUrl, basePrivateKey),
        });
        ```
      </Tab>

      <Tab title="With a Solana account">
        Create a client using a Solana account by importing the ATXP client SDK and other dependencies.

        ```typescript theme={null}
        // Import the ATXP client SDK and Solana account
        import { atxpClient } from '@atxp/client';
        import { SolanaAccount } from '@atxp/solana';

        // Read the Solana account details from the environment variables
        const solanaRpcUrl = process.env.SOLANA_RPC_URL;
        const solanaPrivateKey = process.env.SOLANA_PRIVATE_KEY;

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account: new SolanaAccount(solanaRpcUrl, solanaPrivateKey),
        });
        ```
      </Tab>

      <Tab title="With a Worldchain account">
        Create a client using a Worldchain account with MiniKit integration.

        ```typescript theme={null}
        // Import the ATXP client SDK and Worldchain account creator
        import { atxpClient } from '@atxp/client';
        import { createMiniKitWorldchainAccount } from '@atxp/worldchain';
        import { MiniKit } from '@worldcoin/minikit-js';

        // Create a Worldchain account using MiniKit
        const account = await createMiniKitWorldchainAccount({
          walletAddress: '0x1234...', // User's wallet address
          miniKit: MiniKit
        });

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```
      </Tab>

      <Tab title="With a Polygon account">
        **Browser applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon browser account
        import { atxpClient } from '@atxp/client';
        import { PolygonBrowserAccount } from '@atxp/polygon';

        // Initialize the Polygon browser account with wallet provider
        const account = await PolygonBrowserAccount.initialize({
          provider: window.ethereum, // or any EIP-1193 provider
          walletAddress: '0x1234...', // User's wallet address
        });

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```

        **Server/CLI applications:**

        ```typescript theme={null}
        // Import the ATXP client SDK and Polygon server account
        import { atxpClient } from '@atxp/client';
        import { PolygonServerAccount } from '@atxp/polygon';

        // Read the Polygon account details from the environment variables
        const polygonRpcUrl = process.env.POLYGON_RPC_URL;
        const polygonPrivateKey = process.env.POLYGON_PRIVATE_KEY;

        // Create a Polygon server account
        const account = new PolygonServerAccount(
          polygonRpcUrl,
          polygonPrivateKey,
          137 // Chain ID: 137 = Polygon mainnet, 80002 = Amoy testnet
        );

        // Create a client using the `atxpClient` function
        const client = await atxpClient({
          mcpServer: searchService.mcpServer,
          account,
        });
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Use the services in your agent">
    Use the services in your agent.

    ```typescript theme={null}
    const query = "latest news on the US financial sector";

    try {
      const result = await client.callTool({
          name: searchService.toolName,
          arguments: searchService.getArguments(query),
      });
      console.log(`${searchService.description} result successful!`);
      console.log('Result:', searchService.getResult(result));
    } catch (error) {
      console.error(`Error with ${searchService.description}:`, error);
      process.exit(1);
    }
    ```
  </Step>
</Steps>

## Resources

<CardGroup cols={3}>
  <Card title="Account Portal" icon="user" href="https://accounts.atxp.ai">
    Log in to manage your ATXP account, view usage, and add funds.
  </Card>

  <Card title="Build an agent using paid MCP servers" icon="robot" href="/developers/build-agents/tutorial">
    Follow a complete tutorial to build your first ATXP‑powered agent.
  </Card>

  <Card title="Monetize your MCP server" icon="messages-dollar" href="/developers/monetize">
    Get started monetizing your MCP server with ATXP.
  </Card>
</CardGroup>
