no_reverse_geocode
Find Norwegian addresses near geographic coordinates by specifying latitude, longitude, and search radius to locate nearby locations.
Instructions
Find Norwegian addresses near a geographic point (reverse geocoding). Returns addresses within the specified radius.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude (WGS84, e.g. 59.911 for Oslo) | |
| lon | Yes | Longitude (WGS84, e.g. 10.750 for Oslo) | |
| radius | No | Search radius in meters (default 100, max 10000) | |
| limit | No | Max results (default 10) |
Implementation Reference
- The `no_reverse_geocode` tool implementation using the `apiFetch` helper to call the Kartverket Adresser API.
server.tool( "no_reverse_geocode", "Find Norwegian addresses near a geographic point (reverse geocoding). Returns addresses within the specified radius.", { lat: z.number().describe("Latitude (WGS84, e.g. 59.911 for Oslo)"), lon: z.number().describe("Longitude (WGS84, e.g. 10.750 for Oslo)"), radius: z.number().min(1).max(10000).optional().describe("Search radius in meters (default 100, max 10000)"), limit: z.number().min(1).max(50).optional().describe("Max results (default 10)"), }, async ({ lat, lon, radius, limit }) => { try { const data = await apiFetch("/punktsok", { lat, lon, radius: radius || 100, treffPerSide: limit || 10, }); const total = data.metadata?.totaltAntallTreff || 0; if (!data.adresser?.length) { return { content: [{ type: "text", text: `No addresses found within ${radius || 100}m of ${lat}, ${lon}.` }] }; } const lines = [`## Addresses near ${lat.toFixed(4)}°N, ${lon.toFixed(4)}°E (${radius || 100}m radius, ${total} total)\n`]; for (const a of data.adresser) { const dist = a.meterDistanseTilPunkt; lines.push(formatAddress(a)); if (dist != null) lines.push(`Distance: ${Math.round(dist)}m`); lines.push(""); } lines.push(`*Kartverket Adresser API*`); return { content: [{ type: "text", text: lines.join("\n") }] }; } catch (err) { return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true }; } } );