Skip to main content
Glama

get_vote_details

Retrieve detailed Swiss popular vote results with per-district breakdowns for Basel-Stadt, including overseas voters, by specifying vote title and date.

Instructions

Get detailed breakdown of a specific Swiss popular vote, including per-district results for Basel-Stadt (Basel city, Riehen, Bettingen, and overseas voters).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vote_titleNoPartial or full vote title to look up (e.g. 'CO2-Gesetz', 'AHV')
dateNoVote date in YYYY-MM-DD format (e.g. '2024-11-24')

Implementation Reference

  • The handler function `handleGetVoteDetails` executes the tool logic by fetching data from the voting API.
    export async function handleGetVoteDetails(params: {
      vote_title?: string;
      date?: string;
    }): Promise<string> {
      if (!params.vote_title && !params.date) {
        return JSON.stringify({
          error: "Provide at least vote_title or date",
        });
      }
    
      const conditions: string[] = [
        `wahllok_name like "%Total%"`,
        `result_art="Schlussresultat"`,
      ];
    
      if (params.vote_title) {
        conditions.push(`abst_titel like "%${params.vote_title.trim()}%"`);
      }
      if (params.date) {
        conditions.push(`abst_datum_text="${params.date.trim()}"`);
      }
    
      const where = conditions.join(" AND ");
      const url = buildUrl(BS_BASE, {
        limit: 100,
        where,
        select:
          "abst_datum_text,abst_id,abst_titel,abst_art,gemein_name,wahllok_name,stimmr_anz,ja_anz,nein_anz,anteil_ja_stimmen",
        order_by: "abst_datum_text desc,abst_id asc",
      });
    
      const rows = await fetchJSON<BsVotingRecord[]>(url, {
        headers: { "User-Agent": USER_AGENT },
      });
    
      if (!rows || rows.length === 0) {
        return JSON.stringify({
          error: "No vote found matching the given parameters",
          hint: "Try partial title (e.g. 'CO2' instead of 'CO2-Gesetz') or check the date format (YYYY-MM-DD)",
        });
      }
    
      // Group by (date, abst_id) — take the first match if multiple votes match
      const firstDate = rows[0].abst_datum_text;
      const firstId = rows[0].abst_id;
      const voteRows = rows.filter(
        (r) => r.abst_datum_text === firstDate && r.abst_id === firstId,
      );
  • The tool definition including its input schema.
    {
      name: "get_vote_details",
      description:
        "Get detailed breakdown of a specific Swiss popular vote, including per-district results for Basel-Stadt (Basel city, Riehen, Bettingen, and overseas voters).",
      inputSchema: {
        type: "object",
        properties: {
          vote_title: {
            type: "string",
            description: "Partial or full vote title to look up (e.g. 'CO2-Gesetz', 'AHV')",
          },
          date: {
            type: "string",
            description: "Vote date in YYYY-MM-DD format (e.g. '2024-11-24')",
          },
        },
  • The tool registration switch-case which routes the request to the `handleGetVoteDetails` function.
    case "get_vote_details":
      return handleGetVoteDetails(args as { vote_title?: string; date?: string });

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