get_customer
Retrieve customer details by ID from GoCardless to access payment information, mandates, and subscription data for account management.
Instructions
Get a specific customer by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customer_id | Yes | The GoCardless customer ID (e.g., CU123) |
Implementation Reference
- src/gocardless_mcp/server.py:279-298 (handler)Handler logic for the 'get_customer' tool: retrieves customer by ID from GoCardless API, formats response with customer details including address and metadata.elif name == "get_customer": customer_id = arguments["customer_id"] customer = client.customers.get(customer_id) result = { "id": customer.id, "email": customer.email, "given_name": customer.given_name, "family_name": customer.family_name, "company_name": customer.company_name, "created_at": customer.created_at, "address_line1": customer.address_line1, "address_line2": customer.address_line2, "city": customer.city, "postal_code": customer.postal_code, "country_code": customer.country_code, "metadata": customer.metadata if hasattr(customer, 'metadata') else {}, } return [ types.TextContent(type="text", text=_format_json(result)) ]
- src/gocardless_mcp/server.py:52-65 (registration)Registration of the 'get_customer' tool in the list_tools handler, including name, description, and input schema requiring customer_id.types.Tool( name="get_customer", description="Get a specific customer by ID", inputSchema={ "type": "object", "properties": { "customer_id": { "type": "string", "description": "The GoCardless customer ID (e.g., CU123)", } }, "required": ["customer_id"], }, ),
- src/gocardless_mcp/server.py:14-22 (helper)Helper function to create and return the GoCardless client instance, used by the get_customer 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)