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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search keyword to find in vote titles (German/French/Italian) | |
| limit | No | Maximum number of results (default: 5, max: 20). |
Implementation Reference
- src/modules/voting.ts:245-275 (handler)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/", }); - src/modules/voting.ts:82-95 (registration)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).", - src/modules/voting.ts:434-435 (handler)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 });