list_mandates
Retrieve and filter customer payment mandates from GoCardless to manage recurring payment authorizations and track active direct debit agreements.
Instructions
List mandates from GoCardless
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer | No | Filter by customer ID | |
| limit | No | Number of mandates to retrieve (default: 50) |
Implementation Reference
- src/gocardless_mcp/server.py:386-407 (handler)Executes the list_mandates tool: constructs params with limit and optional customer filter, lists mandates via GoCardless client, extracts key fields into a result list, and returns formatted text content.elif name == "list_mandates": params = {"limit": arguments.get("limit", 50)} if "customer" in arguments: params["customer"] = arguments["customer"] mandates = client.mandates.list(params=params) result = [] for mandate in mandates.records: result.append( { "id": mandate.id, "status": mandate.status, "scheme": mandate.scheme, "created_at": mandate.created_at, } ) return [ types.TextContent( type="text", text=f"Found {len(result)} mandates:\n{_format_json(result)}", ) ]
- src/gocardless_mcp/server.py:157-173 (registration)Registers the list_mandates tool in the list_tools() method, providing name, description, and input schema for parameters limit and customer.types.Tool( name="list_mandates", description="List mandates from GoCardless", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of mandates to retrieve (default: 50)", }, "customer": { "type": "string", "description": "Filter by customer ID", }, }, }, ),
- src/gocardless_mcp/server.py:157-173 (schema)Defines the input schema for list_mandates tool validation: object with optional integer limit and string customer.types.Tool( name="list_mandates", description="List mandates from GoCardless", inputSchema={ "type": "object", "properties": { "limit": { "type": "integer", "description": "Number of mandates to retrieve (default: 50)", }, "customer": { "type": "string", "description": "Filter by customer ID", }, }, }, ),
- src/gocardless_mcp/server.py:14-21 (helper)Helper function to initialize and return the GoCardless API client, used by the list_mandates handler.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)
- src/gocardless_mcp/server.py:559-562 (helper)Helper function to format result data as indented JSON string, used in the list_mandates response.def _format_json(data: Any) -> str: """Format data as JSON string.""" import json return json.dumps(data, indent=2)