Skip to main content
Glama
europarcel
by europarcel

Get Counties

getCounties

Retrieve all counties for Romania using the country code 'RO'. Get accurate county list for shipping and logistics operations.

Instructions

Retrieves counties for a specific country. Requires country_code parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
country_codeYesThe country code - must be 'RO' (Romania)

Implementation Reference

  • The tool registration function that registers 'getCounties' with the MCP server, including the handler that validates inputs, calls the API client, and formats the response.
    export function registerGetCountiesTool(server: McpServer): void {
      // Create API client instance
    
      // Register getCounties tool
      server.registerTool(
        "getCounties",
        {
          title: "Get Counties",
          description:
            "Retrieves counties for a specific country. Requires country_code parameter.",
          inputSchema: {
            country_code: z
              .enum(["RO"])
              .describe("The country code - must be 'RO' (Romania)"),
          },
        },
        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) {
              return {
                content: [
                  {
                    type: "text",
                    text: "Error: country_code parameter is required",
                  },
                ],
              };
            }
    
            logger.info("Fetching counties", { country_code: args.country_code });
    
            const counties = await client.getCounties(args.country_code);
    
            logger.info(`Retrieved ${counties.length} counties`);
    
            let formattedResponse = `Found ${counties.length} counties in ${args.country_code}:\n\n`;
    
            counties.forEach((county) => {
              formattedResponse += `${county.county_name} (${county.county_code}) - ID: ${county.id}\n`;
            });
    
            return {
              content: [
                {
                  type: "text",
                  text: formattedResponse,
                },
              ],
            };
          } catch (error: any) {
            logger.error("Failed to fetch counties", error);
    
            return {
              content: [
                {
                  type: "text",
                  text: `Error fetching counties: ${error.message || "Unknown error"}`,
                },
              ],
            };
          }
        },
      );
    
      logger.info("getCounties tool registered successfully");
    }
  • Input schema for getCounties tool - requires country_code enum with 'RO' (Romania).
    inputSchema: {
      country_code: z
        .enum(["RO"])
        .describe("The country code - must be 'RO' (Romania)"),
    },
  • Registration of registerGetCountiesTool via import and call in the location tools module.
    import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
    import { registerGetCountriesTool } from "./getCountries.js";
    import { registerGetCountiesTool } from "./getCounties.js";
    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);
      registerGetCarriersTool(server);
      registerGetServicesTool(server);
      registerGetFixedLocationsTool(server);
      registerGetFixedLocationByIdTool(server);
    
      logger.info("All location tools registered successfully");
    }
    
    // Export individual registration functions if needed
    export { registerGetCountriesTool } from "./getCountries.js";
    export { registerGetCountiesTool } from "./getCounties.js";
    export { registerGetLocalitiesTool } from "./getLocalities.js";
    export { registerGetCarriersTool } from "./getCarriers.js";
    export { registerGetServicesTool } from "./getServices.js";
    export { registerGetFixedLocationsTool } from "./getFixedLocations.js";
    export { registerGetFixedLocationByIdTool } from "./getFixedLocationById.js";
  • API client method that calls GET /locations/counties/{countryCode} to fetch counties.
    async getCounties(countryCode: string): Promise<County[]> {
      const response = await this.client.get<County[]>(
        `/locations/counties/${countryCode}`,
      );
      return response.data;
    }
  • Type definition for County with id, county_code, county_name, country_code fields.
    export interface County {
      id: number;
      county_code: string;
      county_name: string;
      country_code: string;
    }
Behavior2/5

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

No annotations are provided, and the description does not disclose behavioral traits such as read-only nature, authentication needs, rate limits, or response format. The description solely states the retrieval action without elaboration.

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 a single, concise sentence that efficiently conveys the tool's primary purpose without unnecessary words or structure.

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

Completeness4/5

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

For a simple lookup tool with one parameter and no output schema, the description is mostly complete. It could benefit from mentioning that it returns a list of counties or that only 'RO' is supported, but overall it is sufficient.

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?

The input schema already provides full coverage with a description and enumeration for 'country_code', so the description's mention of the parameter adds no extra meaning beyond what is already structured.

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 action ('retrieves counties') and the resource ('for a specific country'). However, it does not differentiate from sibling tools like 'getLocalities' or 'getCountries', which serve similar lookup functions.

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 only mentions that the 'country_code' parameter is required, offering no guidance on when to use this tool versus alternatives (e.g., 'getLocalities' for subdivisions) or what prerequisites exist.

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