Skip to main content
Glama

get_dams_by_canton

Retrieve Swiss dams under federal supervision for a specific canton using 2-letter canton codes. Provides up to 20 dams with basic details from official Swiss energy data.

Instructions

List all Swiss dams under federal supervision in a given canton. Returns up to 20 dams with basic details. Data source: Swiss Federal Office of Energy (SFOE) via swisstopo BGDI.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cantonYesSwiss canton 2-letter abbreviation code (e.g. 'VS' for Valais, 'GR' for Graubünden, 'BE' for Bern, 'UR' for Uri, 'TI' for Ticino, 'VD' for Vaud).

Implementation Reference

  • The handler implementation for the `get_dams_by_canton` tool, which validates the input canton code, fetches its bounding box, and filters dams within that area.
    case "get_dams_by_canton": {
      const canton = args.canton as string;
      if (!canton?.trim()) {
        throw new Error("canton is required (2-letter code, e.g. 'VS', 'GR', 'BE')");
      }
    
      const cantonCode = canton.trim().toUpperCase();
      if (!/^[A-Z]{2}$/.test(cantonCode)) {
        throw new Error("canton must be a 2-letter Swiss canton code (e.g. 'VS', 'GR', 'BE', 'ZH')");
      }
    
      // Get canton bounding box
      const bbox = await fetchCantonBbox(cantonCode);
      if (!bbox) {
        throw new Error(`Unknown canton code: "${cantonCode}". Use standard 2-letter Swiss canton abbreviations (VS, GR, BE, UR, TI, VD, etc.)`);
      }
    
      const [xmin, ymin, xmax, ymax] = bbox;
    
      // Fetch all dams with geometry to filter by canton bbox
      const allDams = await findDams("%", "damname", true);
    
      // Filter dams whose coordinates fall within the canton bbox
      const cantonDams = allDams.filter((dam) => {
        const x = dam.geometry?.x;
        const y = dam.geometry?.y;
        if (x == null || y == null) return false;
        return x >= xmin && x <= xmax && y >= ymin && y <= ymax;
      });
    
      if (!cantonDams.length) {
        return JSON.stringify({
          canton: cantonCode,
          dams: [],
          count: 0,
          message: `No dams found in canton ${cantonCode}. This canton may not have any dams under federal supervision.`,
          source: `${BASE}/find?layer=${DAMS_LAYER}`,
        }, null, 2);
      }
    
      const limited = cantonDams.slice(0, MAX_RESULTS);
      const formatted = limited.map((dam) => formatDamSummary(dam, cantonCode));
    
      const response = {
        canton: cantonCode,
        dams: formatted,
        count: formatted.length,
        total_in_canton: cantonDams.length,
        note: cantonDams.length > MAX_RESULTS
          ? `Showing first ${MAX_RESULTS} of ${cantonDams.length} dams in canton ${cantonCode}.`
          : undefined,
        source: `${BASE}/find?layer=${DAMS_LAYER}`,
  • The tool definition and input schema for `get_dams_by_canton`.
    {
      name: "get_dams_by_canton",
      description:
        "List all Swiss dams under federal supervision in a given canton. Returns up to 20 dams with basic details. Data source: Swiss Federal Office of Energy (SFOE) via swisstopo BGDI.",
      inputSchema: {
        type: "object",
        required: ["canton"],
        properties: {
          canton: {
            type: "string",
            description:
              "Swiss canton 2-letter abbreviation code (e.g. 'VS' for Valais, 'GR' for Graubünden, 'BE' for Bern, 'UR' for Uri, 'TI' for Ticino, 'VD' for Vaud).",
          },
        },
      },
    },

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