Skip to main content
Glama

get_postal_code_v1

Retrieve location details for any Brazilian address using the CEP (postal code). Simplify address validation and geolocation processes by querying accurate data.

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 fetches CEP (postal code) data from Brasil API using the provided CEP, formats the JSON response, and returns it as MCP text content. Handles errors by throwing a descriptive error.
    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 single input parameter 'cep' as a required string, with description.
    const getCepToolParams = { cep: z.string().describe("The CEP to query"), }; type GetCepToolParams = typeof getCepToolParams;
  • src/index.ts:30-41 (registration)
    Registration of all tools, including getCepTool (imported from cep-v1.ts), by adding them to an array and iterating to call registerTool(server, tool), which registers the tool with the MCP server using its name, description, params, and handler.
    const tools = [ getCepTool, getCepV2Tool, getBookByISBNTool, getCNPJTool, getAllBanksTool, getBankByCodeTool, ]; tools.forEach((tool) => { registerTool(server, tool); });

Other Tools

Related 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