Skip to main content
Glama
guilhermelirio

Brasil API MCP

ddd-info

Retrieve Brazilian area code details including state and cities by entering a 2-digit DDD code.

Instructions

Get information about a Brazilian area code (DDD) including state and cities

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dddYesArea code (DDD) to be queried (only numbers, 2 digits)

Implementation Reference

  • The handler function for the 'ddd-info' tool. It fetches DDD data from BrasilAPI, processes cities, and returns formatted text or error response.
        async ({ ddd }) => {
          console.error(`Getting info for DDD: ${ddd}`);
          
          const result = await getBrasilApiData(`/ddd/v1/${ddd}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error getting DDD information: ${result.message}`);
          }
          
          // Format the response data
          const dddInfo = result.data;
          const cities = dddInfo.cities.join(", ");
          
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    DDD ${ddd} Information:
    State: ${dddInfo.state}
    Cities: ${cities}
    ` 
            }]
          };
        }
  • Zod input schema for the 'ddd-info' tool validating a 2-digit DDD string.
    {
      ddd: z.string()
        .regex(/^\d{2}$/, "DDD must contain exactly 2 digits")
        .describe("Area code (DDD) to be queried (only numbers, 2 digits)")
    },
  • Registration of the 'ddd-info' tool on the MCP server, specifying name, description, input schema, and handler.
      server.tool(
        "ddd-info",
        "Get information about a Brazilian area code (DDD) including state and cities",
        {
          ddd: z.string()
            .regex(/^\d{2}$/, "DDD must contain exactly 2 digits")
            .describe("Area code (DDD) to be queried (only numbers, 2 digits)")
        },
        async ({ ddd }) => {
          console.error(`Getting info for DDD: ${ddd}`);
          
          const result = await getBrasilApiData(`/ddd/v1/${ddd}`);
          
          if (!result.success) {
            return formatErrorResponse(`Error getting DDD information: ${result.message}`);
          }
          
          // Format the response data
          const dddInfo = result.data;
          const cities = dddInfo.cities.join(", ");
          
          return {
            content: [{ 
              type: "text" as const, 
              text: `
    DDD ${ddd} Information:
    State: ${dddInfo.state}
    Cities: ${cities}
    ` 
            }]
          };
        }
      );
  • Utility function to fetch data from BrasilAPI endpoints, returning structured success/error responses.
    export async function getBrasilApiData(endpoint: string, params: Record<string, any> = {}) {
      try {
        const url = `${BASE_URL}${endpoint}`;
        console.error(`Making request to: ${url}`);
        
        const response = await axios.get(url, { params });
        return { 
          data: response.data,
          success: true
        };
      } catch (error: any) {
        console.error(`Error in API request: ${error.message}`);
        
        // Handle API errors in a structured format
        if (error.response) {
          return {
            success: false,
            statusCode: error.response.status,
            message: error.response.data?.message || error.message,
            error: error.response.data
          };
        }
        
        return {
          success: false,
          message: error.message,
          error
        };
      }
  • Utility function to format error messages into MCP tool response format.
    export function formatErrorResponse(message: string) {
      return {
        content: [{ 
          type: "text" as const, 
          text: message 
        }],
        isError: true
      };
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. While it states what the tool does ('Get information'), it doesn't describe behavioral traits like whether it's a read-only operation, potential rate limits, authentication needs, error handling, or what format the information is returned in. For a query tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 front-loads the core purpose ('Get information about a Brazilian area code') and adds specific details ('including state and cities'). There is zero wasted language, and every word earns its place by clarifying the tool's scope.

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 simplicity (1 parameter, 100% schema coverage) but lack of annotations and output schema, the description is incomplete. It doesn't address what the output looks like (e.g., JSON structure, possible fields), error conditions, or behavioral constraints. For a tool with no structured output documentation, the description should provide more context about the return value.

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?

Schema description coverage is 100%, with the parameter 'ddd' fully documented in the schema as a 2-digit area code. The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain valid DDD ranges, examples, or edge cases. With high schema coverage, the baseline score of 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 verb ('Get information') and resource ('Brazilian area code (DDD)') with specific scope ('including state and cities'). It distinguishes from siblings by focusing on area codes rather than banks, currencies, CEP, CNPJ, IBGE data, or domain checks. However, it doesn't explicitly differentiate from potential similar tools (like 'cep-search' which also deals with geographic codes).

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 doesn't mention when this tool is appropriate (e.g., for area code lookup vs. other geographic searches like 'cep-search' for postal codes) or any prerequisites. The agent must infer usage from the tool name and description alone.

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

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