Skip to main content
Glama

find_cities_near_city

Resolve a city's coordinates and retrieve nearby cities ordered by distance or population.

Instructions

Find cities near a given city. Resolves the city's coordinates and returns nearby cities ordered by distance or population.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUUID of the reference city
modeNo"closest" orders by distance, "largest" orders by populationclosest
preferredLanguagesNoComma-separated BCP 47 language tags

Implementation Reference

  • The async handler function that executes the 'find_cities_near_city' tool logic: resolves a city by UUID, gets its coordinates, and queries nearby cities ordered by distance (closest) or population (largest).
    async ({ id, mode, preferredLanguages }) => {
      const city = await client.cities.get(id);
      if (city.latitude == null || city.longitude == null) {
        return { content: [{ type: 'text', text: `City "${city.name}" has no coordinates on record.` }] };
      }
      const params = { lat: city.latitude, lon: city.longitude, preferredLanguages };
      const nearby = mode === 'largest'
        ? await client.cities.byCoordinatesLargest(params)
        : await client.cities.byCoordinatesClosest(params);
      const result = { reference: { id: city.id, name: city.name }, nearby };
      return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
    },
  • Zod schema definitions for the tool's input parameters: id (string UUID), mode (enum 'closest'|'largest', default 'closest'), and optional preferredLanguages.
    {
      id: z.string().describe('UUID of the reference city'),
      mode: z
        .enum(['closest', 'largest'])
        .default('closest')
        .describe('"closest" orders by distance, "largest" orders by population'),
      preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'),
    },
  • src/server.ts:205-228 (registration)
    Registration of the 'find_cities_near_city' tool using server.tool() with its name, description, input schema, and handler.
    server.tool(
      'find_cities_near_city',
      'Find cities near a given city. Resolves the city\'s coordinates and returns nearby cities ordered by distance or population.',
      {
        id: z.string().describe('UUID of the reference city'),
        mode: z
          .enum(['closest', 'largest'])
          .default('closest')
          .describe('"closest" orders by distance, "largest" orders by population'),
        preferredLanguages: z.string().optional().describe('Comma-separated BCP 47 language tags'),
      },
      async ({ id, mode, preferredLanguages }) => {
        const city = await client.cities.get(id);
        if (city.latitude == null || city.longitude == null) {
          return { content: [{ type: 'text', text: `City "${city.name}" has no coordinates on record.` }] };
        }
        const params = { lat: city.latitude, lon: city.longitude, preferredLanguages };
        const nearby = mode === 'largest'
          ? await client.cities.byCoordinatesLargest(params)
          : await client.cities.byCoordinatesClosest(params);
        const result = { reference: { id: city.id, name: city.name }, nearby };
        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 provided, so description carries full burden. It does not disclose error handling, read-only nature, output format, or behavior when city ID is invalid.

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 concise sentences, no redundant information, and the primary purpose is front-loaded.

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?

Adequate for a simple find tool but lacks output description, error scenarios, and usage guidance relative to many sibling tools. Missing details that would fully support an AI 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 covers all parameters with 100% description coverage. Description adds context for 'id' (resolves coordinates) and 'mode' (ordering), but does not explain 'preferredLanguages' beyond 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?

Description clearly states 'Find cities near a given city' with verb and resource, and distinguishes from sibling tools that use coordinates or compute distances between specific cities.

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?

No explicit guidance on when to use this tool versus its siblings, such as cities_by_coordinates_closest/largest or cities_distance. No prerequisites or exclusions mentioned.

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