Skip to main content
Glama
DynamicEndpoints

Advanced PocketBase MCP Server

create_stripe_customer

Create a new customer in Stripe to manage billing and subscriptions within the PocketBase database system.

Instructions

Create a new customer in Stripe

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the create_stripe_customer MCP tool with input schema, description, and handler function that instantiates StripeService and calls createCustomer
    export function registerTools(server: any, pb: any): void {
      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 };
      });
    }
  • Core implementation of customer creation: checks for existing customer by email in PocketBase, creates new Stripe customer via Stripe API, saves to PocketBase stripe_customers collection
    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}`);
      }
    }
  • Input schema for create_stripe_customer tool: requires email and optional name
    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 };
    });
  • Alternative registration of create_stripe_customer tool in agent-simple.ts, with more detailed schema and error handling, also delegating to StripeService.createCustomer
      'create_stripe_customer',
      'Create a new customer in Stripe',
      {
        type: 'object',
        properties: {
          email: { type: 'string', format: 'email', description: 'Customer email' },
          name: { type: 'string', description: 'Customer name' }
        },
        required: ['email']
      },
      async ({ email, name }) => {
        // Lazy load Stripe service
        await this.ensureStripeService();
        
        if (!this.stripeService) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                error: 'Stripe service not available. Please set STRIPE_SECRET_KEY environment variable.'
              })
            }]
          };
        }
    
        try {
          const customer = await this.stripeService.createCustomer({ email, name });
          return {
            content: [{
              type: 'text',
              text: JSON.stringify(customer, null, 2)
            }]
          };
        } catch (error: any) {
          return {
            content: [{
              type: 'text',
              text: JSON.stringify({
                error: `Failed to create Stripe customer: ${error.message}`
              })
            }]
          };
        }
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Create' implies a write operation, it doesn't disclose any behavioral traits such as required permissions, whether this is idempotent, what happens on duplicate attempts, error conditions, or rate limits. The description is minimal and lacks essential operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a tool with no parameters. Every word earns its place in conveying the essential function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool (creating a customer) with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what data is required for customer creation, what the response looks like, error handling, or any operational constraints. The minimal description leaves significant gaps in understanding how to effectively use this tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so there are no parameters to document. The description appropriately doesn't mention parameters, which is correct for this case. Baseline score of 4 applies since no parameter information is needed or expected.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and target resource ('new customer in Stripe'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_stripe_product' or 'create_stripe_payment_intent' beyond the resource type, missing specific distinctions about what makes this tool unique versus other Stripe creation tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when it's appropriate compared to other customer management tools, or any exclusions. It simply states what the tool does without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DynamicEndpoints/advanced-pocketbase-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server