validate_address
Validate a postal address to obtain its standardized form, deliverability status, and validation metadata.
Instructions
Validate a single postal address. Returns the standardized address, deliverability status, and validation metadata. Consumes 1 credit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Full or partial postal address as a single string, e.g. '1600 Amphitheatre Pkwy, Mountain View, CA' |
Implementation Reference
- src/index.ts:34-56 (registration)The tool 'validate_address' is registered with the MCP server at line 34, with its name, description, input schema (a single string 'address'), and handler callback.
server.registerTool( "validate_address", { description: "Validate a single postal address. Returns the standardized address, deliverability status, and validation metadata. Consumes 1 credit.", inputSchema: { address: z .string() .min(1) .describe("Full or partial postal address as a single string, e.g. '1600 Amphitheatre Pkwy, Mountain View, CA'"), }, }, async ({ address }) => { try { const result = await client.validateAddress(address); return { content: [{ type: "text", text: JSON.stringify(shapeSingle(result), null, 2) }], }; } catch (error) { return errorResult(error); } } ); - src/index.ts:46-55 (handler)The handler function for 'validate_address' that calls client.validateAddress(address), shapes the result via shapeSingle(), and returns the response.
async ({ address }) => { try { const result = await client.validateAddress(address); return { content: [{ type: "text", text: JSON.stringify(shapeSingle(result), null, 2) }], }; } catch (error) { return errorResult(error); } } - src/index.ts:39-44 (schema)Input schema for validate_address: a single required string field 'address' with a description.
inputSchema: { address: z .string() .min(1) .describe("Full or partial postal address as a single string, e.g. '1600 Amphitheatre Pkwy, Mountain View, CA'"), }, - src/client.ts:18-23 (helper)The client method validateAddress() that sends a POST request to the API endpoint with the original input address.
async validateAddress(originalInput: string) { return this.post(`/accounts/${this.accountId}/addresses`, { address: { original_input: originalInput }, sync: true, }); } - src/shape.ts:34-37 (helper)The shapeSingle() helper that transforms the raw API response into the shaped output format used by validate_address.
export function shapeSingle(envelope: unknown): ShapedAddress { const raw = ((envelope as { address?: RawAddress })?.address ?? {}) as RawAddress; return shape(raw); }