Update a creative
lob_creatives_updateUpdate a creative's description or metadata by providing the creative ID and optional parameters.
Instructions
Update a creative's description or metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Creative ID (`crv_…`). | |
| description | 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:201-208 (handler)The handler function for lob_creatives_update. It destructures id and extra from args, then sends a PATCH request to /creatives/{id} with the remaining fields merged with extra via withExtra().
handler: async (args) => { const { id, extra, ...rest } = args; return lob.request({ method: "PATCH", path: `/creatives/${id}`, body: withExtra(rest, extra), }); }, - src/tools/campaigns.ts:195-200 (schema)Input schema for lob_creatives_update: requires creative ID (crv_…), optional description (max 255 chars), optional metadata key/value pairs, and optional extra params escape hatch.
inputSchema: { id: CREATIVE_ID, description: z.string().max(255).optional(), metadata: metadataSchema, extra: extraParamsSchema, }, - src/tools/campaigns.ts:191-209 (registration)Registration of the lob_creatives_update tool within the registerCampaignTools function. Called via registerAllTools in register.ts line 41.
registerTool(server, { name: "lob_creatives_update", annotations: { title: "Update a creative", ...ToolAnnotationPresets.mutate }, description: "Update a creative's description or metadata.", inputSchema: { id: CREATIVE_ID, description: z.string().max(255).optional(), metadata: metadataSchema, extra: extraParamsSchema, }, handler: async (args) => { const { id, extra, ...rest } = args; return lob.request({ method: "PATCH", path: `/creatives/${id}`, body: withExtra(rest, extra), }); }, }); - src/schemas/common.ts:161-166 (helper)Helper function used by the handler to merge extra params into the request body, with explicit typed fields taking precedence.
export function withExtra( payload: object, extra: Record<string, unknown> | undefined, ): Record<string, unknown> { return { ...(extra ?? {}), ...compact(payload) }; } - src/tools/helpers.ts:85-117 (helper)The generic registerTool helper that wraps handlers with consistent error handling and JSON formatting. Used to register lob_creatives_update onto 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, ); }