list_payments
Retrieve and filter GoCardless payment records by status, subscription, or mandate to monitor transaction activity.
Instructions
List payments from GoCardless
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of payments to retrieve (default: 50) | |
| status | No | Filter by payment status (pending_customer_approval, pending_submission, submitted, confirmed, paid_out, cancelled, customer_approval_denied, failed, charged_back) | |
| subscription | No | Filter by subscription ID (e.g., SB123) | |
| mandate | No | Filter by mandate ID (e.g., MD123) |
Implementation Reference
- src/gocardless_mcp/server.py:319-346 (handler)Handler implementation for list_payments tool: constructs params from arguments, calls client.payments.list(), formats and returns list of payments.elif name == "list_payments": params = {"limit": arguments.get("limit", 50)} if "status" in arguments: params["status"] = arguments["status"] if "subscription" in arguments: params["subscription"] = arguments["subscription"] if "mandate" in arguments: params["mandate"] = arguments["mandate"] payments = client.payments.list(params=params) result = [] for payment in payments.records: result.append( { "id": payment.id, "amount": payment.amount, "currency": payment.currency, "status": payment.status, "description": payment.description, "created_at": payment.created_at, } ) return [ types.TextContent( type="text", text=f"Found {len(result)} payments:\n{_format_json(result)}", ) ]
- src/gocardless_mcp/server.py:92-116 (registration)Registration of the list_payments tool in handle_list_tools(), including name, description, and input schema definition.types.Tool( name="list_payments", description="List payments from GoCardless", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of payments to retrieve (default: 50)", }, "status": { "type": "string", "description": "Filter by payment status (pending_customer_approval, pending_submission, submitted, confirmed, paid_out, cancelled, customer_approval_denied, failed, charged_back)", }, "subscription": { "type": "string", "description": "Filter by subscription ID (e.g., SB123)", }, "mandate": { "type": "string", "description": "Filter by mandate ID (e.g., MD123)", }, }, }, ),
- src/gocardless_mcp/server.py:95-114 (schema)Input schema definition for the list_payments tool, defining optional parameters for filtering payments.inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of payments to retrieve (default: 50)", }, "status": { "type": "string", "description": "Filter by payment status (pending_customer_approval, pending_submission, submitted, confirmed, paid_out, cancelled, customer_approval_denied, failed, charged_back)", }, "subscription": { "type": "string", "description": "Filter by subscription ID (e.g., SB123)", }, "mandate": { "type": "string", "description": "Filter by mandate ID (e.g., MD123)", }, },
- src/gocardless_mcp/server.py:14-21 (helper)Helper function get_client() used by all tools including list_payments to initialize the GoCardless client.def get_client() -> gocardless_pro.Client: """Initialize and return GoCardless client.""" access_token = os.environ.get("GOCARDLESS_ACCESS_TOKEN") if not access_token: raise ValueError("GOCARDLESS_ACCESS_TOKEN environment variable is required") environment = os.environ.get("GOCARDLESS_ENVIRONMENT", "sandbox") return gocardless_pro.Client(access_token=access_token, environment=environment)