AgentPay is currently in Early Access. To get early access to AgentPay, please sign up for the Waitlist here.
- Registering your MCP Server on the AgentPay Hub and getting your Service Token.
- Integrating the AgentPay SDK, by:
- Installing the AgentPay Python SDK (Node.js coming soon!).
- Initializing
AgentPayClient
with your Service Token. - Using the
consume()
method to charge for tool usage. - Running to a full example implementation.
- Tracking your earnings and getting paid via AgentPay Hub.
Prerequisites
This quickstart guide assumes a working knowledge of:- Python
- MCP (Model Context Protocol) specifications and Server development
1. Register & Get Service Token
First, you’ll need to register your MCP Server on the AgentPay Hub. This is where you’ll also receive your unique Service Token, which is essential for authenticating your server with AgentPay. Steps:- Sign Up / Log In: Head over to AgentPay and sign up or log in.
As AgentPay is in Early Access, access is currently managed via our Waitlist, which you can sign up for here.
- Navigate to Servers: Once logged in, you’ll find a “My Servers” tab in the main navigation.
-
Register New Server: Within the “My Servers” section, click on “Register New Server” and complete the relevant fields, like name and description (all information can be updated later).
- Please note: You will see fields to describe your server’s pricing. This is display-only information for users to understand more about your service offering.
- However, the actual charging logic and amounts are defined by you in your SDK integration. For more details on pricing, see Defining Your Pricing Models.
-
Receive Your Service Token: Upon successful registration, your unique Service Token will be displayed.
- It will look something like this:
st-apay-7sj3...-98dk...
- Critical: This token is shown to you only once. Copy it immediately and store it in a secure place (e.g. a password manager or environment file).
- If you lose it, you can regenerate a new one, but this will invalidate the old token, requiring you to update your server configuration.
- It will look something like this:
2. Integrating the AgentPay SDK
Next, let’s go through the key steps to integrate the AgentPay SDK.i. Install AgentPay Python SDK
Open your terminal or command prompt, activate your project’s virtual environment (recommended), and run the following command:agentpay-sdk
and its dependencies.
The
agentpay-sdk
package currently on PyPI is a placeholder to reserve the name during Early Access. To get the actual SDK now, join the Waitlist.ii. Initialize AgentPayClient
In your Python server code, import and initializeAgentPayClient
. This client object is your main interface for interacting with AgentPay.
AgentPayClient
in the AgentPayClient Initialization Guide or the AgentPayClient SDK Reference.
iii. Add a Consumption Call
When a user calls one of your paid tools, you’ll use theconsume()
method to record the usage and charge them using their User API Key.
- Please note: This quickstart assumes you have already extracted the user’s User API Key from the incoming request (typically from a header like
X-AGENTPAY-API-KEY
). - For guidance on how to extract the User API Key in various Python web frameworks, please see Extracting API Keys from Requests.
- To learn more about this, refer to Validating User API Keys.
consume()
call into a tool function, following the best practice of processing your tool’s core logic before attempting to charge:
- Service Token: Your server’s secret key for AgentPay.
- User API Key: The key your client users use to authenticate with your server, which AgentPay uses for billing.
- Consumption: The act of recording usage and charging a user via AgentPay.
AgentPay handles complex payment scenarios automatically. If a user’s balance is insufficient, the system will track the outstanding payment and automatically process it when they add funds. This means you can focus on building great tools while AgentPay manages the payment complexities.
consume()
method, including all parameters, response objects, and advanced error handling, please see the detailed guide on Charging for Usage and the Consume Method SDK Reference.
iv. Run a Full Example
To see a more complete, runnable example of an MCP Server integrated with AgentPay, including how to set it up and test the flows, please refer to our Example Implementation.3. Tracking Earnings & Getting Paid
Once your server is operational and processing paid requests, you’ll be able to track your accumulated earnings directly within the AgentPay Hub. AgentPay facilitates payouts of these earnings, typically on a monthly basis. You can configure your preferred payout method in the Hub, with options including:- Stripe Connect Express: For receiving payouts in fiat currency to your bank account.
- Stablecoins: For receiving payouts in supported cryptocurrencies.