Skip to main content
Glama

search_kpis

Search for Swedish public sector KPIs by keyword, publication date, or operating area to analyze municipal and regional performance data.

Instructions

Sök efter nyckeltal (KPIs) med fritextsökning, publiceringsdatum eller verksamhetsområde. Returnerar en lista med matchande KPIs. Svenska söktermer ger bäst resultat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSökterm för att filtrera KPIs efter titel (svenska termer ger bäst resultat)
publication_dateNoFiltrera efter publiceringsdatum (YYYY-MM-DD)
operating_areaNoFiltrera efter verksamhetsområde (t.ex. "Utbildning", "Hälso- och sjukvård")
limitNoMax antal resultat (standard: 20, max: 100)

Implementation Reference

  • The async handler function implementing the core logic of search_kpis: fetches cached KPI catalog, applies filters (query, publication_date, operating_area), limits results, and returns formatted JSON.
    handler: async (args: z.infer<typeof searchKpisSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { query, publication_date, operating_area, limit } = args; logger.toolCall('search_kpis', { query, publication_date, operating_area, limit }); try { // Use cached KPI catalog for better performance let kpis = await dataCache.getOrFetch( 'kpi-catalog-full', () => koladaClient.fetchAllData<KPI>('/kpi'), 86400000 // 24 hours ); // Apply filters if (query) { const searchTerm = query.toLowerCase(); kpis = kpis.filter( (k) => k.title.toLowerCase().includes(searchTerm) || k.description?.toLowerCase().includes(searchTerm) || k.id.toLowerCase().includes(searchTerm) ); } if (publication_date) { kpis = kpis.filter((k) => k.publication_date === publication_date); } if (operating_area) { const areaLower = operating_area.toLowerCase(); kpis = kpis.filter((k) => k.operating_area?.toLowerCase().includes(areaLower)); } // Limit results const totalMatches = kpis.length; kpis = kpis.slice(0, limit); logger.toolResult('search_kpis', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { count: kpis.length, total_matches: totalMatches, truncated: totalMatches > limit, kpis: kpis.map((k) => ({ id: k.id, title: k.title, description: k.description, operating_area: k.operating_area, municipality_type: k.municipality_type, has_ou_data: k.has_ou_data, })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('search_kpis', false, Date.now() - startTime); throw error; } },
  • Zod input schema defining parameters for search_kpis tool.
    const searchKpisSchema = z.object({ query: z.string().optional().describe('Sökterm för att filtrera KPIs efter titel (svenska termer ger bäst resultat)'), publication_date: z.string().optional().describe('Filtrera efter publiceringsdatum (YYYY-MM-DD)'), operating_area: z.string().optional().describe('Filtrera efter verksamhetsområde (t.ex. "Utbildning", "Hälso- och sjukvård")'), limit: z.number().min(1).max(100).default(20).describe('Max antal resultat (standard: 20, max: 100)'), });
  • Registration of kpiTools (containing search_kpis) into the combined allTools registry used by MCP server handlers for tool listing and execution.
    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