Skip to main content
Glama

search_municipalities

Search and filter Swedish municipalities and regions by name or type to identify specific administrative areas for statistical analysis and data comparison.

Instructions

Sök efter svenska kommuner eller regioner (landsting). Filtrera efter namn eller typ. Det finns 290 kommuner och 21 regioner i Sverige.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSökterm för att filtrera kommuner efter namn
municipality_typeNoTypfilter: K=Kommun, L=Landsting/Region, all=bådaall

Implementation Reference

  • Handler function that performs the municipality search by filtering a cached list of municipalities based on query string and type filter (K=Kommun, L=Region, all). Returns formatted JSON with matching municipalities.
    handler: async (args: z.infer<typeof searchMunicipalitiesSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { query, municipality_type } = args; logger.toolCall('search_municipalities', { query, municipality_type }); try { // Use cached municipality list let municipalities = await dataCache.getOrFetch( 'municipalities-full', () => koladaClient.fetchAllData<Municipality>('/municipality'), 86400000 // 24 hours ); // Apply filters if (query) { const searchTerm = query.toLowerCase(); municipalities = municipalities.filter( (m) => m.title.toLowerCase().includes(searchTerm) || m.id.includes(searchTerm) ); } if (municipality_type !== 'all') { municipalities = municipalities.filter((m) => m.type === municipality_type); } logger.toolResult('search_municipalities', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { count: municipalities.length, municipalities: municipalities.map((m) => ({ id: m.id, title: m.title, type: m.type, type_description: m.type === 'K' ? 'Kommun' : 'Region', })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('search_municipalities', false, Date.now() - startTime); throw error; } },
  • Zod input schema defining optional 'query' for name search and 'municipality_type' enum for filtering by type.
    const searchMunicipalitiesSchema = z.object({ query: z.string().optional().describe('Sökterm för att filtrera kommuner efter namn'), municipality_type: z .enum(['K', 'L', 'all']) .default('all') .describe('Typfilter: K=Kommun, L=Landsting/Region, all=båda'), });
  • Registration of municipalityTools (including search_municipalities) into the central allTools registry, which is used by MCP server's tool listing and calling handlers.
    export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/isakskogstad/Kolada-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server