upgrade_subscription
Convert your free todo management account to a paid plan to access premium features and remove usage limits.
Instructions
Upgrade user subscription to paid plan
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| authToken | Yes | Authentication token from Kinde |
Implementation Reference
- src/server.ts:270-283 (registration)Registration of the 'upgrade_subscription' tool in the listTools handler, including its name, description, and input schema that requires an authToken.{ name: 'upgrade_subscription', description: 'Upgrade user subscription to paid plan', inputSchema: { type: 'object', properties: { authToken: { type: 'string', description: 'Authentication token from Kinde', }, }, required: ['authToken'], }, },
- src/server.ts:273-282 (schema)Input schema definition for the upgrade_subscription tool, specifying the required authToken parameter.inputSchema: { type: 'object', properties: { authToken: { type: 'string', description: 'Authentication token from Kinde', }, }, required: ['authToken'], },
- src/server.ts:512-548 (handler)The handler logic for the upgrade_subscription tool. It validates the authToken argument, verifies the token to get user info, simulates a subscription upgrade by updating the database to set subscription_status to 'active' and plan to 'premium', and returns a success message.case 'upgrade_subscription': { const validation = validateArgs(args, ['authToken']); if (!validation.valid) { return { content: [{ type: 'text', text: `Error: ${validation.error}` }], }; } const user = await verifyToken(validation.validatedArgs!.authToken as string); if (!user) { return { content: [{ type: 'text', text: 'Error: Invalid authentication token' }], }; } // In a real implementation, you would integrate with a payment processor // For now, we'll simulate the upgrade await sql` INSERT INTO users (user_id, subscription_status, plan) VALUES (${user.userId}, 'active', 'premium') ON CONFLICT (user_id) DO UPDATE SET subscription_status = 'active', plan = 'premium' `; return { content: [{ type: 'text', text: JSON.stringify({ success: true, message: 'Subscription upgraded successfully! You can now create unlimited todos.', subscriptionStatus: 'active' }, null, 2) }], }; }
- src/server.ts:203-215 (helper)General helper function validateArgs used by the upgrade_subscription handler to check for required arguments like authToken.function validateArgs(args: any, requiredFields: string[]): { valid: boolean; error?: string; validatedArgs?: any } { if (!args) { return { valid: false, error: 'Missing arguments' }; } for (const field of requiredFields) { if (!args[field]) { return { valid: false, error: `Missing required field: ${field}` }; } } return { valid: true, validatedArgs: args }; }