Skip to main content
Glama

get_departments

Retrieve Colombia's 32 departments plus Bogotá D.C. with details including capital, population, area, and region for geographical reference or data analysis.

Instructions

Obtiene los 32 departamentos de Colombia más Bogotá D.C.

Returns: Lista de departamentos con: id, nombre, capital, población, superficie y región.

Ejemplo de uso:

  • "¿Cuáles son los departamentos de Colombia?"

  • "Lista todos los departamentos"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:145-198 (registration)
    Complete registration of the 'get_departments' tool using server.registerTool, including tool name, metadata (title, description), empty input schema, annotations, and inline async handler function that fetches and formats department data.
    server.registerTool( "get_departments", { title: "Obtener Departamentos de Colombia", description: `Obtiene los 32 departamentos de Colombia más Bogotá D.C. Returns: Lista de departamentos con: id, nombre, capital, población, superficie y región. Ejemplo de uso: - "¿Cuáles son los departamentos de Colombia?" - "Lista todos los departamentos"`, inputSchema: {}, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }, async () => { try { const departments = await apiRequest<Department[]>("/Department"); const resultado = departments.map(d => ({ id: d.id, nombre: d.name, capital: d.cityCapital?.name || "N/A", poblacion: d.population, superficie_km2: d.surface, municipios: d.municipalities, region_id: d.regionId, })); return { content: [ { type: "text", text: JSON.stringify(resultado, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error al obtener departamentos: ${error instanceof Error ? error.message : "Error desconocido"}`, }, ], }; } } );
  • The tool handler: fetches all departments via API, maps to a simplified structure (id, name, capital, population, area, municipalities, region_id), stringifies as JSON in text content, handles errors.
    async () => { try { const departments = await apiRequest<Department[]>("/Department"); const resultado = departments.map(d => ({ id: d.id, nombre: d.name, capital: d.cityCapital?.name || "N/A", poblacion: d.population, superficie_km2: d.surface, municipios: d.municipalities, region_id: d.regionId, })); return { content: [ { type: "text", text: JSON.stringify(resultado, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error al obtener departamentos: ${error instanceof Error ? error.message : "Error desconocido"}`, }, ], }; } }
  • Tool schema/metadata: title, detailed description of purpose and returns, empty inputSchema (no parameters required), annotations for read-only, idempotent behavior.
    { title: "Obtener Departamentos de Colombia", description: `Obtiene los 32 departamentos de Colombia más Bogotá D.C. Returns: Lista de departamentos con: id, nombre, capital, población, superficie y región. Ejemplo de uso: - "¿Cuáles son los departamentos de Colombia?" - "Lista todos los departamentos"`, inputSchema: {}, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, },
  • TypeScript interface defining the Department structure used in the API response typing for the handler.
    interface Department { id: number; name: string; description: string; cityCapitalId: number; municipalities: number; surface: number; population: number; phonePrefix: string; regionId: number; cityCapital?: { id: number; name: string; description: string; }; }
  • Shared helper function apiRequest used by the handler to make GET requests to the Colombia API base URL.
    async function apiRequest<T>(endpoint: string): Promise<T> { const url = `${API_BASE_URL}${endpoint}`; const response = await fetch(url, { method: "GET", headers: { "Accept": "application/json", "Content-Type": "application/json", }, }); if (!response.ok) { throw new Error(`API Error: ${response.status} ${response.statusText}`); } return response.json() as Promise<T>; }

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