Skip to main content
Glama

listar-empresas

Retrieve all registered companies from the API to access business data for analysis, management, or integration purposes.

Instructions

Lista todas las empresas registradas en la API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'listar-empresas' tool. It fetches the list of companies using companyService.getCompanies(), formats them into a readable text list, handles empty results and errors, returning structured content.
    export async function listCompaniesToolHandler() { try { const companies = await companyService.getCompanies(); if (companies.length === 0) { return { content: [ { type: "text" as const, text: "No hay empresas registradas en el sistema." } ] }; } const companiesList = companies.map(company => `🏢 ${company.name} ID: ${company.id} Email: ${company.email} Teléfono: ${company.phone} Industria: ${company.industry} Tamaño: ${company.size} Creada: ${new Date(company.created_at).toLocaleString()}` ).join('\n\n'); return { content: [ { type: "text" as const, text: `Se encontraron ${companies.length} empresa(s):\n\n${companiesList}` } ] }; } catch (error) { return { content: [ { type: "text" as const, text: `❌ Error al obtener las empresas: ${error.message}` } ] }; } }
  • Input schema for the 'listar-empresas' tool. It is an empty object, indicating no input parameters are required.
    /** * Esquema de entrada para listar empresas (sin parámetros requeridos) */ export const listCompaniesInputSchema = {};
  • src/main.ts:62-69 (registration)
    Registration of the 'listar-empresas' tool with the MCP server, linking the name, description, input schema, and handler function.
    server.registerTool( "listar-empresas", { description: "Lista todas las empresas registradas en la API", inputSchema: listCompaniesInputSchema }, listCompaniesToolHandler );
  • The getCompanies method in CompanyService, which makes an HTTP GET request to retrieve the list of companies from the external API. This is the core data-fetching helper used by the tool handler.
    async getCompanies(): Promise<CompanyListResponse> { try { const response = await httpClient.get<CompanyListResponse>(API_ENDPOINTS.companies); return response.data; } catch (error) { console.error('Error al obtener empresas:', error); throw new Error(`No se pudieron obtener las empresas: ${error.message}`); } }

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/mcgiverdev/mcp-api-v1'

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