Skip to main content
Glama

search_votes

Search Swiss popular votes by keyword to find referendum results with yes/no outcomes. Use keywords in German, French, or Italian to locate specific votes and their results.

Instructions

Search Swiss popular votes by keyword in the vote title (e.g. 'Initiative', 'Klimaschutz', 'CO2', 'AHV'). Returns matching votes with yes/no results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch keyword to find in vote titles (German/French/Italian)
limitNoMaximum number of results (default: 5, max: 20).

Implementation Reference

  • The handler function `handleSearchVotes` executes the search logic by querying the database and aggregating results.
    export async function handleSearchVotes(params: {
      query: string;
      limit?: number;
    }): Promise<string> {
      if (!params.query?.trim()) {
        return JSON.stringify({ error: "query parameter is required" });
      }
    
      const limit = Math.min(params.limit ?? 5, 20);
      const keyword = params.query.trim();
    
      const extraWhere = `abst_titel like "%${keyword}%"`;
      const rows = await fetchVoteRows(extraWhere, limit);
      const votes = aggregateVotes(rows).slice(0, limit);
    
      if (votes.length === 0) {
        return JSON.stringify({
          query: keyword,
          count: 0,
          votes: [],
          hint: "Try shorter keywords. Vote titles are in German, French, or Italian.",
        });
      }
    
      return JSON.stringify({
        query: keyword,
        count: votes.length,
        votes,
        source: "Basel-Stadt open data",
        data_url: "https://data.bs.ch/explore/dataset/100345/",
      });
  • The registration of the `search_votes` tool definition, including its description and input schema.
    name: "search_votes",
    description:
      "Search Swiss popular votes by keyword in the vote title (e.g. 'Initiative', 'Klimaschutz', 'CO2', 'AHV'). Returns matching votes with yes/no results.",
    inputSchema: {
      type: "object",
      required: ["query"],
      properties: {
        query: {
          type: "string",
          description: "Search keyword to find in vote titles (German/French/Italian)",
        },
        limit: {
          type: "number",
          description: "Maximum number of results (default: 5, max: 20).",
  • The entry point in the tool router that invokes `handleSearchVotes` when `search_votes` is called.
    case "search_votes":
      return handleSearchVotes(args as { query: string; limit?: number });

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