// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { Metadata, asTextContentResult } from 'dodopayments-mcp/tools/types';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import DodoPayments from 'dodopayments';
export const metadata: Metadata = {
resource: 'subscriptions',
operation: 'write',
tags: [],
httpMethod: 'patch',
httpPath: '/subscriptions/{subscription_id}',
operationId: 'patch_subscription_handler',
};
export const tool: Tool = {
name: 'update_subscriptions',
description: '',
inputSchema: {
type: 'object',
properties: {
subscription_id: {
type: 'string',
},
billing: {
$ref: '#/$defs/billing_address',
},
cancel_at_next_billing_date: {
type: 'boolean',
description: 'When set, the subscription will remain active until the end of billing period',
},
customer_name: {
type: 'string',
},
disable_on_demand: {
type: 'object',
title: 'Disable On Demand Request',
properties: {
next_billing_date: {
type: 'string',
format: 'date-time',
},
},
required: ['next_billing_date'],
},
metadata: {
type: 'object',
additionalProperties: true,
},
next_billing_date: {
type: 'string',
format: 'date-time',
},
status: {
$ref: '#/$defs/subscription_status',
},
tax_id: {
type: 'string',
},
},
required: ['subscription_id'],
$defs: {
billing_address: {
type: 'object',
properties: {
city: {
type: 'string',
description: 'City name',
},
country: {
$ref: '#/$defs/country_code',
},
state: {
type: 'string',
description: 'State or province name',
},
street: {
type: 'string',
description: 'Street address including house number and unit/apartment if applicable',
},
zipcode: {
type: 'string',
description: 'Postal code or ZIP code',
},
},
required: ['city', 'country', 'state', 'street', 'zipcode'],
},
country_code: {
type: 'string',
description: 'ISO country code alpha2 variant',
enum: [
'AF',
'AX',
'AL',
'DZ',
'AS',
'AD',
'AO',
'AI',
'AQ',
'AG',
'AR',
'AM',
'AW',
'AU',
'AT',
'AZ',
'BS',
'BH',
'BD',
'BB',
'BY',
'BE',
'BZ',
'BJ',
'BM',
'BT',
'BO',
'BQ',
'BA',
'BW',
'BV',
'BR',
'IO',
'BN',
'BG',
'BF',
'BI',
'KH',
'CM',
'CA',
'CV',
'KY',
'CF',
'TD',
'CL',
'CN',
'CX',
'CC',
'CO',
'KM',
'CG',
'CD',
'CK',
'CR',
'CI',
'HR',
'CU',
'CW',
'CY',
'CZ',
'DK',
'DJ',
'DM',
'DO',
'EC',
'EG',
'SV',
'GQ',
'ER',
'EE',
'ET',
'FK',
'FO',
'FJ',
'FI',
'FR',
'GF',
'PF',
'TF',
'GA',
'GM',
'GE',
'DE',
'GH',
'GI',
'GR',
'GL',
'GD',
'GP',
'GU',
'GT',
'GG',
'GN',
'GW',
'GY',
'HT',
'HM',
'VA',
'HN',
'HK',
'HU',
'IS',
'IN',
'ID',
'IR',
'IQ',
'IE',
'IM',
'IL',
'IT',
'JM',
'JP',
'JE',
'JO',
'KZ',
'KE',
'KI',
'KP',
'KR',
'KW',
'KG',
'LA',
'LV',
'LB',
'LS',
'LR',
'LY',
'LI',
'LT',
'LU',
'MO',
'MK',
'MG',
'MW',
'MY',
'MV',
'ML',
'MT',
'MH',
'MQ',
'MR',
'MU',
'YT',
'MX',
'FM',
'MD',
'MC',
'MN',
'ME',
'MS',
'MA',
'MZ',
'MM',
'NA',
'NR',
'NP',
'NL',
'NC',
'NZ',
'NI',
'NE',
'NG',
'NU',
'NF',
'MP',
'NO',
'OM',
'PK',
'PW',
'PS',
'PA',
'PG',
'PY',
'PE',
'PH',
'PN',
'PL',
'PT',
'PR',
'QA',
'RE',
'RO',
'RU',
'RW',
'BL',
'SH',
'KN',
'LC',
'MF',
'PM',
'VC',
'WS',
'SM',
'ST',
'SA',
'SN',
'RS',
'SC',
'SL',
'SG',
'SX',
'SK',
'SI',
'SB',
'SO',
'ZA',
'GS',
'SS',
'ES',
'LK',
'SD',
'SR',
'SJ',
'SZ',
'SE',
'CH',
'SY',
'TW',
'TJ',
'TZ',
'TH',
'TL',
'TG',
'TK',
'TO',
'TT',
'TN',
'TR',
'TM',
'TC',
'TV',
'UG',
'UA',
'AE',
'GB',
'UM',
'US',
'UY',
'UZ',
'VU',
'VE',
'VN',
'VG',
'VI',
'WF',
'EH',
'YE',
'ZM',
'ZW',
],
},
subscription_status: {
type: 'string',
enum: ['pending', 'active', 'on_hold', 'cancelled', 'failed', 'expired'],
},
},
},
annotations: {},
};
export const handler = async (client: DodoPayments, args: Record<string, unknown> | undefined) => {
const { subscription_id, ...body } = args as any;
return asTextContentResult(await client.subscriptions.update(subscription_id, body));
};
export default { metadata, tool, handler };