no_address_search
Search Norwegian addresses using text queries, with filters for postal codes and municipalities. Find locations by street names, full addresses, or postal codes.
Instructions
Search for Norwegian addresses by text query. Supports street names, full addresses, postal codes, and municipality filtering.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Address search query (e.g. 'Karl Johans gate 1', 'Storgata Oslo', 'Bryggen Bergen') | |
| postal_code | No | Filter by postal code (4 digits, e.g. '0154') | |
| municipality | No | Filter by municipality name (e.g. 'OSLO', 'BERGEN', 'TRONDHEIM') | |
| limit | No | Max results (default 10, max 50) | |
| fuzzy | No | Enable fuzzy matching for misspellings (default false) |
Implementation Reference
- src/servers/norwegian-addresses.js:43-81 (handler)The 'no_address_search' tool is registered and its handler is defined here using the Kartverket Adresser API to search for Norwegian addresses based on a query and optional filters.
server.tool( "no_address_search", "Search for Norwegian addresses by text query. Supports street names, full addresses, postal codes, and municipality filtering.", { query: z.string().describe("Address search query (e.g. 'Karl Johans gate 1', 'Storgata Oslo', 'Bryggen Bergen')"), postal_code: z.string().optional().describe("Filter by postal code (4 digits, e.g. '0154')"), municipality: z.string().optional().describe("Filter by municipality name (e.g. 'OSLO', 'BERGEN', 'TRONDHEIM')"), limit: z.number().min(1).max(50).optional().describe("Max results (default 10, max 50)"), fuzzy: z.boolean().optional().describe("Enable fuzzy matching for misspellings (default false)"), }, async ({ query, postal_code, municipality, limit, fuzzy }) => { try { const params = { sok: query, treffPerSide: limit || 10, }; if (postal_code) params.postnummer = postal_code; if (municipality) params.kommunenavn = municipality; if (fuzzy) params.fuzzy = "true"; 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 "${query}".` }] }; } const lines = [`## Address Search: "${query}" (${total} total results)\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 }; } } );