Skip to main content
Glama

search_cities

Search for cities by name, country, population range, or region. Returns results with geographic information and name translations.

Instructions

Search cities by name, country, population range, and more. Returns matching cities with geographic and translation data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoCity name prefix to search for
countryCodeNoISO 3166-1 alpha-2 country code (e.g. "US", "DE")
regionIdNoFilter by region UUID
minPopulationNoMinimum population
maxPopulationNoMaximum population
sortNoSort order
preferredLanguagesNoComma-separated BCP 47 language tags for name translations (e.g. "fr,en")
limitNoMax results (default 20)
offsetNoPagination offset

Implementation Reference

  • Handler function for the 'search_cities' tool. Accepts the params object (name, countryCode, regionId, minPopulation, maxPopulation, sort, preferredLanguages, limit, offset) and calls client.cities.search(params) to execute the search, returning results as JSON text.
    async (params) => {
      const result = await client.cities.search(params);
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    },
  • Zod schema definitions for the 'search_cities' tool inputs: optional name prefix, countryCode (ISO alpha-2), regionId (UUID), minPopulation/maxPopulation (integers), sort (enum with 4 options), preferredLanguages (comma-separated BCP 47 tags), limit (1-100), and offset.
    {
      name: z.string().optional().describe('City name prefix to search for'),
      countryCode: z.string().optional().describe('ISO 3166-1 alpha-2 country code (e.g. "US", "DE")'),
      regionId: z.string().optional().describe('Filter by region UUID'),
      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 for name translations (e.g. "fr,en")'),
      limit: z.number().int().min(1).max(100).optional().describe('Max results (default 20)'),
      offset: z.number().int().min(0).optional().describe('Pagination offset'),
    },
  • src/server.ts:15-39 (registration)
    Registration of the 'search_cities' tool on the MCP server via server.tool() with its name, description, Zod schema, and async handler function.
    server.tool(
      'search_cities',
      'Search cities by name, country, population range, and more. Returns matching cities with geographic and translation data.',
      {
        name: z.string().optional().describe('City name prefix to search for'),
        countryCode: z.string().optional().describe('ISO 3166-1 alpha-2 country code (e.g. "US", "DE")'),
        regionId: z.string().optional().describe('Filter by region UUID'),
        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 for name translations (e.g. "fr,en")'),
        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 (params) => {
        const result = await client.cities.search(params);
        return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
      },
    );
Behavior2/5

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

No annotations are provided, so the description must carry the full burden of behavioral disclosure. It only mentions returning 'matching cities with geographic and translation data' but omits details about pagination (default limit 20), case sensitivity, fuzzy matching, or any rate limits. The phrase 'and more' is vague and does not compensate for the missing behavioral context.

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 two sentences, concise and front-loaded with purpose. Every sentence adds value. However, given 9 parameters, slightly more detail could be justified without losing conciseness.

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?

The tool has 9 optional parameters and no output schema. The description covers the general purpose and return type (geographic and translation data) but lacks specifics on pagination, default values, and the structure of output. It is adequate but not comprehensive.

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 baseline is 3 even if the description adds little. The description hints at parameters ('by name, country, population range') but does not elaborate beyond the schema. It does not provide additional context like the meaning of sort orders or preferredLanguages, so no improvement over schema.

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 'Search cities by name, country, population range, and more. Returns matching cities with geographic and translation data.' It specifies a verb ('search') and resource ('cities'), and the mention of multiple filter criteria distinguishes it from siblings like search_cities_in_country or get_city.

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 implies usage for combined city searches but does not explicitly state when to use this tool versus alternatives like get_city (for exact lookups) or find_cities_near_city (for proximity searches). No direct guidance on when not to use or which sibling to choose.

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