Skip to main content
Glama

Validate Address

validate_address

Validate US or Puerto Rico addresses via UPS API. Returns validity, residential/commercial classification, and suggested corrections for ambiguous addresses.

Instructions

Validate a US or Puerto Rico address using UPS Address Validation. Returns whether the address is valid, classification (residential/commercial), and suggested corrections if ambiguous.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressLine1YesStreet address (e.g. "123 Main St")
addressLine2NoApartment, suite, unit (e.g. "Apt 4B")
cityYesCity or town name
stateProvinceCodeYesTwo-letter state code (e.g. "GA")
postalCodeYes5-digit ZIP code
countryCodeNoCountry code (US or PR)US

Implementation Reference

  • The handler function `addAddressTools` registers the `validate_address` tool on the MCP server. It defines the handler logic: builds the UPS XAVRequest body with address fields (addressLine1, addressLine2, city, stateProvinceCode, postalCode, countryCode), posts to the UPS Address Validation API, and formats the response via `formatToolResponse`.
    export function addAddressTools(server: McpServer, client: UPSHttpClient): void {
    	server.registerTool(
    		'validate_address',
    		{
    			title: 'Validate Address',
    			description:
    				'Validate a US or Puerto Rico address using UPS Address Validation. Returns whether the address is valid, classification (residential/commercial), and suggested corrections if ambiguous.',
    			inputSchema: {
    				addressLine1: z.string().describe('Street address (e.g. "123 Main St")'),
    				addressLine2: z.string().optional().describe('Apartment, suite, unit (e.g. "Apt 4B")'),
    				city: z.string().describe('City or town name'),
    				stateProvinceCode: z.string().length(2).describe('Two-letter state code (e.g. "GA")'),
    				postalCode: z.string().describe('5-digit ZIP code'),
    				countryCode: z.string().length(2).default('US').describe('Country code (US or PR)'),
    			},
    		},
    		async ({ addressLine1, addressLine2, city, stateProvinceCode, postalCode, countryCode }) => {
    			const body = {
    				XAVRequest: {
    					AddressKeyFormat: {
    						AddressLine: addressLine2 ? [addressLine1, addressLine2] : [addressLine1],
    						PoliticalDivision2: city,
    						PoliticalDivision1: stateProvinceCode,
    						PostcodePrimaryLow: postalCode,
    						CountryCode: countryCode,
    					},
    				},
    			};
    
    			const response = await client.post<unknown>(
    				`/api/addressvalidation/${API_VERSIONS.ADDRESS_VALIDATION}/${ADDRESS_VALIDATION_OPTIONS.ADDRESS_VALIDATION_AND_CLASSIFICATION}`,
    				body,
    			);
    
    			return formatToolResponse(response);
    		},
    	);
    }
  • src/server.ts:24-25 (registration)
    The tool is registered on the MCP server via `addAddressTools(server, client)` which calls the handler function.
    addTrackingTools(server, client);
    addAddressTools(server, client);
  • The TypeScript interface `ValidateAddressParams` defines the full set of parameters for address validation, including optional fields like addressLine3, postalCodeExtended, urbanization, and validationOption.
    export interface ValidateAddressParams {
    	readonly addressLine1: string;
    	readonly addressLine2?: string;
    	readonly addressLine3?: string;
    	readonly city: string;
    	readonly stateProvinceCode: string;
    	readonly postalCode: string;
    	readonly postalCodeExtended?: string;
    	readonly countryCode: string;
    	readonly urbanization?: string;
    	readonly validationOption?: AddressValidationOption;
    }
  • Response types for address validation including `AddressValidationResult` (with valid/ambiguous/noCandidates flags, classification, and candidates) and `AddressCandidate` (simplified candidate address).
    /**
     * A candidate address suggestion from validation (simplified).
     */
    export interface AddressCandidate {
    	readonly addressLine1: string;
    	readonly addressLine2?: string;
    	readonly city: string;
    	readonly stateProvinceCode: string;
    	readonly postalCode: string;
    	readonly postalCodeExtended?: string;
    	readonly countryCode: string;
    	readonly classification: 'commercial' | 'residential' | 'unknown';
    }
    
    /**
     * Simplified address validation result.
     */
    export interface AddressValidationResult {
    	readonly valid: boolean;
    	readonly ambiguous: boolean;
    	readonly noCandidates: boolean;
    	readonly classification?: 'commercial' | 'residential' | 'unknown';
    	readonly candidates: readonly AddressCandidate[];
    }
  • The `formatToolResponse` helper function wraps raw API responses into MCP-compatible text content output.
    export function formatToolResponse(response: unknown) {
    	return {
    		content: [{ type: 'text' as const, text: JSON.stringify(response, null, 2) }],
    	};
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description bears full burden. It mentions return values but omits behavioral traits like authentication requirements, rate limits, side effects, or error conditions. For a validation tool, this is a gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no redundancy, front-loaded with key information. Could be slightly more structured (e.g., separate output description), but overall very concise and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 6 parameters and no output schema, description covers purpose and basic output (validity, classification, corrections). However, it lacks details on return format, error handling, or behavior for invalid addresses. Adequate but incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The tool description does not add extra meaning beyond the schema's parameter descriptions. It correctly implies address components but adds no new semantic details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states verb+resource: 'Validate a US or Puerto Rico address'. Distinguishes from sibling tools (e.g., create_shipment, track_package) by focusing on validation. Mentions specific service (UPS Address Validation) and return types (validity, classification, corrections).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides implied usage: validating addresses. But lacks explicit guidance on when to use vs alternatives (e.g., before shipping, after data entry). No exclusions or comparisons to siblings like create_shipment or get_rates.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/roscoej/ups-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server