Skip to main content
Glama
europarcel
by europarcel

Get Localities

getLocalities

Retrieve localities for shipping addresses in Romania by providing country and county codes to support accurate logistics operations.

Instructions

Retrieves localities for a specific country and county. Requires country_code and county_code parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
country_codeYesThe country code - must be 'RO' (Romania)
county_codeYesCounty code (1-2 characters, e.g., 'B', 'CJ') or county name (3+ characters, e.g., 'Bucuresti', 'Cluj')

Implementation Reference

  • The main handler logic for the 'getLocalities' tool. It retrieves the API key, creates an EuroparcelApiClient instance, validates input parameters, fetches localities from the API, formats the response as a text list, and handles errors.
    async (args: any) => {
      // Get API key from async context
      const apiKey = apiKeyStorage.getStore();
    
      if (!apiKey) {
        return {
          content: [
            {
              type: "text",
              text: "Error: X-API-KEY header is required",
            },
          ],
        };
      }
    
      // Create API client with customer's API key
      const client = new EuroparcelApiClient(apiKey);
    
      try {
        if (!args.country_code || !args.county_code) {
          return {
            content: [
              {
                type: "text",
                text: "Error: Both country_code and county_code parameters are required",
              },
            ],
          };
        }
    
        logger.info("Fetching localities", {
          country_code: args.country_code,
          county_code: args.county_code,
        });
    
        const localities = await client.getLocalities(
          args.country_code,
          args.county_code,
        );
    
        logger.info(`Retrieved ${localities.length} localities`);
    
        let formattedResponse = `Found ${localities.length} localities in ${args.county_code}, ${args.country_code}:\n\n`;
    
        localities.forEach((locality) => {
          formattedResponse += `${locality.name} - ID: ${locality.id}\n`;
        });
    
        return {
          content: [
            {
              type: "text",
              text: formattedResponse,
            },
          ],
        };
      } catch (error: any) {
        logger.error("Failed to fetch localities", error);
    
        return {
          content: [
            {
              type: "text",
              text: `Error fetching localities: ${error.message || "Unknown error"}`,
            },
          ],
        };
      }
    },
  • Zod-based input schema defining required parameters: country_code (must be 'RO') and county_code (string, county code or name).
    inputSchema: {
      country_code: z
        .enum(["RO"])
        .describe("The country code - must be 'RO' (Romania)"),
      county_code: z
        .string()
        .min(1)
        .max(100)
        .describe(
          "County code (1-2 characters, e.g., 'B', 'CJ') or county name (3+ characters, e.g., 'Bucuresti', 'Cluj')",
        ),
    },
  • Direct registration of the 'getLocalities' tool on the McpServer instance, specifying name, metadata, input schema, and handler function.
    server.registerTool(
      "getLocalities",
      {
        title: "Get Localities",
        description:
          "Retrieves localities for a specific country and county. Requires country_code and county_code parameters.",
        inputSchema: {
          country_code: z
            .enum(["RO"])
            .describe("The country code - must be 'RO' (Romania)"),
          county_code: z
            .string()
            .min(1)
            .max(100)
            .describe(
              "County code (1-2 characters, e.g., 'B', 'CJ') or county name (3+ characters, e.g., 'Bucuresti', 'Cluj')",
            ),
        },
      },
      async (args: any) => {
        // Get API key from async context
        const apiKey = apiKeyStorage.getStore();
    
        if (!apiKey) {
          return {
            content: [
              {
                type: "text",
                text: "Error: X-API-KEY header is required",
              },
            ],
          };
        }
    
        // Create API client with customer's API key
        const client = new EuroparcelApiClient(apiKey);
    
        try {
          if (!args.country_code || !args.county_code) {
            return {
              content: [
                {
                  type: "text",
                  text: "Error: Both country_code and county_code parameters are required",
                },
              ],
            };
          }
    
          logger.info("Fetching localities", {
            country_code: args.country_code,
            county_code: args.county_code,
          });
    
          const localities = await client.getLocalities(
            args.country_code,
            args.county_code,
          );
    
          logger.info(`Retrieved ${localities.length} localities`);
    
          let formattedResponse = `Found ${localities.length} localities in ${args.county_code}, ${args.country_code}:\n\n`;
    
          localities.forEach((locality) => {
            formattedResponse += `${locality.name} - ID: ${locality.id}\n`;
          });
    
          return {
            content: [
              {
                type: "text",
                text: formattedResponse,
              },
            ],
          };
        } catch (error: any) {
          logger.error("Failed to fetch localities", error);
    
          return {
            content: [
              {
                type: "text",
                text: `Error fetching localities: ${error.message || "Unknown error"}`,
              },
            ],
          };
        }
      },
    );
  • EuroparcelApiClient helper method that performs the actual HTTP GET request to the /locations/localities endpoint with query parameters and returns the localities data.
    async getLocalities(
      countryCode: string,
      countyCode: string,
    ): Promise<Locality[]> {
      const response = await this.client.get<Locality[]>(
        "/locations/localities",
        {
          params: {
            country_code: countryCode,
            county_code: countyCode,
          },
        },
      );
      return response.data;
    }
  • Invocation of registerGetLocalitiesTool within the aggregated registerLocationTools function.
    registerGetLocalitiesTool(server);
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'Retrieves' which implies a read operation, but doesn't disclose behavioral traits like whether it's idempotent, what format the localities are returned in, if there are rate limits, authentication requirements, or error conditions. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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?

Two sentences, zero waste. First sentence states purpose and scope, second sentence specifies parameter requirements. No redundant information, well-structured, and appropriately sized for a simple retrieval tool.

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

Completeness2/5

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

Given no annotations, no output schema, and a read operation with 2 parameters, the description is incomplete. It doesn't explain what 'localities' means in this context, what the return format looks like, or any behavioral constraints. For a tool that likely returns structured data, more context about the output would be helpful to the agent.

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 the schema already fully documents both parameters. The description adds that these parameters are 'required' but doesn't provide additional semantic context beyond what's in the schema (e.g., why these specific parameters are needed, how they relate to each other, or examples of valid combinations). Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the verb ('Retrieves') and resource ('localities'), and specifies the scope ('for a specific country and county'). It distinguishes from siblings like 'searchLocalities' by indicating this is a retrieval rather than search operation. However, it doesn't explicitly contrast with 'getCountries' or 'getCounties' which are related but different resources.

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

Usage Guidelines2/5

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

The description mentions required parameters but provides no guidance on when to use this tool versus alternatives like 'searchLocalities' or 'getCountries'/'getCounties'. There's no context about prerequisites, typical use cases, or exclusions. The agent must infer usage from the tool name and parameters alone.

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/europarcel/mcp'

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