no_postal_code_lookup
Find addresses in Norwegian postal code areas. Use this tool to explore locations within specific postal districts by entering a 4-digit postal code.
Instructions
List addresses in a Norwegian postal code area. Useful for exploring what's in a given postal district.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| postal_code | Yes | Norwegian postal code (4 digits, e.g. '0154', '5003', '7010') | |
| street | No | Optional street name filter within the postal code area | |
| limit | No | Max results (default 10) |
Implementation Reference
- The handler function that executes the logic for the "no_postal_code_lookup" tool, calling the address API.
async ({ postal_code, street, limit }) => { try { const params = { postnummer: postal_code, treffPerSide: limit || 10, }; if (street) params.adressenavn = street; const data = await apiFetch("/sok", params); const total = data.metadata?.totaltAntallTreff || 0; if (!data.adresser?.length) { return { content: [{ type: "text", text: `No addresses found for postal code ${postal_code}.` }] }; } const poststed = data.adresser[0]?.poststed || ""; const lines = [`## Postal Code ${postal_code} ${poststed} (${total} addresses total)\n`]; for (const a of data.adresser) { lines.push(formatAddress(a)); lines.push(""); } lines.push(`*Kartverket Adresser API — showing ${data.adresser.length} of ${total}*`); return { content: [{ type: "text", text: lines.join("\n") }] }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true }; } } - src/servers/norwegian-addresses.js:121-128 (registration)The registration of the "no_postal_code_lookup" tool, including its schema/parameter definitions.
server.tool( "no_postal_code_lookup", "List addresses in a Norwegian postal code area. Useful for exploring what's in a given postal district.", { postal_code: z.string().describe("Norwegian postal code (4 digits, e.g. '0154', '5003', '7010')"), street: z.string().optional().describe("Optional street name filter within the postal code area"), limit: z.number().min(1).max(50).optional().describe("Max results (default 10)"), },