Skip to main content
Glama
mauricio-cantu

brasil-api-mcp-server

get_cnpj

Retrieve company information using a Brazilian CNPJ number. Query business details through the Brasil API MCP server for data integration.

Instructions

Get information about a company given a CNPJ.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
CNPJYesThe CNPJ to query

Implementation Reference

  • The main handler function that executes the tool logic: fetches company data for the given CNPJ using brasilApiClient and returns a formatted text response.
    handler: async ({ CNPJ }): Promise<McpResponse> => {
      try {
        const result = await brasilApiClient.cnpj.getBy(CNPJ);
        const content: McpTextContent = {
          type: "text",
          text: `CNPJ ${CNPJ} found:\n${prettifyJson(result.data)}`,
        };
        return {
          content: [content],
        };
      } catch (error: any) {
        console.error(error);
        throw new Error(`Failed to fetch CNPJ ${CNPJ}`);
      }
    },
  • Zod schema defining the input parameter 'CNPJ' as a string, along with its TypeScript type.
    const getCNPJToolParams = {
      CNPJ: z.string().describe("The CNPJ to query"),
    };
    
    type GetCNPJToolParams = typeof getCNPJToolParams;
  • src/index.ts:30-41 (registration)
    Registration of the getCNPJTool by including it in the tools array and calling registerTool on the MCP server for each tool.
    const tools = [
      getCepTool,
      getCepV2Tool,
      getBookByISBNTool,
      getCNPJTool,
      getAllBanksTool,
      getBankByCodeTool,
    ];
    
    tools.forEach((tool) => {
      registerTool(server, tool);
    });
  • Helper function that registers a tool definition to the MCP server by calling server.tool with its properties.
    export const registerTool = (server: McpServer, tool: McpToolDefinition) => {
      server.tool(tool.name, tool.description, tool.params, tool.handler);
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves information but does not describe traits like whether it's read-only, requires authentication, has rate limits, returns structured data, or handles errors. For a lookup tool with no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is appropriately sized and front-loaded, making it easy to understand at a glance. Every part of the sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a lookup operation), lack of annotations, and no output schema, the description is incomplete. It does not explain what information is returned, potential error cases, or behavioral aspects like performance or data freshness. For a tool with no structured metadata, more detail is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal meaning beyond the input schema, which has 100% coverage and clearly documents the single parameter 'CNPJ' as 'The CNPJ to query.' The description implies the parameter is required but does not provide additional context like format examples or validation rules. Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get information about a company given a CNPJ.' It specifies the verb ('Get'), resource ('information about a company'), and required input ('CNPJ'). However, it does not distinguish this tool from its siblings (e.g., get_isbn, get_postal_code_v1/v2) beyond the input type, which are similar lookup tools for different identifiers.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, exclusions, or comparisons to sibling tools like get_all_banks or get_bank_by_code, which might be relevant in a business context. Usage is implied by the description but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mauricio-cantu/brasil-api-mcp-server'

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