get_subscription
Retrieve subscription details by ID to access payment information, mandate links, and manage recurring billing data through GoCardless payment platform.
Instructions
Get subscription by ID. Returns links.mandate - use get_mandate then get_customer for full details, or use get_subscription_details instead.
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:451-472 (handler)The core handler logic for the 'get_subscription' tool. It extracts the subscription_id from arguments, fetches the subscription using the GoCardless client, constructs a result dictionary with key fields and links, formats it as JSON, and returns it as TextContent.elif name == "get_subscription": subscription_id = arguments["subscription_id"] subscription = client.subscriptions.get(subscription_id) result = { "id": subscription.id, "amount": subscription.amount, "currency": subscription.currency, "status": subscription.status, "interval_unit": subscription.interval_unit, "interval": subscription.interval, "created_at": subscription.created_at, "name": subscription.name, "start_date": subscription.start_date, "end_date": subscription.end_date, "metadata": subscription.metadata if hasattr(subscription, 'metadata') else {}, "links": { "mandate": subscription.links.mandate if hasattr(subscription, 'links') else None, }, } return [ types.TextContent(type="text", text=_format_json(result)) ]
- src/gocardless_mcp/server.py:205-218 (registration)Registration of the 'get_subscription' tool in the list_tools() handler. Defines the tool name, description, and input schema requiring 'subscription_id'.types.Tool( name="get_subscription", description="Get subscription by ID. Returns links.mandate - use get_mandate then get_customer for full details, or use get_subscription_details instead.", inputSchema={ "type": "object", "properties": { "subscription_id": { "type": "string", "description": "The GoCardless subscription ID (e.g., SB123)", } }, "required": ["subscription_id"], }, ),
- src/gocardless_mcp/server.py:208-217 (schema)Input schema for the 'get_subscription' tool, specifying an object with a required 'subscription_id' string property.inputSchema={ "type": "object", "properties": { "subscription_id": { "type": "string", "description": "The GoCardless subscription ID (e.g., SB123)", } }, "required": ["subscription_id"], },