no_municipality_addresses
Find addresses in Norwegian municipalities by specifying a location and optional street filter. Retrieve structured address data for planning, verification, or analysis purposes.
Instructions
List addresses in a Norwegian municipality. Can filter by street name.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| municipality | Yes | Municipality name (e.g. 'OSLO', 'BERGEN', 'TRONDHEIM', 'STAVANGER', 'TROMSØ') | |
| street | No | Optional street name filter | |
| limit | No | Max results (default 10) |
Implementation Reference
- The "no_municipality_addresses" tool definition and its handler implementation, which queries the Kartverket Adresser API.
server.tool( "no_municipality_addresses", "List addresses in a Norwegian municipality. Can filter by street name.", { municipality: z.string().describe("Municipality name (e.g. 'OSLO', 'BERGEN', 'TRONDHEIM', 'STAVANGER', 'TROMSØ')"), street: z.string().optional().describe("Optional street name filter"), limit: z.number().min(1).max(50).optional().describe("Max results (default 10)"), }, async ({ municipality, street, limit }) => { try { const params = { kommunenavn: municipality, 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 in municipality "${municipality}".` }] }; } const lines = [`## Addresses in ${municipality} (${total} 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 }; } } );