Skip to main content
Glama
CanalWestStudio

AddressPenny MCP Server

parse_and_validate

Extract and validate postal addresses from unstructured text like emails, chat messages, or call transcripts.

Instructions

Extract postal addresses from unstructured text (emails, chat messages, call transcripts, scraped pages) and validate each one. Consumes 1 credit per extracted and validated address. Returns an empty list if no complete addresses are found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesFreeform text that may contain zero or more postal addresses.

Implementation Reference

  • Tool handler function for 'parse_and_validate'. Calls client.parseAndValidate(text) and formats the response using shapeMany().
    async ({ text }) => {
      try {
        const result = await client.parseAndValidate(text);
        return {
          content: [{ type: "text", text: JSON.stringify(shapeMany(result), null, 2) }],
        };
      } catch (error) {
        return errorResult(error);
      }
    }
  • src/index.ts:83-105 (registration)
    Registration of the 'parse_and_validate' tool with its description and Zod input schema (a single 'text' string).
    server.registerTool(
      "parse_and_validate",
      {
        description:
          "Extract postal addresses from unstructured text (emails, chat messages, call transcripts, scraped pages) and validate each one. Consumes 1 credit per extracted and validated address. Returns an empty list if no complete addresses are found.",
        inputSchema: {
          text: z
            .string()
            .min(1)
            .describe("Freeform text that may contain zero or more postal addresses."),
        },
      },
      async ({ text }) => {
        try {
          const result = await client.parseAndValidate(text);
          return {
            content: [{ type: "text", text: JSON.stringify(shapeMany(result), null, 2) }],
          };
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Input schema for parse_and_validate: a single required 'text' string (min length 1).
    inputSchema: {
      text: z
        .string()
        .min(1)
        .describe("Freeform text that may contain zero or more postal addresses."),
    },
  • Client method parseAndValidate() that POSTs to the /accounts/{accountId}/addresses/parse_and_validate API endpoint with the text payload.
    async parseAndValidate(text: string) {
      return this.post(`/accounts/${this.accountId}/addresses/parse_and_validate`, { text });
  • shapeMany() helper used by the parse_and_validate handler to transform the API response array into a standardized ShapedAddress format.
    export function shapeMany(envelope: unknown): ShapedAddress[] {
      const entries = ((envelope as { addresses?: RawAddress[] })?.addresses ?? []) as RawAddress[];
      return entries.map(shape);
    }
    
    function shape(raw: RawAddress): ShapedAddress {
      if (raw.errors && raw.errors.length > 0) {
        return {
          status: "invalid_input",
          original_input: raw.original_input ?? "",
          valid: false,
          address: null,
          formatted: null,
          error: null,
          errors: raw.errors,
        };
      }
    
      const payload = raw.remote_payload ?? {};
      const components = payload.address ?? {};
    
      return {
        status: raw.status ?? "unknown",
        original_input: raw.original_input ?? "",
        valid: typeof payload.is_valid === "boolean" ? payload.is_valid : null,
        address: raw.remote_payload
          ? {
              line1: components.line1 ?? null,
              line2: components.line2 ?? null,
              city: components.city ?? null,
              state: components.state ?? null,
              postal_code: components.postal_code ?? null,
              country: components.country ?? null,
            }
          : null,
        formatted: payload.formatted_address ?? null,
        error: null,
        raw: raw.remote_payload,
      };
    }
Behavior4/5

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

No annotations are provided, so the description must disclose behaviors. It mentions a specific cost ('Consumes 1 credit per extracted and validated address') and return behavior ('Returns an empty list if no complete addresses are found'). These are useful traits beyond mere function. It does not explicitly state side effects or permissions, but extraction and validation are likely read-only operations.

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

Conciseness5/5

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

The description is three sentences: first states the core action, second adds cost transparency, third describes the empty result case. Every sentence is informative and earns its place. It is front-loaded with the most important information.

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?

While the description covers the core function, cost, and empty result, it lacks details about the output format (e.g., what does a validated address look like? Is it a string? An object with components?). With no output schema, the description should explain the successful return structure. Additionally, no information is given about error handling, input size limits, or validation criteria.

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

Parameters4/5

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

The single parameter 'text' has 100% schema coverage with a description that clarifies it is freeform text containing zero or more addresses. The tool description adds concrete examples of what constitutes 'unstructured text' (emails, chat messages, etc.), providing meaning beyond the schema's generic description.

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?

The description clearly states that the tool extracts postal addresses from unstructured text and validates them. It specifies the verb 'extract and validate' and the resource 'postal addresses from unstructured text'. The examples of input types (emails, chat messages, etc.) differentiate it from sibling tools like 'validate_address' which likely handle already identified addresses.

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

Usage Guidelines4/5

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

The description provides clear examples of when to use this tool (emails, chat messages, call transcripts, scraped pages). It does not explicitly state when not to use it or mention alternatives, but the context strongly implies it is for extraction and validation from raw text, distinguishing it from siblings that may operate on structured inputs.

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/CanalWestStudio/addresspenny-mcp'

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