search_zip_code
Search for Japanese addresses by entering a 7-digit zip code.
Instructions
Search zip code data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zipCode | Yes |
Implementation Reference
- src/index.ts:11-38 (registration)Tool 'search_zip_code' is registered via server.registerTool with a Zod inputSchema (zipCode: z.string()), description, and an async handler that calls the fetcher and formats the response.
server.registerTool("search_zip_code", { description: "Search zip code data", inputSchema: z.object({ zipCode: z.string(), }), }, async (args) => { const result = await searchZipCode(args.zipCode); if (!result.results || result.results.length === 0) { return { content: [ { type: "text", text: "No results found", }, ], }; } return { content: [ { type: "text", text: JSON.stringify(result), }, ], }; }); - src/index.ts:13-15 (schema)Input schema for 'search_zip_code' using Zod: expects a single 'zipCode' string parameter.
inputSchema: z.object({ zipCode: z.string(), }), - src/fetcher.ts:1-9 (handler)Core handler logic: searchZipCode async function that fetches from the zipcloud API endpoint with the given zipCode and returns parsed JSON.
const SEARCH_ENDPOINT = "https://zipcloud.ibsnet.co.jp/api/search"; const searchZipCode = async (zipCode: string) => { const response = await fetch(`${SEARCH_ENDPOINT}?zipcode=${zipCode}`); const data = await response.json(); return data; }; export { searchZipCode };