Skip to main content
Glama
cep-v1.ts935 B
import { z } from "zod"; import { brasilApiClient } from "../apiClient/brasilApiClient.js"; import { McpTextContent, McpToolDefinition } from "../types/MCP.js"; import { prettifyJson } from "../utils/index.js"; const getCepToolParams = { cep: z.string().describe("The CEP to query"), }; type GetCepToolParams = typeof getCepToolParams; export const getCepTool: McpToolDefinition<GetCepToolParams> = { name: "get_postal_code_v1", description: "Get a location data given a CEP (postal code).", params: getCepToolParams, 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}`); } }, };

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