get_subscription_details
Retrieve complete subscription information including mandate and customer details in a single API call using the subscription ID.
Instructions
Get complete subscription info including mandate and customer in one call
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subscription_id | Yes | The GoCardless subscription ID (e.g., SB123) |
Implementation Reference
- src/gocardless_mcp/server.py:474-525 (handler)Handler logic for get_subscription_details tool: fetches subscription by ID, then linked mandate and customer, formats them into a nested JSON structure and returns as text content.elif name == "get_subscription_details": subscription_id = arguments["subscription_id"] # Get subscription subscription = client.subscriptions.get(subscription_id) # Get mandate mandate = client.mandates.get(subscription.links.mandate) # Get customer customer = client.customers.get(mandate.links.customer) result = { "subscription": { "id": subscription.id, "name": subscription.name, "amount": subscription.amount, "currency": subscription.currency, "status": subscription.status, "interval_unit": subscription.interval_unit, "interval": subscription.interval, "start_date": subscription.start_date, "end_date": subscription.end_date, "created_at": subscription.created_at, "metadata": subscription.metadata if hasattr(subscription, 'metadata') else {}, }, "mandate": { "id": mandate.id, "reference": mandate.reference, "status": mandate.status, "scheme": mandate.scheme, "created_at": mandate.created_at, "metadata": mandate.metadata if hasattr(mandate, 'metadata') else {}, }, "customer": { "id": customer.id, "email": customer.email, "given_name": customer.given_name, "family_name": customer.family_name, "company_name": customer.company_name, "address_line1": customer.address_line1, "address_line2": customer.address_line2, "city": customer.city, "postal_code": customer.postal_code, "country_code": customer.country_code, "created_at": customer.created_at, "metadata": customer.metadata if hasattr(customer, 'metadata') else {}, }, } return [ types.TextContent(type="text", text=_format_json(result)) ]
- src/gocardless_mcp/server.py:219-232 (registration)Registration of the get_subscription_details tool in the list_tools handler, including its name, description, and input schema requiring subscription_id.types.Tool( name="get_subscription_details", description="Get complete subscription info including mandate and customer in one call", inputSchema={ "type": "object", "properties": { "subscription_id": { "type": "string", "description": "The GoCardless subscription ID (e.g., SB123)", } }, "required": ["subscription_id"], }, ),
- src/gocardless_mcp/server.py:222-232 (schema)Input schema for get_subscription_details tool: requires a subscription_id string.inputSchema={ "type": "object", "properties": { "subscription_id": { "type": "string", "description": "The GoCardless subscription ID (e.g., SB123)", } }, "required": ["subscription_id"], }, ),