Skip to main content
Glama

Brasil API MCP

index.ts1.96 kB
import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { getBrasilApiData, formatErrorResponse } from "../../utils/api.js"; /** * Register CNPJ (Brazilian company registration) related tools to the MCP server * @param server MCP Server instance */ export function registerCnpjTools(server: McpServer) { // Tool to query information about a Brazilian company by its CNPJ server.tool( "cnpj-search", "Query information about a Brazilian company by its CNPJ (National Registry of Legal Entities)", { cnpj: z.string() .regex(/^\d{14}$/, "CNPJ must contain exactly 14 numbers without any special characters") .describe("CNPJ to be queried (only numbers, 14 digits)") }, async ({ cnpj }) => { console.error(`Consulting CNPJ: ${cnpj}`); const result = await getBrasilApiData(`/cnpj/v1/${cnpj}`); if (!result.success) { return formatErrorResponse(`Error querying CNPJ: ${result.message}`); } // Format the response data const company = result.data; return { content: [{ type: "text" as const, text: ` Informações da Empresa: CNPJ: ${company.cnpj} Razão Social: ${company.razao_social} Nome Fantasia: ${company.nome_fantasia || "N/A"} Situação Cadastral: ${company.descricao_situacao_cadastral || "N/A"} Data de Abertura: ${company.data_inicio_atividade || "N/A"} CNAE Principal: ${company.cnae_fiscal} - ${company.cnae_fiscal_descricao || "N/A"} Natureza Jurídica: ${company.codigo_natureza_juridica} - ${company.natureza_juridica || "N/A"} Endereço: ${company.logradouro || ""} ${company.numero || ""} ${company.complemento || ""} ${company.bairro || ""}, ${company.municipio || ""} - ${company.uf || ""} CEP: ${company.cep || "N/A"} Contato: Telefone: ${company.ddd_telefone_1 || "N/A"} Email: ${company.email || "N/A"} ` }] }; } ); }

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/guilhermelirio/brasil-api-mcp'

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