Skip to main content
Glama

Create a webhook subscription

lob_webhooks_create
Idempotent

Set up a webhook to monitor mail delivery events by registering an HTTPS URL and selecting event types.

Instructions

Subscribe an HTTPS endpoint to receive Lob event notifications (e.g. 'postcard.mailed', 'letter.in_transit', 'check.delivered'). The endpoint must respond with 2xx within 5 seconds.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesHTTPS URL to receive event POSTs.
event_typesYesEvent types to subscribe to, e.g. ['postcard.mailed', 'letter.delivered']. Use ['*'] for all.
descriptionNo
metadataNoUp to 20 string key/value pairs of arbitrary metadata to attach to the resource.
extraNoAdditional Lob API parameters not enumerated above. Merged into the request body verbatim. See https://docs.lob.com for the full parameter list per resource.

Implementation Reference

  • The tool 'lob_webhooks_create' registration and handler. It registers with input schema (url, event_types, description, metadata, extra) and the handler POSTs to /webhooks with the given payload via lob.request.
    export function registerWebhookTools(server: McpServer, lob: LobClient): void {
      registerTool(server, {
        name: "lob_webhooks_create",
        annotations: { title: "Create a webhook subscription", ...ToolAnnotationPresets.mutate },
        description:
          "Subscribe an HTTPS endpoint to receive Lob event notifications (e.g. 'postcard.mailed', " +
          "'letter.in_transit', 'check.delivered'). The endpoint must respond with 2xx within 5 seconds.",
        inputSchema: {
          url: z.string().url().describe("HTTPS URL to receive event POSTs."),
          event_types: z
            .array(z.string())
            .min(1)
            .describe("Event types to subscribe to, e.g. ['postcard.mailed', 'letter.delivered']. Use ['*'] for all."),
          description: z.string().max(255).optional(),
          metadata: metadataSchema,
          extra: extraParamsSchema,
        },
        handler: async (args) => {
          const { extra, ...rest } = args;
          return lob.request({
            method: "POST",
            path: "/webhooks",
            body: withExtra(rest, extra),
          });
        },
      });
  • Input schema for lob_webhooks_create: url (string URL), event_types (array of strings, min 1), description (optional string max 255), metadata (optional key/value record), extra (optional record for additional Lob API parameters).
    inputSchema: {
      url: z.string().url().describe("HTTPS URL to receive event POSTs."),
      event_types: z
        .array(z.string())
        .min(1)
        .describe("Event types to subscribe to, e.g. ['postcard.mailed', 'letter.delivered']. Use ['*'] for all."),
      description: z.string().max(255).optional(),
      metadata: metadataSchema,
      extra: extraParamsSchema,
    },
  • Registration call: registerWebhookTools(server, lob) at line 44 of register.ts wires the webhooks group into the MCP server.
    registerWebhookTools(server, lob);
  • The registerTool helper that wraps the handler with error handling and registers the tool on the MCP server.
    export function registerTool<TShape extends ZodRawShape>(
      server: McpServer,
      def: ToolDefinition<TShape>,
    ): void {
      const a = def.annotations ?? {};
      server.registerTool(
        def.name,
        {
          title: a.title ?? def.name,
          description: def.description,
          inputSchema: def.inputSchema,
          annotations: {
            ...a,
            // Lob is always external; default the hint accordingly.
            openWorldHint: a.openWorldHint ?? true,
          },
        },
        // The SDK's ToolCallback type is parameterised over the exact ZodRawShape and
        // resists the generic erasure here. The runtime contract (validated args in,
        // CallToolResult out) is correct, so we bridge the type boundary with `as never`.
        (async (args: unknown, serverCtx: unknown): Promise<CallToolResult> => {
          try {
            const result = await def.handler(args as never, serverCtx);
            return { content: [{ type: "text", text: stringifyResult(result) }] };
          } catch (err) {
            return {
              isError: true,
              content: [{ type: "text", text: formatErrorForTool(err) }],
            };
          }
        }) as never,
      );
    }
  • The withExtra helper used by the handler to merge extra parameters into the request body.
    /** Merge an `extra` record into a typed payload, with explicit fields taking precedence. */
    export function withExtra(
      payload: object,
      extra: Record<string, unknown> | undefined,
    ): Record<string, unknown> {
      return { ...(extra ?? {}), ...compact(payload) };
    }
Behavior4/5

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

The description adds a behavioral constraint: the endpoint must respond with 2xx within 5 seconds. Annotations include idempotentHint=true and openWorldHint=true, but the description provides additional context beyond these annotations. No contradiction.

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?

Two sentences, front-loaded with the core action, no wasted words. Efficient and clear.

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

Completeness4/5

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

The description is self-contained for a create operation, but lacks information about the return value (no output schema). However, the schema and annotations provide additional context. Minor gap, but overall adequate.

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 80%, so the schema covers most parameters. The description does not add new meaning beyond what the schema provides (it mentions endpoint and event types but not in detail). The baseline is 3 due to high coverage.

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

Purpose5/5

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

The description clearly states the verb 'Subscribe' and the resource 'HTTPS endpoint to receive Lob event notifications', with specific examples of event types. It distinguishes from sibling tools like list, delete, update.

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

Usage Guidelines3/5

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

The description implies usage by describing the subscription process but does not explicitly state when to use this tool versus alternatives like update or delete. It includes a requirement (2xx response within 5 seconds) but no guidance on when not to use it.

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/optimize-overseas/lob-mcp'

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