Retrieve a card
lob_cards_getRetrieve a single card's details using its unique card ID.
Instructions
Retrieve a single card by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Card ID (`card_…`). |
Implementation Reference
- src/tools/uploads.ts:257-264 (handler)Handler for lob_cards_get: makes a GET request to Lob's /cards/{id} endpoint using the provided card ID.
registerTool(server, { name: "lob_cards_get", annotations: { title: "Retrieve a card", ...ToolAnnotationPresets.read }, description: "Retrieve a single card by ID.", inputSchema: { id: CARD_ID }, handler: async ({ id }) => lob.request({ method: "GET", path: `/cards/${id}` }), }); - src/tools/uploads.ts:29-30 (schema)Input schema for lob_cards_get: expects a single 'id' parameter validated as a string matching the /^card_/ pattern.
const BUCKSLIP_ID = z.string().regex(/^bck_/).describe("Buckslip ID (`bck_…`)."); const CARD_ID = z.string().regex(/^card_/).describe("Card ID (`card_…`)."); - src/tools/uploads.ts:257-264 (registration)Registration of the 'lob_cards_get' tool via registerTool helper, which calls server.registerTool with the schema and handler.
registerTool(server, { name: "lob_cards_get", annotations: { title: "Retrieve a card", ...ToolAnnotationPresets.read }, description: "Retrieve a single card by ID.", inputSchema: { id: CARD_ID }, handler: async ({ id }) => lob.request({ method: "GET", path: `/cards/${id}` }), }); - src/tools/helpers.ts:85-117 (helper)The registerTool helper function that wraps the MCP SDK's 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, ); }