Skip to main content
Glama

get_cities

Retrieve cities and municipalities for a specific Colombian department, including names, populations, and postal codes, to access detailed geographical information.

Instructions

Obtiene todas las ciudades/municipios de un departamento específico.

Args:

  • department_id (number): ID del departamento

Returns: Lista de ciudades con nombre, población y código postal.

Ejemplo de uso:

  • "¿Qué ciudades hay en Antioquia?"

  • "Lista los municipios del Valle del Cauca"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
department_idYesID del departamento

Implementation Reference

  • The handler function for the 'get_cities' tool. It takes a department_id, fetches the list of cities/municipalities from the API endpoint `/Department/${department_id}/cities`, formats the data (including id, name, population, surface, postal code), and returns it as a JSON string in the MCP response format. Handles errors gracefully.
    async ({ department_id }) => { try { const cities = await apiRequest<City[]>(`/Department/${department_id}/cities`); const resultado = { departamento_id: department_id, total_ciudades: cities.length, ciudades: cities.map(c => ({ id: c.id, nombre: c.name, poblacion: c.population, superficie_km2: c.surface, codigo_postal: c.postalCode, })), }; return { content: [ { type: "text", text: JSON.stringify(resultado, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error al obtener ciudades: ${error instanceof Error ? error.message : "Error desconocido"}`, }, ], }; } }
  • Input schema for the 'get_cities' tool using Zod validation. Requires a single parameter 'department_id' as a positive integer (minimum 1).
    inputSchema: { department_id: z.number().int().min(1).describe("ID del departamento"), },
  • src/index.ts:358-418 (registration)
    Registration of the 'get_cities' tool using server.registerTool. Includes title, detailed description, input schema, annotations (read-only, idempotent, etc.), and references the handler function.
    server.registerTool( "get_cities", { title: "Obtener Ciudades de un Departamento", description: `Obtiene todas las ciudades/municipios de un departamento específico. Args: - department_id (number): ID del departamento Returns: Lista de ciudades con nombre, población y código postal. Ejemplo de uso: - "¿Qué ciudades hay en Antioquia?" - "Lista los municipios del Valle del Cauca"`, inputSchema: { department_id: z.number().int().min(1).describe("ID del departamento"), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }, async ({ department_id }) => { try { const cities = await apiRequest<City[]>(`/Department/${department_id}/cities`); const resultado = { departamento_id: department_id, total_ciudades: cities.length, ciudades: cities.map(c => ({ id: c.id, nombre: c.name, poblacion: c.population, superficie_km2: c.surface, codigo_postal: c.postalCode, })), }; return { content: [ { type: "text", text: JSON.stringify(resultado, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error al obtener ciudades: ${error instanceof Error ? error.message : "Error desconocido"}`, }, ], }; } } );
  • TypeScript interface defining the structure of a City object, used in the get_cities handler for typing the API response.
    interface City { id: number; name: string; description: string; surface: number | null; population: number | null; postalCode: string | null; departmentId: number; }

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/crexative/colombia-mcp-server'

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