dk_postal_code_lookup
Find the city, area, municipalities, and geographic boundaries for any 4-digit Danish postal code using Nordic regional data tools.
Instructions
Look up a Danish postal code to get the city/area name, bounding box, and associated municipalities.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| postal_code | Yes | 4-digit Danish postal code, e.g. '2200' |
Implementation Reference
- src/servers/danish-addresses.js:87-109 (handler)The handler for the 'dk_postal_code_lookup' tool, which fetches postal code data from the DAWA API and formats it into a text response.
server.tool( "dk_postal_code_lookup", "Look up a Danish postal code to get the city/area name, bounding box, and associated municipalities.", { postal_code: z.string().regex(/^\d{4}$/).describe("4-digit Danish postal code, e.g. '2200'"), }, async ({ postal_code }) => { try { const data = await dawaFetch(`/postnumre/${postal_code}`); const lines = []; lines.push(`## ${data.nr} ${data.navn}`); if (data.bbox) { lines.push(`**Bounding box:** ${data.bbox[1].toFixed(4)}°N to ${data.bbox[3].toFixed(4)}°N, ${data.bbox[0].toFixed(4)}°E to ${data.bbox[2].toFixed(4)}°E`); } if (data.kommuner && data.kommuner.length) { lines.push(`**Municipalities:** ${data.kommuner.map(k => `${k.navn} (${k.kode})`).join(", ")}`); } return { content: [{ type: "text", text: lines.join("\n") }] }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true }; } } );