list_subscriptions
Retrieve and filter subscription data from GoCardless to manage recurring payments, view status, and monitor customer billing cycles.
Instructions
List subscriptions from GoCardless
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of subscriptions to retrieve (default: 50) | |
| status | No | Filter by subscription status |
Implementation Reference
- src/gocardless_mcp/server.py:427-449 (handler)The core handler logic for the 'list_subscriptions' tool. It retrieves subscriptions from the GoCardless API using optional limit and status parameters, extracts key fields, and returns a formatted JSON list.elif name == "list_subscriptions": params = {"limit": arguments.get("limit", 50)} if "status" in arguments: params["status"] = arguments["status"] subscriptions = client.subscriptions.list(params=params) result = [] for subscription in subscriptions.records: result.append( { "id": subscription.id, "amount": subscription.amount, "currency": subscription.currency, "status": subscription.status, "created_at": subscription.created_at, } ) return [ types.TextContent( type="text", text=f"Found {len(result)} subscriptions:\n{_format_json(result)}", ) ]
- src/gocardless_mcp/server.py:188-204 (registration)Registers the 'list_subscriptions' tool in the list_tools handler, including its description and input schema definition.types.Tool( name="list_subscriptions", description="List subscriptions from GoCardless", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of subscriptions to retrieve (default: 50)", }, "status": { "type": "string", "description": "Filter by subscription status", }, }, }, ),
- src/gocardless_mcp/server.py:191-203 (schema)Input schema for the 'list_subscriptions' tool, defining optional limit and status parameters.inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of subscriptions to retrieve (default: 50)", }, "status": { "type": "string", "description": "Filter by subscription status", }, }, },
- src/gocardless_mcp/server.py:559-562 (helper)Helper function used by the list_subscriptions handler (and others) to format the result as pretty-printed JSON.def _format_json(data: Any) -> str: """Format data as JSON string.""" import json return json.dumps(data, indent=2)