Skip to main content
Glama

get_postal_code_v2

Retrieve location details in Brazil using a CEP (postal code). Input a valid CEP to access accurate address information, enhancing applications with precise Brazilian geographical data.

Instructions

Version 2 of 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 location data for the given CEP using BrasilAPI client and returns a formatted text response or throws an error.
    handler: async ({ cep }): Promise<McpResponse> => { try { const result = await brasilApiClient.cep.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 parameters for the tool: a required 'cep' string.
    const getCepV2ToolParams = { cep: z.string().describe("The CEP to query"), };
  • src/index.ts:30-41 (registration)
    The tool is included in the array of tools and registered on the MCP server instance via the registerTool utility.
    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