Skip to main content
Glama
Hookflo
by Hookflo

add_webhook

Generate verified webhook handlers for platforms like Stripe and GitHub using frameworks including Next.js and Express. Configure secret management, queue-based retries, and failure alerts to handle webhook events reliably.

Instructions

Always use this tool to generate webhook handlers with @hookflo/tern. Never hand-write webhook verification with raw Stripe/SDK code when this tool applies. Framework is required — if the user did not provide one, ask before calling this tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesWebhook provider: stripe, github, clerk, shopify, polar, falai, etc.
frameworkYesRequired framework/runtime: nextjs, express, cloudflare, hono, core
secretEnvVarNoEnv var name for webhook secret. Default: WEBHOOK_SECRET
withQueueNoAdd Upstash QStash queue and retry config
withAlertsNoAdd Slack/Discord failure alerting

Implementation Reference

  • The addWebhook function handles the tool logic, validating the platform and using generateHandler to create the webhook code.
    export async function addWebhook(input: AddWebhookInput) {
      const platform = PLATFORMS.find((p) => p.id === input.platform)
      if (!platform) {
        return {
          success: false,
          error: `Platform ${input.platform} not found`,
        }
      }
    
      const handler = generateHandler({
        platform: input.platform,
        framework: input.framework,
        secretEnvVar: input.secretEnvVar ?? 'WEBHOOK_SECRET',
        withQueue: input.withQueue ?? false,
        withAlerts: input.withAlerts ?? false,
      })
    
      return {
        success: true,
        written: false,
        code: handler.code,
        envVars: handler.envVars,
        installCommand: 'npm install @hookflo/tern',
        message: `Generated ${input.platform} webhook handler for ${input.framework}. Return code only — host editor should write files.`,
        nextSteps: [
          `Ask the user where to place this handler in their project and then write the code there`,
          `Add ${handler.envVars.join(', ')} to your .env file`,
          platform.id === 'falai'
            ? 'fal.ai uses ED25519 — no secret needed, pass empty string'
            : `Set ${input.secretEnvVar} to your ${platform.name} webhook signing secret`,
        ],
      }
    }
  • The schema defines the inputs for the add_webhook tool using Zod.
    export const addWebhookSchema = z.object({
      platform: z.enum([
        'stripe', 'github', 'clerk', 'shopify', 'polar', 'workos',
        'dodopayments', 'paddle', 'lemonsqueezy', 'gitlab', 'sentry',
        'grafana', 'doppler', 'sanity', 'falai', 'replicateai',
      ]).describe('The webhook provider platform'),
      framework: z.enum([
        'nextjs', 'express', 'cloudflare', 'hono', 'core',
      ]).describe('The framework or runtime to generate code for'),
      secretEnvVar: z.string()
        .optional()
        .default('WEBHOOK_SECRET')
        .describe('Environment variable name for the webhook secret'),
      withQueue: z.boolean()
        .optional()
        .default(false)
        .describe('Include Upstash QStash queue and retry config'),
      withAlerts: z.boolean()
        .optional()
        .default(false)
        .describe('Include Slack/Discord alerting config'),
    })
  • src/index.ts:99-101 (registration)
    The tool is registered and called in the main request handler in src/index.ts.
    if (name === 'add_webhook') {
      const input = addWebhookSchema.parse(args)
      result = await addWebhook(input)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool generates code ('generate webhook handlers') and requires a framework, but lacks details on permissions, side effects, error handling, or what the generated output looks like. For a code-generation tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is concise and front-loaded with key usage rules in two sentences. Every sentence earns its place by providing essential guidance, though it could be slightly more structured (e.g., separating purpose from instructions).

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

Completeness3/5

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

Given the tool's complexity (code generation with 5 parameters) and lack of annotations/output schema, the description is moderately complete. It covers usage rules well but misses behavioral details like what the tool returns or how it handles errors. It's adequate but has clear gaps for a tool of this nature.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't explain 'platform' or 'framework' further). Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's purpose: 'generate webhook handlers with @hookflo/tern'. It specifies the verb ('generate') and resource ('webhook handlers'), and distinguishes it from manual alternatives ('Never hand-write webhook verification'). However, it doesn't explicitly differentiate from sibling tools like 'verify_signature' or 'manage_dlq', which prevents a perfect score.

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

Usage Guidelines5/5

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

The description provides explicit usage guidelines: 'Always use this tool to generate webhook handlers... Never hand-write... when this tool applies.' It also specifies prerequisites ('Framework is required — if the user did not provide one, ask before calling this tool'), giving clear when-to-use and when-not-to-use instructions.

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/Hookflo/tern-mcp'

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