Delete a saved address
lob_addresses_deleteDelete a saved address from the address book without affecting existing mail pieces.
Instructions
Delete a saved address from the address book. Does not affect mail pieces already created with it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Lob address ID to delete. |
Implementation Reference
- src/tools/address-book.ts:64-74 (handler)Tool definition and handler for 'lob_addresses_delete'. Registers the tool with a destructive annotation, validates input with a Zod schema (id matching /^adr_/), and makes a DELETE /addresses/{id} request via LobClient.
registerTool(server, { name: "lob_addresses_delete", annotations: { title: "Delete a saved address", ...ToolAnnotationPresets.destructive, }, description: "Delete a saved address from the address book. Does not affect mail pieces already created with it.", inputSchema: { id: z.string().regex(/^adr_/).describe("Lob address ID to delete.") }, handler: async ({ id }) => lob.request({ method: "DELETE", path: `/addresses/${id}` }), }); - src/tools/address-book.ts:18-18 (registration)Imports registerTool and ToolAnnotationPresets from helpers.js, used to register the tool.
import { ToolAnnotationPresets, registerTool } from "./helpers.js"; - src/tools/address-book.ts:20-20 (registration)The function registerAddressBookTools is called from src/tools/register.ts (line 34) to wire all address-book tools into the MCP server.
export function registerAddressBookTools(server: McpServer, lob: LobClient): void { - src/tools/helpers.ts:85-117 (helper)The registerTool helper function that wraps SDK server.registerTool with consistent error handling and JSON formatting.
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, ); } - src/tools/helpers.ts:29-60 (helper)ToolAnnotationPresets including the 'destructive' preset used by lob_addresses_delete.
export const ToolAnnotationPresets = { read: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, preview: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, commit: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true, }, destructive: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true, }, mutate: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, } as const;