Skip to main content
Glama
launchframe-dev

LaunchFrame MCP

credits_get_add_pattern

Generate code to add credits to users programmatically by specifying transaction types like purchase, refund, or bonus.

Instructions

Get the code snippet for programmatically adding credits to a user with a specific transaction type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transactionTypeYesThe CreditTransactionType to use

Implementation Reference

  • The handler implementation for the `credits_get_add_pattern` tool.
      server.tool(
        'credits_get_add_pattern',
        'Get the code snippet for programmatically adding credits to a user with a specific transaction type.',
        {
          transactionType: z
            .enum(['INITIAL', 'PURCHASE', 'USAGE', 'REFUND', 'BONUS', 'EXPIRY', 'REDEMPTION'])
            .describe('The CreditTransactionType to use'),
        },
        async ({ transactionType }) => {
          const descriptions: Record<string, string> = {
            INITIAL: 'Grant starting credits to a new user',
            PURCHASE: 'Credit top-up purchased by the user',
            USAGE: 'Manual usage deduction (prefer CreditsGuard for route-level deduction)',
            REFUND: 'Refund credits after a failed or cancelled operation',
            BONUS: 'Promotional or reward credits',
            EXPIRY: 'Expire/remove unused credits',
            REDEMPTION: 'Redeem credits (e.g. voucher, referral)',
          };
    
          const snippet = `// ${descriptions[transactionType]}
    import { CreditsService } from '../credits/credits.service';
    import { CreditTransactionType } from '../credits/entities/credit-transaction.entity';
    
    // Inject in constructor:
    constructor(private readonly creditsService: CreditsService) {}
    
    // Call:
    await this.creditsService.addCredits(
      user,                              // User entity
      100,                               // amount (positive to add, negative to deduct)
      CreditTransactionType.${transactionType},
      'Optional description',            // optional
      'optional-ref-id',                 // optional — external reference (e.g. Polar order ID)
    );`;
    
          return {
            content: [{ type: 'text', text: snippet }],
          };
        }
      );

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/launchframe-dev/mcp'

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