Update a campaign
lob_campaigns_updateModify campaign metadata, name, description, or send schedule before the campaign is sent. Supports custom parameters via Lob API.
Instructions
Update a campaign's metadata or schedule before it has been sent.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Campaign ID (`cmp_…`). | |
| name | No | ||
| description | No | ||
| send_date | No | ||
| target_delivery_date | No | ||
| cancel_window_campaign_minutes | No | ||
| metadata | No | Up to 20 string key/value pairs of arbitrary metadata to attach to the resource. | |
| extra | No | Additional 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
- src/tools/campaigns.ts:96-103 (handler)The handler function for lob_campaigns_update. It destructures args to extract 'id' and 'extra', then sends a PATCH request to /campaigns/{id} with the remaining fields merged via withExtra().
handler: async (args) => { const { id, extra, ...rest } = args; return lob.request({ method: "PATCH", path: `/campaigns/${id}`, body: withExtra(rest, extra), }); }, - src/tools/campaigns.ts:86-95 (schema)Input schema for lob_campaigns_update: id (regex ^cmp_), optional name, description (max 500), send_date, target_delivery_date, cancel_window_campaign_minutes, metadata, and extra escape hatch.
inputSchema: { id: CAMPAIGN_ID, name: z.string().optional(), description: z.string().max(500).optional(), send_date: z.string().optional(), target_delivery_date: z.string().optional(), cancel_window_campaign_minutes: z.number().int().optional(), metadata: metadataSchema, extra: extraParamsSchema, }, - src/tools/campaigns.ts:82-104 (registration)Registration of the tool via registerTool() with name 'lob_campaigns_update', annotations for mutating operations, and the handler.
registerTool(server, { name: "lob_campaigns_update", annotations: { title: "Update a campaign", ...ToolAnnotationPresets.mutate }, description: "Update a campaign's metadata or schedule before it has been sent.", inputSchema: { id: CAMPAIGN_ID, name: z.string().optional(), description: z.string().max(500).optional(), send_date: z.string().optional(), target_delivery_date: z.string().optional(), cancel_window_campaign_minutes: z.number().int().optional(), metadata: metadataSchema, extra: extraParamsSchema, }, handler: async (args) => { const { id, extra, ...rest } = args; return lob.request({ method: "PATCH", path: `/campaigns/${id}`, body: withExtra(rest, extra), }); }, }); - src/tools/register.ts:41-46 (registration)The tool is registered as part of registerCampaignTools(server, lob) call in the central registration entry point.
registerCampaignTools(server, lob); registerUploadsTools(server, lob, tokenStore, pieceCounter); registerBankAccountTools(server, lob); registerWebhookTools(server, lob); registerSpecsResources(server); } - src/tools/helpers.ts:85-117 (helper)The registerTool helper function that wraps the tool definition and registers it with the MCP server, with error handling and result serialization.
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, ); }