Skip to main content
Glama

search_cities_in_country

Search for cities in any country by typing the country name. Filter results by city name, population, language, and more.

Instructions

Search cities using a country name instead of an ISO code. Resolves the country first, then searches cities within it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countryNameYesCountry name prefix (e.g. "France", "United States")
nameNoCity name prefix to filter by
minPopulationNoMinimum population
maxPopulationNoMaximum population
sortNoSort order
preferredLanguagesNoComma-separated BCP 47 language tags
limitNoMax results (default 20)
offsetNoPagination offset

Implementation Reference

  • src/server.ts:300-326 (registration)
    Registration of the 'search_cities_in_country' tool via server.tool() call, defining its name, description, input schema, and handler.
    server.tool(
      'search_cities_in_country',
      'Search cities using a country name instead of an ISO code. Resolves the country first, then searches cities within it.',
      {
        countryName: z.string().describe('Country name prefix (e.g. "France", "United States")'),
        name: z.string().optional().describe('City name prefix to filter by'),
        minPopulation: z.number().int().optional().describe('Minimum population'),
        maxPopulation: z.number().int().optional().describe('Maximum population'),
        sort: z
          .enum(['population_desc', 'population_asc', 'name_asc', 'name_desc'])
          .optional()
          .describe('Sort order'),
        preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'),
        limit: z.number().int().min(1).max(100).optional().describe('Max results (default 20)'),
        offset: z.number().int().min(0).optional().describe('Pagination offset'),
      },
      async ({ countryName, ...cityParams }) => {
        const matches = await client.countries.list({ name: countryName, limit: 1 });
        if (!matches.length) {
          return { content: [{ type: 'text', text: `No country found matching "${countryName}".` }] };
        }
        const country = matches[0];
        const cities = await client.cities.search({ ...cityParams, countryCode: country.isoCode });
        const result = { country: { id: country.id, name: country.name, isoCode: country.isoCode }, cities };
        return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
      },
    );
  • Input schema for the tool using Zod: countryName (required), name, minPopulation, maxPopulation, sort, preferredLanguages, limit, offset.
    {
      countryName: z.string().describe('Country name prefix (e.g. "France", "United States")'),
      name: z.string().optional().describe('City name prefix to filter by'),
      minPopulation: z.number().int().optional().describe('Minimum population'),
      maxPopulation: z.number().int().optional().describe('Maximum population'),
      sort: z
        .enum(['population_desc', 'population_asc', 'name_asc', 'name_desc'])
        .optional()
        .describe('Sort order'),
      preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'),
      limit: z.number().int().min(1).max(100).optional().describe('Max results (default 20)'),
      offset: z.number().int().min(0).optional().describe('Pagination offset'),
    },
  • Handler function that resolves the country by name using client.countries.list(), then searches cities within that country using client.cities.search() with the resolved countryCode.
    async ({ countryName, ...cityParams }) => {
      const matches = await client.countries.list({ name: countryName, limit: 1 });
      if (!matches.length) {
        return { content: [{ type: 'text', text: `No country found matching "${countryName}".` }] };
      }
      const country = matches[0];
      const cities = await client.cities.search({ ...cityParams, countryCode: country.isoCode });
      const result = { country: { id: country.id, name: country.name, isoCode: country.isoCode }, cities };
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    },
Behavior3/5

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

With no annotations, the description adds a key behavioral insight: the tool resolves the country first before searching cities. However, it does not disclose potential errors, performance implications, or other behaviors beyond this minimal detail.

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 extremely concise with only two sentences, front-loading the core purpose. Every word adds value, no redundancy.

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 8 parameters and no output schema, the description does not cover return structure, error handling, or pagination details beyond offset/limit. It provides minimal context for a moderately complex search tool.

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 baseline is 3. The description adds no parameter-specific information beyond what the schema already provides; it remains at a high level.

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 tool searches cities using a country name instead of an ISO code, with specific verb 'Search' and resource 'cities'. It distinguishes itself from sibling tools like 'search_cities' which likely uses ISO codes.

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 implies when to use this tool (when you have a country name rather than ISO code). While it doesn't explicitly state when not to use it, the sibling list provides context, making the guidance clear enough.

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/930m310n/geomelon-mcp'

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