Skip to main content
Glama

ApiColombiaMCP

by esneyder
regions.services.jsβ€’2.95 kB
import { ERROR_MESSAGES } from "../shared/constants/index.js"; export async function getRegions() { 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 = 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}` }] }; } } export async function getRegionById(regionId) { try { const apiUrl = process.env.API_COLOMBIA_URL || 'https://api-colombia.com/api/'; const response = await fetch(`${apiUrl}v1/Region/${regionId}`); if (!response.ok) { if (response.status === 404) { return { content: [{ type: 'text', text: `❌ No se encontrΓ³ una regiΓ³n con el ID: ${regionId}` }] }; } throw new Error(`HTTP error! status: ${response.status}`); } const regionData = await response.json(); // Format the region data into a readable text format const regionInfo = ` πŸ‡¨πŸ‡΄ DETALLE DE LA REGIΓ“N ${'═'.repeat(80)} 🌎 REGIΓ“N: ${regionData.name} πŸ“ ID: ${regionData.id} πŸ“ DescripciΓ³n: ${regionData.description} ${regionData.departments ? `πŸ›οΈ Departamentos: ${regionData.departments.join(', ')}` : 'πŸ›οΈ Departamentos: No especificados'} ${'═'.repeat(80)} `; return { content: [{ type: 'text', text: regionInfo.trim() }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : ERROR_MESSAGES.UNKNOWN_ERROR; return { content: [{ type: 'text', text: `${ERROR_MESSAGES.FETCH_ERROR}: ${errorMessage}` }] }; } }

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/esneyder/apicolombia-mcp'

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