Skip to main content
Glama

get_statistic

Retrieve dataset details and resource links from Swiss open data using an opendata.swiss identifier. First use search_statistics to find dataset IDs.

Instructions

Fetch details and resource links for a specific BFS/OFS dataset by its opendata.swiss identifier. Use search_statistics first to find dataset IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataset_idYesDataset identifier from opendata.swiss (e.g. 'bevolkerungsstatistik-einwohner')

Implementation Reference

  • The handler function 'handleGetStatistic' that implements the 'get_statistic' tool logic by fetching dataset details from the CKAN API.
    async function handleGetStatistic(args: Record<string, unknown>): Promise<string> {
      const datasetId = typeof args.dataset_id === "string" ? args.dataset_id.trim() : "";
      if (!datasetId) throw new Error("dataset_id is required");
    
      const url = buildUrl(`${CKAN_BASE}/package_show`, { id: datasetId });
      const data = await fetchJSON<CkanPackageResult>(url);
    
      if (!data.success) throw new Error(`Dataset not found: ${datasetId}`);
    
      const pkg = data.result;
    
      const resources = (pkg.resources ?? []).slice(0, 10).map((r) => ({
        name: resolveText(r.name),
        format: r.format,
        url: r.url,
      }));
    
      const contact = pkg.contact_points?.[0];
      const org = resolveText(pkg.organization?.title);
    
      return JSON.stringify({
        id: pkg.name,
        title: resolveText(pkg.title),
        description: truncate(resolveText(pkg.notes || pkg.description), 500),
        keywords: pkg.keywords?.en ?? pkg.keywords?.de ?? [],
        issued: pkg.issued?.slice(0, 10) ?? "",
        modified: pkg.metadata_modified?.slice(0, 10) ?? "",
        organization: org,
        contact: contact ? { name: contact.name, email: contact.email } : undefined,
        resources,
        source: "opendata.swiss",
        source_url: `https://opendata.swiss/en/dataset/${pkg.name}`,
      });
    }
  • The tool definition and input schema for 'get_statistic'.
      name: "get_statistic",
      description:
        "Fetch details and resource links for a specific BFS/OFS dataset by its opendata.swiss identifier. " +
        "Use search_statistics first to find dataset IDs.",
      inputSchema: {
        type: "object",
        required: ["dataset_id"],
        properties: {
          dataset_id: {
            type: "string",
            description: "Dataset identifier from opendata.swiss (e.g. 'bevolkerungsstatistik-einwohner')",
          },
        },
      },
    },
  • The registration/dispatch logic for 'get_statistic' within the 'handleStatistics' function.
    case "get_statistic":
      return handleGetStatistic(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