Skip to main content
Glama

get_voting_results

Retrieve Swiss popular vote results from Basel-Stadt open data, including vote titles, dates, counts, percentages, and eligible voters for national and cantonal votes since 2021.

Instructions

Get results of Swiss popular votes (Volksabstimmungen) from Basel-Stadt open data. Returns vote title, date, yes/no counts, yes percentage, and eligible voters. Covers national and cantonal votes since 2021.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoFilter by year (e.g. 2024). If omitted, returns most recent votes.
limitNoMaximum number of votes to return (default: 10, max: 50).

Implementation Reference

  • The handleGetVotingResults function orchestrates the fetching and aggregation of voting results from Basel-Stadt open data.
    export async function handleGetVotingResults(params: {
      year?: number;
      limit?: number;
    }): Promise<string> {
      const limit = Math.min(params.limit ?? 10, 50);
    
      let extraWhere = "";
      if (params.year) {
        const y = params.year;
        extraWhere = `abst_datum_text like "${y}%"`;
      }
    
      const rows = await fetchVoteRows(extraWhere, limit);
      const votes = aggregateVotes(rows).slice(0, limit);
    
      if (votes.length === 0) {
        return JSON.stringify({
          error: "No voting results found for the given parameters",
          hint: "Try without a year filter, or use a different year (available: 2021–2025)",
        });
      }
    
      const result = {
        count: votes.length,
        source: "Basel-Stadt open data — national & cantonal votes",
        data_url: "https://data.bs.ch/explore/dataset/100345/",
        note: "Results from Basel-Stadt (BS canton) as representative Swiss data. National votes cover the whole country.",
        votes,
      };
    
      const json = JSON.stringify(result);
      if (json.length > 48000) {
        const trimmed = { ...result, votes: votes.slice(0, 5) };
        return JSON.stringify(trimmed);
      }
      return json;
    }
  • Tool definition including name, description, and input schema for get_voting_results.
    export const votingTools = [
      {
        name: "get_voting_results",
        description:
          "Get results of Swiss popular votes (Volksabstimmungen) from Basel-Stadt open data. Returns vote title, date, yes/no counts, yes percentage, and eligible voters. Covers national and cantonal votes since 2021.",
        inputSchema: {
          type: "object",
          properties: {
            year: {
              type: "number",
              description: "Filter by year (e.g. 2024). If omitted, returns most recent votes.",
            },
            limit: {
              type: "number",
              description: "Maximum number of votes to return (default: 10, max: 50).",
            },
          },
        },
      },
  • Registration of the get_voting_results tool within the MCP server using server.tool.
    server.tool(
      "get_voting_results",
      votingTools[0].description,
      votingTools[0].inputSchema,
      async (params) => ({
        content: [
          {
            type: "text",
            text: await handleGetVotingResults(
              params as { year?: number; limit?: number },
            ),
          },
        ],
      }),
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes the return data (vote title, date, counts, etc.) and temporal scope (since 2021), but lacks details on permissions, rate limits, error handling, or data freshness. It adequately covers the core behavior but misses some operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by additional context in a second sentence. Every sentence adds value (data source, return fields, scope), with no wasted words, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 optional parameters, no output schema, no annotations), the description is reasonably complete. It explains what the tool does, what data it returns, and its scope, but could improve by addressing potential limitations or usage constraints to fully compensate for the lack of annotations and output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already fully documents the parameters. The description does not add any parameter-specific semantics beyond what the schema provides (e.g., it mentions filtering by year but doesn't elaborate on format or constraints), meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get results') and resources ('Swiss popular votes from Basel-Stadt open data'), distinguishing it from sibling tools like 'get_vote_details' or 'search_votes' by specifying its scope (Basel-Stadt, since 2021, returns structured vote results).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool (for Swiss popular votes from Basel-Stadt since 2021), but does not explicitly mention when not to use it or name alternatives among sibling tools (e.g., 'get_vote_details' or 'search_votes'), though the scope differentiation is implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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