getRegions
Retrieve a complete list of Colombia's administrative regions to access geographical and administrative data for research, travel planning, or data analysis purposes.
Instructions
Get list of regions in Colombia
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/services/regions.services.ts:11-53 (handler)The core handler function for the 'getRegions' tool. Fetches list of regions from the Colombia API, formats the data with emojis and details (ID, name, description, departments), adds a header, handles errors, and returns a formatted ApiColombiaResponse.export async function getRegions(): Promise<ApiColombiaResponse> { try { const apiUrl = process.env.API_COLOMBIA_URL || 'https://api-colombia.com/api/'; const response = await fetch(`${apiUrl}v1/Region`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const regionsData: RegionData[] = await response.json(); // Format the regions data into a readable text format const regionsInfo = regionsData.map(region => ` 🌎 REGIÓN: ${region.name} 📍 ID: ${region.id} 📝 Descripción: ${region.description} ${region.departments ? `🏛️ Departamentos: ${region.departments.join(', ')}` : '🏛️ Departamentos: No especificados'} ${'─'.repeat(80)} `).join('\n'); const headerInfo = ` 🇨🇴 REGIONES DE COLOMBIA Total de regiones: ${regionsData.length} ${'═'.repeat(80)} `; return { content: [{ type: 'text', text: (headerInfo + regionsInfo).trim() }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : ERROR_MESSAGES.UNKNOWN_ERROR; return { content: [{ type: 'text', text: `${ERROR_MESSAGES.FETCH_ERROR}: ${errorMessage}` }] }; } }
- src/tools/index.ts:19-23 (registration)Registers the 'getRegions' tool within the MCP tools configuration array, linking the name, description from constants, and the handler function.{ name: TOOL_NAMES.GET_REGIONS, description: TOOL_DESCRIPTIONS.GET_REGIONS, handler: getRegions, },
- src/tools/index.ts:7-11 (schema)Defines the ToolConfig interface used for structuring the registration of all MCP tools, including input name, description, and handler signature with ApiColombiaResponse return.export interface ToolConfig { name: string; description: string; handler: (...args: any[]) => Promise<ApiColombiaResponse>; }
- src/shared/types/response.mcp.ts:1-7 (schema)Type definition for the output response format of the getRegions tool and other tools, specifying a content array of text blocks.type ApiColombiaResponse = { content:Array<{ type:'text', text:string, }> } export type { ApiColombiaResponse }
- src/shared/constants/index.ts:1-6 (registration)Defines constant tool names used in registration, including GET_REGIONS: 'getRegions' which is the tool name.export const TOOL_NAMES = { GET_COUNTRY: 'getCountry', GET_REGIONS: 'getRegions', GET_REGION_BY_ID: 'getRegionById', GET_DEPARTMENTS_BY_REGION: 'getDepartmentsByRegion', } as const;