create_stripe_customer
Add a new customer to your Stripe account using this tool within the Advanced PocketBase MCP Server. Simplify customer management and integrate payment workflows with ease.
Instructions
Create a new customer in Stripe
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/services/stripe.ts:976-980 (registration)Registration of the 'create_stripe_customer' tool, including description, input schema, and inline handler function that uses StripeService to create the customer.server.tool('create_stripe_customer', 'Create a Stripe customer', { type: 'object', properties: { email: { type: 'string' }, name: { type: 'string' } } }, async (args: any) => { const stripeService = new StripeService(pb); const customer = await stripeService.createCustomer({ email: args.email, name: args.name }); return { success: true, customer }; });
- src/services/stripe.ts:69-107 (handler)The StripeService.createCustomer method which implements the core logic for creating a Stripe customer: checks for duplicates in PocketBase, creates in Stripe API, persists to PocketBase, returns the customer record.async createCustomer(data: { email: string; name?: string; userId?: string; metadata?: Record<string, any>; }): Promise<StripeCustomer> { try { // Check if customer already exists const existingCustomer = await this.pb.collection('stripe_customers') .getFirstListItem(`email="${data.email}"`) .catch(() => null); if (existingCustomer) { return existingCustomer as StripeCustomer; } // Create customer in Stripe const stripeCustomer = await this.stripe.customers.create({ email: data.email, name: data.name, metadata: { userId: data.userId || '', ...data.metadata, }, }); // Save to PocketBase const customerRecord = await this.pb.collection('stripe_customers').create({ email: data.email, name: data.name, stripeCustomerId: stripeCustomer.id, userId: data.userId, metadata: data.metadata || {}, }); return customerRecord as unknown as StripeCustomer; } catch (error: any) { throw new Error(`Failed to create customer: ${error.message}`); } }
- src/types/stripe.d.ts:18-27 (schema)TypeScript interface definition for StripeCustomer used in the createCustomer method and tool return type.export interface StripeCustomer { id: string; email: string; name?: string; stripeCustomerId: string; userId?: string; metadata?: Record<string, any>; created: string; updated: string; }
- src/worker.ts:276-283 (schema)Input schema definition for 'create_stripe_customer' tool in the MCP tools list.inputSchema: { type: 'object', properties: { email: { type: 'string', format: 'email', description: 'Customer email' }, name: { type: 'string', description: 'Customer name' } }, required: ['email'] }