Skip to main content
Glama
europarcel
by europarcel

Get Localities

getLocalities

Retrieve localities in a Romanian county using its code or name. Provide country code 'RO' and county identifier to get matching localities.

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 function that registers the 'getLocalities' tool with the MCP server. Contains the full tool logic: validates API key and parameters, calls the API client, formats the response, and handles errors.
    export function registerGetLocalitiesTool(server: McpServer): void {
      // Create API client instance
    
      // Register getLocalities tool
      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"}`,
                },
              ],
            };
          }
        },
      );
    
      logger.info("getLocalities tool registered successfully");
    }
  • Input schema for the getLocalities tool using Zod validation. Defines required 'country_code' (enum RO) and 'county_code' (string min1 max100) 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')",
        ),
    },
  • The tool is imported and registered in the location tools index. registerGetLocalitiesTool is called at line 17 and re-exported at line 29.
    import { registerGetLocalitiesTool } from "./getLocalities.js";
    import { registerGetCarriersTool } from "./getCarriers.js";
    import { registerGetServicesTool } from "./getServices.js";
    import { registerGetFixedLocationsTool } from "./getFixedLocations.js";
    import { registerGetFixedLocationByIdTool } from "./getFixedLocationById.js";
    import { logger } from "../../utils/logger.js";
    
    export function registerLocationTools(server: McpServer): void {
      logger.info("Registering location tools...");
    
      // Register all location-related tools
      registerGetCountriesTool(server);
      registerGetCountiesTool(server);
      registerGetLocalitiesTool(server);
  • The API client helper method that makes the HTTP request to fetch localities. Sends a GET request to '/locations/localities' with country_code and county_code query params and returns Locality[] 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;
    }
Behavior2/5

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

With no annotations, the description should disclose behavioral traits such as read-only nature, authentication requirements, error handling, or response format. It only states it 'Retrieves localities,' omitting any details about the output, pagination, or behavior on invalid inputs.

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?

The description is a single, clear sentence with no wasted words. While concise, it could be more informative without sacrificing brevity, hence not a perfect score.

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 output schema and low complexity, the description should at least hint at the return structure (e.g., list of locality names/codes) or mention that country_code is fixed. It covers neither, leaving the agent under-informed.

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 coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond the schema's parameter descriptions; it merely repeats the requirement. No extra context is provided for parameter values or formats.

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 the action ('Retrieves') and the resource ('localities for a specific country and county'), distinguishing it from siblings like getCounties and searchLocalities. It also mentions required parameters, making the purpose unmistakable.

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?

The description specifies that country_code and county_code are required, but provides no guidance on when to use this tool versus alternatives like searchLocalities (which likely supports fuzzy text searches). It does not mention prerequisites or contextual cues for selecting this tool.

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-docker'

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