AgentPayClient
is the primary interface for interacting with the AgentPay system from your Python MCP server.
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.Initialization
To begin, you need to import and initialize theAgentPayClient
:
AgentPayClient
Constructor
AgentPayClient(service_token: str)
service_token
(str, required):- Your unique Service Token obtained from the AgentPay Hub after registering your MCP server.
- This token authenticates your server with AgentPay.
- Security Note: The Service Token is highly sensitive. It is strongly recommended to load it from an environment variable or a secure secrets management system rather than hardcoding it.
Singleton Pattern (Recommended)
It’s generally recommended to initialize theAgentPayClient
once and reuse the instance throughout your application. This avoids redundant initializations and can be more efficient. How you achieve this depends on your web framework:
- In Starlette, you might store it on the application object
- In Flask, you might use the application context
- In Django, you might use a custom middleware
Error Handling
Ensure proper error handling when initializing the client:Methods
This SDK reference page focuses on theAgentPayClient
object initialization. For details on its methods, see: