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
| Name | Required | Description | Default |
|---|---|---|---|
| cep | Yes | The CEP to query |
Implementation Reference
- src/tools/cep-v1.ts:16-30 (handler)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}`); } },
- src/tools/cep-v1.ts:6-10 (schema)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); });