no_search_subunits
Find branches, offices, and departments of Norwegian companies by parent organization number, name search, or municipality. Retrieve up to 50 results per query.
Instructions
Search sub-units (underenheter) - branches, offices, departments of Norwegian companies
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parent_org_number | No | Parent company org number to find its sub-units | |
| query | No | Name search | |
| municipality | No | Municipality name | |
| limit | No | Number of results (max 50) |
Implementation Reference
- The handler for the no_search_subunits tool, which queries the /underenheter API and formats the results.
async ({ parent_org_number, query, municipality, limit }) => { const params = { size: Math.min(limit, 50) }; if (parent_org_number) params["overordnetEnhet"] = parent_org_number.replace(/\s/g, ""); if (query) params.navn = query; if (municipality) params["kommunenummer"] = municipality; const data = await apiFetch("/underenheter", params); const units = data._embedded?.underenheter || []; if (units.length === 0) { return { content: [{ type: "text", text: "No sub-units found." }] }; } const total = data.page?.totalElements || units.length; const header = `Found ${total.toLocaleString()} sub-units (showing ${units.length}):\n`; const results = units.map((u, i) => { const lines = [ `${i + 1}. **${u.navn}**`, ` Org.nr: ${u.organisasjonsnummer}`, ` Parent: ${u.overordnetEnhet || "N/A"}`, ]; if (u.naeringskode1?.beskrivelse) lines.push(` Industry: ${u.naeringskode1.beskrivelse}`); if (u.antallAnsatte != null) lines.push(` Employees: ${u.antallAnsatte}`); lines.push(` Address: ${formatAddress(u.beliggenhetsadresse)}`); return lines.join("\n"); }).join("\n\n"); return { content: [{ type: "text", text: header + "\n" + results }] }; } ); - src/servers/norwegian-companies.js:143-151 (registration)Tool registration for no_search_subunits with Zod schema for input validation.
server.tool( "no_search_subunits", "Search sub-units (underenheter) - branches, offices, departments of Norwegian companies", { parent_org_number: z.string().optional().describe("Parent company org number to find its sub-units"), query: z.string().optional().describe("Name search"), municipality: z.string().optional().describe("Municipality name"), limit: z.number().optional().default(10).describe("Number of results (max 50)"), },