search_statistics
Search Swiss Federal Statistical Office datasets on opendata.swiss to find official statistics on topics like unemployment, GDP, housing prices, and birth rates.
Instructions
Search Swiss Federal Statistical Office (BFS/OFS/UST) datasets on opendata.swiss. Returns matching dataset titles, IDs, and descriptions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (e.g. 'unemployment', 'GDP', 'housing prices', 'birth rate') | |
| limit | No | Max results to return (1–20, default 10) |
Implementation Reference
- src/modules/statistics.ts:297-329 (handler)The implementation of the `search_statistics` tool handler, which searches opendata.swiss for datasets from the BFS/OFS organization.
async function handleSearchStatistics(args: Record<string, unknown>): Promise<string> { const query = typeof args.query === "string" ? args.query.trim() : ""; if (!query) throw new Error("query is required"); const limit = Math.min(20, Math.max(1, typeof args.limit === "number" ? args.limit : 10)); const url = buildUrl(`${CKAN_BASE}/package_search`, { q: query, rows: limit, fq: `organization:${BFS_ORG}`, }); const data = await fetchJSON<CkanSearchResult>(url); if (!data.success) throw new Error("opendata.swiss search failed"); const results = data.result.results.map((pkg) => ({ id: pkg.name, title: resolveText(pkg.title), description: truncate(resolveText(pkg.notes || pkg.description), 200), keywords: pkg.keywords?.en ?? pkg.keywords?.de ?? [], modified: pkg.metadata_modified?.slice(0, 10) ?? "", })); return JSON.stringify({ query, total_matches: data.result.count, returned: results.length, results, source: "opendata.swiss — Federal Statistical Office (BFS/OFS)", source_url: `https://opendata.swiss/en/organization/bundesamt-fur-statistik-bfs`, }); } - src/modules/statistics.ts:142-161 (schema)The schema definition for the `search_statistics` tool.
{ name: "search_statistics", description: "Search Swiss Federal Statistical Office (BFS/OFS/UST) datasets on opendata.swiss. " + "Returns matching dataset titles, IDs, and descriptions.", inputSchema: { type: "object", required: ["query"], properties: { query: { type: "string", description: "Search query (e.g. 'unemployment', 'GDP', 'housing prices', 'birth rate')", }, limit: { type: "number", description: "Max results to return (1–20, default 10)", }, }, }, }, - src/modules/statistics.ts:375-376 (registration)Registration/dispatch logic for the `search_statistics` tool within the statistics module.
case "search_statistics": return handleSearchStatistics(args);