Skip to main content
Glama

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
NameRequiredDescriptionDefault
customerNoFilter by customer ID
limitNoNumber of mandates to retrieve (default: 50)

Implementation Reference

  • 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)}", ) ]
  • 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", }, }, }, ),
  • 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", }, }, }, ),
  • 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)
  • 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)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jmceleney/gocardless-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server