Skip to main content
Glama

get_postal_code_v1

Retrieve location data for any Brazilian address using its CEP postal code. This tool provides detailed address information including street, neighborhood, city, and state from the BrasilAPI database.

Instructions

Get a location data given a CEP (postal code).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cepYesThe CEP to query

Implementation Reference

  • The asynchronous handler function that queries the Brasil API for CEP data, formats the result using prettifyJson, and returns it as McpTextContent, or throws an error on failure.
    handler: async ({ cep }) => { try { const result = await brasilApiClient.cepV1.getBy(cep); const content: McpTextContent = { type: "text", text: `CEP found:\n${prettifyJson(result.data)}`, }; return { content: [content], }; } catch (error: any) { console.error(error); throw new Error(`Failed to fetch cep ${cep}`); } },
  • Zod schema defining the input parameter 'cep' as a string.
    const getCepToolParams = { cep: z.string().describe("The CEP to query"), };
  • src/index.ts:30-41 (registration)
    The tool getCepTool ("get_postal_code_v1") is included in the tools array and registered to the MCP server via registerTool.
    const tools = [ getCepTool, getCepV2Tool, getBookByISBNTool, getCNPJTool, getAllBanksTool, getBankByCodeTool, ]; tools.forEach((tool) => { registerTool(server, tool); });

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