Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesSearch query (e.g. 'unemployment', 'GDP', 'housing prices', 'birth rate')
limitNoMax results to return (1–20, default 10)

Implementation Reference

  • 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`,
      });
    }
  • 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)",
          },
        },
      },
    },
  • Registration/dispatch logic for the `search_statistics` tool within the statistics module.
    case "search_statistics":
      return handleSearchStatistics(args);

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/vikramgorla/mcp-swiss'

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