Skip to main content
Glama
29N Elections MCP

29N Elections MCP

29N Elections MCP

Official results of Spain's general election of 29 November 2026, for any AI assistant.

A Model Context Protocol server for the public results website of the 29N general election (Congreso de los Diputados and Senado), published by the Ministerio del Interior.

Python MCP Transport License: MIT Read-only

Quick start · Connect a client · Available tools · Available data

English · Spanish


Give your AI assistant direct access to the official 29N results.

This server lets any MCP client (Claude, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Zed and others) read the results that the Ministerio del Interior publishes on resultados.29neleccionesgenerales.com. Ask in plain language, for example "What was the turnout in Madrid at 18:00, compared with 2023?", and the assistant will check the publication phase, find the territory, and answer with the official figures and a link to the official page.

Unofficial project. This server is not affiliated with, endorsed by or sponsored by the Ministerio del Interior or any other public body. It reads the same public data that the official website shows. See Data source and attribution.

Hosted endpoint

Available soon (meanwhile, run it locally)

Transport

stdio (default) or Streamable HTTP

Protocol

MCP revision 2026-07-28 (stateless); earlier revisions through the initialize handshake

Authentication

None, the data is public

Coverage

Congreso and Senado: Spain, autonomous communities, provinces, islands, municipalities, municipal districts, polling places and their polling stations (tally sheets as PDF)

Phases

Constitution of polling stations, turnout updates (14:00 and 18:00) and vote count (from 20:00)

Language

Tool descriptions in English; territory and party names in Spanish, as the website publishes them

Reference

Chambers, levels, phases and identifiers in the catalogue

Why use it

  • Real data, not memory. Every figure is read from the official results website when the tool is called.

  • Phase-aware. The server knows whether turnout or votes are being published and tells the assistant not to report party results before the count starts.

  • Always sourced. Each result carries a source object with the publisher, the official page, the API URLs read, the phase, the data source (provisional or definitive) and the time the data was retrieved.

  • Typed. Every tool declares an outputSchema and returns structuredContent, plus a next_step hint for the assistant.

Contents

Related MCP server: onpe-mcp

Quick start

  1. Install uv and clone the repository (details).

  2. Register the server in your client, for example with Claude Code:

    claude mcp add elecciones29n -- uv run --directory /path/to/elecciones29n-mcp elecciones29n-mcp
  3. Ask a question: "What is the latest turnout in Spain for the 29N election?"

Installation

Two ways to use the server: the hosted endpoint (available soon) or a local copy running on your machine. The local setup is available today.

Hosted server

Available soon. A public endpoint has not been published yet. Once it is, this section will list the URL and the configuration snippets for each client.

Endpoint

Available soon

Transport

Streamable HTTP

Authentication

None

Run locally

Requirements: Python 3.11 or later, and uv.

git clone <repository-url> elecciones29n-mcp
cd elecciones29n-mcp
uv sync
uv run elecciones29n-mcp

The server starts on the stdio transport and waits for an MCP client. It prints nothing until a client connects; that is expected.

To serve Streamable HTTP instead (for example, for a shared deployment), set MCP_TRANSPORT=http. The server listens on MCP_HOST:MCP_PORT (by default 127.0.0.1:8000, reachable only from the same machine) and the endpoint path is /mcp, so a local client connects to http://localhost:8000/mcp:

MCP_TRANSPORT=http MCP_PORT=8000 uv run elecciones29n-mcp

To update an existing clone, run git pull and then uv sync again.

Connect a client

In the snippets below, replace /path/to/elecciones29n-mcp with the absolute path of your clone.

Command-line clients (one line)

Client

Command

Claude Code

claude mcp add elecciones29n -- uv run --directory /path/to/elecciones29n-mcp elecciones29n-mcp

Codex (OpenAI)

codex mcp add elecciones29n -- uv run --directory /path/to/elecciones29n-mcp elecciones29n-mcp

VS Code

code --add-mcp '{"name":"elecciones29n","command":"uv","args":["run","--directory","/path/to/elecciones29n-mcp","elecciones29n-mcp"]}'

Clients with a JSON file

Most clients read the same block. Paste it into the file for your client and restart it:

{
	"mcpServers": {
		"elecciones29n": {
			"command": "uv",
			"args": ["run", "--directory", "/path/to/elecciones29n-mcp", "elecciones29n-mcp"]
		}
	}
}

Client

Configuration file

Claude Desktop (macOS)

~/Library/Application Support/Claude/claude_desktop_config.json

Claude Desktop (Windows)

%APPDATA%\Claude\claude_desktop_config.json

Claude Desktop (Microsoft Store)

%LOCALAPPDATA%\Packages\Claude_pzs8sxrjxfjjc\LocalCache\Roaming\Claude\claude_desktop_config.json

Cursor

~/.cursor/mcp.json (global) or .cursor/mcp.json (project)

Windsurf

~/.codeium/windsurf/mcp_config.json

Gemini CLI

~/.gemini/settings.json

Cline, LM Studio and others

The client's MCP settings file (same mcpServers block)

Some clients use a different format:

{
	"servers": {
		"elecciones29n": {
			"type": "stdio",
			"command": "uv",
			"args": ["run", "--directory", "/path/to/elecciones29n-mcp", "elecciones29n-mcp"]
		}
	}
}
[mcp_servers.elecciones29n]
command = "uv"
args = ["run", "--directory", "/path/to/elecciones29n-mcp", "elecciones29n-mcp"]

Configuration

The server is configured with environment variables. All of them are optional.

Variable

Default

Description

MCP_TRANSPORT

stdio

stdio, or http (also streamable-http) for Streamable HTTP.

MCP_HOST

127.0.0.1

Bind address in HTTP mode. Set 0.0.0.0 only to expose the server on purpose (for example, inside a container behind a reverse proxy): it has no authentication.

MCP_PORT

8000

Port in HTTP mode. The endpoint path is /mcp.

ELECCIONES29N_BASE_URL

https://resultados.29neleccionesgenerales.com

Origin of the results website and its API. Also used to build the official page links.

ELECCIONES29N_USER_AGENT

A current desktop Chrome User-Agent

User-Agent sent to the website. The website firewall rejects non-browser agents (see Troubleshooting).

Built-in behaviour (not configurable):

  • Caching. Responses are cached in memory (at most 256 entries; expired entries are dropped first, then the least recently used): the website configuration for 10 seconds; territory results for the website polling interval (30 seconds today); the territory tree and the candidacies catalogue for 6 hours, or until the configuration announces a new version. If a refreshed catalogue still carries the old version (the website copy lags behind its configuration), it is kept for 60 seconds before checking again. Concurrent requests for the same data share one upstream request. Tally sheet PDFs are kept for 5 minutes (at most 4).

  • Retrieval time. source.fetched_at is the time the data was actually retrieved from the website, so a cached answer keeps its original time.

  • Retries. Up to 3 attempts on HTTP 429, 502, 503 and 504 and on transport errors (timeouts, refused, reset or truncated connections), with exponential backoff or the Retry-After delay of 429/503 answers (at most 10 seconds). At most 8 requests run at the same time.

Example questions

  • "What was the turnout in Spain at 18:00, and how does it compare with 2023?"

  • "How many polling stations opened in the province of Sevilla?"

  • "Give me the turnout of every province of Andalucía."

  • "How many seats does each party have in the Congreso right now, and how much has been counted?"

  • "Which party is winning in each province?"

  • "Who was elected senator for Madrid?"

  • "Which polling stations does my polling place have, and can I see the tally sheet of one of them?"

  • "How does Compromís appear in the results, and what is its acronym and color?"

Available tools

The server exposes seven read-only tools. It is stateless: the tools are chained by passing the scope_id values that the search returns (and the polling station codes that elecciones29n_get_polling_stations returns). Every tool except elecciones29n_get_status takes a single params object.

Step

Tool

Description

1

elecciones29n_get_status

Publication status: current phase (0 constitution, 1 turnout, 2 count), turnout update announced by the configuration (indicative), active data source (pro provisional or def definitive), whether tally sheets are published, official alert and data versions. Takes no arguments.

2

elecciones29n_search_scopes

Finds territories (scopes) by name or official territory code, ignoring accents, case and word order. Returns scope_id, code, level, parents (to tell homonyms apart), child_levels and the official page. With level=110 it finds polling places.

3

elecciones29n_get_scope_results

Results of one territory: polling stations constituted, turnout updates compared with 2023 and, from phase 2, vote totals, parties (votes, %, seats, change vs 2023) and Senate candidates. Optionally summarizes every child territory of one level. During the count, constitution and turnout come from the election-day snapshot.

4

elecciones29n_get_winners_map

The winning or leading candidacy of every child territory of a scope (for example, each province of Spain), with its seats and the share of the census counted, plus a tally per candidacy. Each entry says whether it is the official winner, an inferred leader or a tie. Phase 2 only.

5

elecciones29n_list_parties

Candidacies of the 29N call (code, acronym, name, color and group), optionally filtered by a word of the name or acronym.

6

elecciones29n_get_polling_stations

Polling stations of one polling place (level 110): code, short label (district-section-letter) and whether each one has been counted.

7

elecciones29n_get_tally_sheet

Metadata of the tally sheet (acta) of one polling station (send and processing dates, size, SHA-256) and the URI of the resource that serves the PDF. Only when the website publishes tally sheets.

Parameters (all inside params):

Tool

Parameters

elecciones29n_search_scopes

queries (1–15 terms, required), chamber (congreso default | senado), level (number or name, optional), limit (1–100, default 20)

elecciones29n_get_scope_results

scope_id (24 hex characters, required), chamber, data_source (auto default | pro | def), children_level (number or name, optional), children_limit (1–500, default 60)

elecciones29n_get_winners_map

scope_id (required), level (number or name, required; circunscripciones for every Senate constituency), chamber, data_source, limit (1–1000, default 200)

elecciones29n_list_parties

chamber, query (optional, up to 100 characters)

elecciones29n_get_polling_stations

scope_id (a level-110 polling place, required), chamber, data_source

elecciones29n_get_tally_sheet

mesa_code (polling station code such as 2807903650A, required), chamber

Levels can be given as a number or a name in Spanish or English: 1 nacional, 20 comunidad, 30 provincia, 70 isla, 90 municipio, 100 distrito, 110 local. See the catalogue.

The server also publishes two resources:

Resource

Content

elecciones29n://instructions

The usage guide (the same text it sends as server instructions), Markdown.

elecciones29n://tally-sheet/{chamber}/{mesa_code}

Resource template: the tally sheet PDF (application/pdf) of one polling station. Its URI is returned by elecciones29n_get_tally_sheet, which never puts the file itself in its result.

How it uses the tools (simple case):

sequenceDiagram
    participant A as AI assistant
    participant S as 29N MCP server
    participant W as Results website API

    Note over A,S: Step 1 · what is published?
    A->>S: elecciones29n_get_status()
    S->>W: getConfig
    S-->>A: phase, turnout update, data source, alert

    Note over A,S: Step 2 · find the territory
    A->>S: elecciones29n_search_scopes(queries=["Madrid"])
    S->>W: getNomenclator (cached)
    S-->>A: scopes (scope_id, parents, child_levels)

    Note over A,S: Step 3 · get the figures
    A->>S: elecciones29n_get_scope_results(scope_id, children_level?)
    S->>W: getScopeData (phase 2 with children: getScopeDataTopPartidosGanadores)
    S->>W: phase 2: getScopeData day snapshot (turnout)
    S-->>A: constitution, turnout or count + source

    Note over A,S: Step 4 (phase 2) · winners by territory
    A->>S: elecciones29n_get_winners_map(scope_id, level=30)
    S->>W: getScopeDataTopPartidosGanadores
    S-->>A: winner, leader or tie of each child territory + tally

    Note over A,S: Step 5 (optional) · polling stations and tally sheets
    A->>S: elecciones29n_get_polling_stations(scope_id of a polling place)
    S->>W: getScopesLocalMesa
    A->>S: elecciones29n_get_tally_sheet(mesa_code)
    S->>W: getImagen
    S-->>A: metadata + resource URI
    A->>S: resources/read elecciones29n://tally-sheet/...
    S-->>A: PDF blob

Every result includes next_step, a short instruction that tells the assistant what to report and what to call next (for example, not to report party results while the count has not started).

All seven tools are annotated readOnlyHint, idempotentHint and openWorldHint, and not destructiveHint.

The server is stateless, so this order is recommended, not enforced: each tool validates its own inputs and, when one is missing or wrong, answers with an error that says which tool to call first.

Step

Tool

Input it expects

1

elecciones29n_get_status

Nothing. Call it at the start and again to learn about new data.

2

elecciones29n_search_scopes

Names or official territory codes of the places the user mentions.

3

elecciones29n_get_scope_results

A scope_id from step 2 and, optionally, a children_level from its child_levels.

4

elecciones29n_get_winners_map

A scope_id from step 2 and a level from its child_levels. Phase 2 only.

5

elecciones29n_list_parties

Nothing, or a word of a party name or acronym. Any time.

6

elecciones29n_get_polling_stations

The scope_id of a polling place (level 110) from step 2.

7

elecciones29n_get_tally_sheet

A polling station code from step 6, once scrutiny_records_available is true.

Available data

The server covers the 2 chambers of the 29N general election (Congreso, 350 deputies; Senado, 208 senators), 3 publication phases and 8 territory levels, from Spain down to polling stations, with every figure in its provisional and definitive versions and the 2023 election as the comparison baseline.

See Resources/Catalogue.md for the chambers, election calls, phases, data sources, levels, example identifiers, polling station codes, official website routes and API endpoints, plus a glossary.

MCP protocol compliance

The server targets MCP specification revision 2026-07-28 and is built on the official Python SDK (mcp[cli]>=2.3.0,<3).

  • Stateless. No session state is kept between requests; tools are chained through explicit scope_id values, not through a server-side flow. Clients negotiate with server/discover. Clients on earlier revisions (2024-11-05 to 2025-11-25) can still connect through the initialize handshake that the SDK keeps.

  • Typed results. Every tool returns a Pydantic model: the SDK publishes its JSON Schema as the tool outputSchema and sends the result as structuredContent (with a JSON text copy in content for clients that ignore structured output).

  • Cache hints. tools/list, resources/list and resources/templates/list carry ttlMs = 3,600,000 (one hour) and cacheScope = public, because they do not change while the server runs; resources/read carries ttlMs = 300,000 (five minutes), because tally sheets can be resent.

  • Binary resources. The tally sheet template returns the PDF as a blob with mimeType application/pdf; elecciones29n_get_tally_sheet adds a resource_link content block next to its structured metadata.

  • Errors. Upstream failures become tool errors (isError) with an actionable message, never protocol errors.

  • No subscriptions. The server sends no change notifications; clients call elecciones29n_get_status again to learn about new data.

Development

The server is a small package under src/elecciones29n_mcp/:

File

Role

server.py

Entry point (elecciones29n-mcp) and transport selection.

tools.py

The MCP server instance, the instructions resource, the tally sheet resource template and the seven tools.

client.py, cache.py

HTTP client for the results API (retries, concurrency limit, version-aware cache) and in-memory TTL cache.

models.py

Pydantic input and output models (the source of every outputSchema).

utils.py

Territory search, provisional/definitive value selection and payload normalization.

config.py

Environment variables, election constants and the instruction text.

Resources/elecciones29n_mcp_instructions.md is the usage guide the server sends to the client; it is bundled into the package.

Install the dependencies (including the development group) and run the tests:

uv sync
uv run pytest

The tests use trimmed copies of real responses in tests/fixtures/, synthetic payloads (synthetic_*.json, including a tiny PDF) for the endpoints not published yet, and a fake API, so they never call the website.

Troubleshooting

Symptom

Fix

The server does not appear in the client

Check that /path/to/elecciones29n-mcp is absolute and that uv is on the client's PATH, then restart the client completely.

Error 403 (CloudFront WAF)

The website firewall rejected the request: it blocks clients that do not look like a browser and may rate limit. Set ELECCIONES29N_USER_AGENT to a current desktop browser User-Agent, restart the server, or wait a few minutes.

Error 404

The data is not published yet for the current phase, or the identifier does not exist. Check the phase with elecciones29n_get_status and take scope_id from elecciones29n_search_scopes.

A response that is not JSON

The website returned an HTML error page, usually for data that is not published yet. Try again later.

Timeouts or Error 5xx on election night

The website is under heavy load. The server already retries; try again in a moment.

No party results or empty winners map

Expected before phase 2 (polls close at 20:00) or while count.started is false.

Unknown scope_id

The identifier does not belong to the chosen chamber, or was typed by hand. Search again with the same chamber.

incomplete configuration

The website returned a configuration without a valid phase or data source. It is usually a transient glitch: try again in about 10 seconds.

Polling stations or tally sheets not published yet

The website publishes them late (usually after the count), and tally sheets only when scrutiny_records_available is true in elecciones29n_get_status.

Limitations

  • Phases. Phase 0 publishes the constitution of polling stations, phase 1 the turnout updates (14:00 and 18:00) and phase 2 the vote count. Party results and winners exist only in phase 2.

  • Senado before the count. Polling stations and turnout are common to both chambers and are published only under the Congreso; Senado results start in phase 2.

  • Provisional vs definitive. Every figure exists as pro (provisional count on election night) and def (definitive count, published days later). data_source="auto" uses the source the website marks as active. Provisional figures can change.

  • Turnout update number. turnout_update comes from the website configuration and can lag behind the territory data; turnout.latest_published is the update to report.

  • Baselines. Previous-election figures (totals, turnout and party comparisons) are always the definitive 2023 count, as on the website; current figures and their deltas use the selected data source.

  • Winners. A territory has no winner until the selected data source has counted part of its census. winner_basis says whether the winner is the one marked by the website (official), a leader computed from seats and votes (inferred_leader) or a tie.

  • Polling stations and tally sheets. elecciones29n_get_polling_stations and elecciones29n_get_tally_sheet use endpoints inferred from the website code (getScopesLocalMesa, getImagen) that were not published yet when they were written: they are not validated live. Tally sheets are capped at 10 MB and served only as PDF resources; their figures are not machine-read.

  • Not exposed. Polling-station level results, logos and candidate portraits, map geometry, downloadable files, and other presentation-only assets of the website: translation files (/assets/locales/{lng}/{ns}.json), versioned shared assets (/shared-assets/...: logos, -leader portraits, topojson maps including real_{level} variants), the live video stream and the markup of official alerts (the alert text is returned by elecciones29n_get_status).

  • Official links. official_url points to routes of the website's single-page app. The website answers those URLs with HTTP 404 and the app shell, which then renders the page in a browser; tools that only check the HTTP status may report them as broken.

  • Unofficial client. The API is the website's own backend. It is not documented as a public API and can change or block automated clients without notice.

  • Comparisons. Previous-election figures refer to the general election of 23 July 2023 (call 07-23).

  • Hosted endpoint. It is not available yet; use the local setup.

Privacy

No authentication and no personal data are needed. The server only forwards the requests required to answer the question to the public results website, with a browser User-Agent and a Referer header pointing to the website itself. It stores nothing on disk and sends no telemetry; its only log output is the list of API requests written to the server's standard error. Candidate names in Senate results are public electoral information, as published by the website.

Data source and attribution

The results are published by the Ministerio del Interior (Gobierno de España) on the official results website of the 29N general election, resultados.29neleccionesgenerales.com. When you reuse the figures, cite the Ministerio del Interior as the source and link to the official_url returned with each result; check the website's legal notice for the reuse conditions.

This project is independent. It is not affiliated with, endorsed by or sponsored by the Ministerio del Interior, the Government of Spain or any electoral authority. The provisional results published on election night are informative; the definitive results come from the general count (escrutinio general) carried out by the electoral boards.

WIP and disclaimer

Work in progress

This project is currently under active development. The polling station and tally sheet tools rely on endpoints that the website had not published yet when they were written.

Disclaimer

This repository and its contents are provided for informational and technical purposes only. Use of this code is at your own risk.

The software is provided "as is", without warranty of any kind, either expressed or implied. The figures it returns are copied from the official website at request time and may be incomplete, provisional or out of date.

By using this repository, you acknowledge that:

  • You are responsible for reviewing and testing the code before using it in any production or critical environment.

  • You must check any figure that matters against the official website before relying on it.

  • The authors are not liable for any direct, indirect or consequential damages arising from the use of this software.

Package maintenance and contributing

Any contribution is welcome and should be done through pull requests and/or issues. Pull requests should include updated tests and updated documentation. If functionality is changed, the tool docstrings (the descriptions that the assistant reads) should be added or updated.

Licensing

The code of this project is licensed under the MIT License.

Available Tools

7 tools
elecciones29n_get_polling_stationsList 29N polling stations of a polling placeA
Read-onlyIdempotent
Use this tool to list the polling stations (mesas) of ONE polling place (local electoral):
their codes, the short label the official website shows and whether each one has been
counted. The codes are the input of 'elecciones29n_get_tally_sheet'.

WHEN TO USE IT:
When the user asks about a specific polling place or polling station, or wants the tally
sheet (acta) of a polling station.

INPUT PARAMETERS (What it receives):
- params.scope_id (str, required): scope_id of a polling place (level 110), found with
  'elecciones29n_search_scopes' and level=110 (or 'local').
- params.chamber ('congreso' default | 'senado').
- params.data_source ('auto' default | 'pro' | 'def'): source of the 'scrutinized' flags.

WHAT IT RETURNS:
- local and parents: the polling place and its enclosing territories.
- polling_stations: code (e.g. '2807903650A'), label ('03-650-A': district-section-letter),
  name, scope_id, municipality_code, district, section, letter and 'scrutinized'.
- total, scrutinized_count, tally_sheets_available, next_step and source.

OPERATING NOTES:
- The website publishes this list late (often only after the count); until then the tool
  says it is not published yet. This endpoint is inferred from the website code and has
  not been validated live yet.
- It contains no votes: use 'elecciones29n_get_scope_results' for results.

Inputs: params (required). Returns: Polling stations of one polling place.

elecciones29n_get_scope_resultsGet 29N results of a territoryA
Read-onlyIdempotent
Use this tool to get the official 29N figures of ONE territory: polling stations constituted,
turnout updates compared with 2023 and, once counting has started, votes, percentages and
seats of every candidacy (and Senate candidates).

WHEN TO USE IT:
After 'elecciones29n_search_scopes' returned the scope_id of the territory the user asks about.

INPUT PARAMETERS (What it receives):
- params.scope_id (str, required): 24-hex scope_id from 'elecciones29n_search_scopes'.
- params.chamber ('congreso' default | 'senado'): must match the chamber used in the search.
- params.data_source ('auto' default | 'pro' | 'def'): provisional or definitive figures;
  'auto' uses the source the website marks as active.
- params.children_level (optional, number or name): also summarize every child territory of
  that level. It must be one of the scope 'child_levels'.
- params.children_limit (1-500, default 60).

WHAT IT RETURNS:
- scope: name, official territory code, level, census, polling stations, parents and child_levels.
- constitution: polling stations opened/suspended (absolute and %).
- turnout: turnout updates (time, votes, %), each with 'published' and the 2023 figure at the
  same time ('previous', with deltas). 'latest_published' is the one to report.
- count (phase 2): totals (votes, valid, blank, null, abstention, turnout), 'counted_pct',
  'seats_at_stake', 'parties' (code, acronym, name, color, votes, votes_pct, seats and the
  2023 counterpart with deltas), 'candidates' (Senado: votes and elected flag), 'previous'
  totals of 2023 and 'change_vs_previous'. 'started' is false until counting begins.
- children / children_total / children_truncated: per-child summary when 'children_level'
  was given: turnout, or count progress ('census_counted_pct' = share of the census counted,
  'polling_stations_counted_pct' = share of polling stations counted, when reported) and
  the leading party (only once the selected source has counted).
- next_step and source (cite it, including data_source and fetched_at = retrieval time).

OPERATING NOTES:
- Never report party results before phase 2 or while 'count.started' is false.
- While counting, always say which percentage has been counted and that figures are provisional.
- Report figures exactly as returned; do not round seats or invent missing values.
- During the count, constitution and turnout come from the day snapshot published under the
  Congreso (common to both chambers); the 2023 baseline is always the definitive count.

Inputs: params (required). Returns: Results of one territory for the current phase.

elecciones29n_get_statusGet 29N results publication statusA
Read-onlyIdempotent
Use this tool FIRST for any question about Spain's general election of 29 November 2026
(29N): turnout, polling stations, votes, seats, winners, elected senators. It tells you what
the Ministerio del Interior has published so far. Never answer such questions from memory.

WHEN TO USE IT:
At the start of every conversation about 29N results, and again later to know whether new
data (a new turnout update, the start of the count, definitive results) is available.

INPUT PARAMETERS (What it receives):
None.

WHAT IT RETURNS:
- phase / phase_label: 0 constitution of polling stations, 1 voter turnout updates,
  2 vote count (scrutiny). Party votes and seats exist only in phase 2.
- turnout_update: turnout update announced by the website configuration (1 = 14:00,
  2 = 18:00). It is only indicative: it can lag behind the published data. The latest
  turnout to report is 'turnout.latest_published' of 'elecciones29n_get_scope_results'.
- active_data_source: 'pro' (provisional, election night) or 'def' (definitive).
- is_open, polling_active, polling_interval_seconds: publication state of the website.
- alert: official alert message in Spanish, if one is active. Relay it to the user.
- versions: data versions announced by the website.
- next_step: what to call next.
- source: attribution (official website, URL, phase, fetch time). Always cite it.

OPERATING NOTES:
- The figures change during election night: re-check the status before reporting a final result.
- Then use 'elecciones29n_search_scopes' to find the territory the user asks about.

Inputs: no named parameters. Returns: Current state of the official results publication.

elecciones29n_get_tally_sheetGet the 29N tally sheet of a polling stationA
Read-onlyIdempotent
Use this tool to get the official tally sheet (acta de escrutinio) of ONE polling station:
the scanned PDF that the polling station sent after counting its votes.

WHEN TO USE IT:
When the user asks to see or check the tally sheet of a specific polling station, after
'elecciones29n_get_polling_stations' returned its code.

INPUT PARAMETERS (What it receives):
- params.mesa_code (str, required): polling station 'code' from
  'elecciones29n_get_polling_stations', e.g. '2807903650A'.
- params.chamber ('congreso' default | 'senado').

WHAT IT RETURNS:
- Metadata only (never the file contents): mesa_code, label, election_code, record_id,
  scope_id, sent_at, processing_state, processing_date, document_type, mime_type,
  size_bytes and sha256 of the PDF.
- resource_uri: 'elecciones29n://tally-sheet/{chamber}/{mesa_code}'. Read that resource
  (resources/read) to get the PDF; the result also carries it as a resource link.
- next_step and source.

OPERATING NOTES:
- Tally sheets exist only when the website reports 'scrutiny_records_available' (see
  'elecciones29n_get_status') and only for polling stations already counted.
- This endpoint is inferred from the website code and has not been validated live yet.
- The figures of a tally sheet are not machine-read: use 'elecciones29n_get_scope_results'
  for results.

Inputs: params (required). Returns: Metadata of the tally sheet (acta) of one polling station; the PDF is a resourc…

elecciones29n_get_winners_mapGet 29N winners by territoryA
Read-onlyIdempotent
Use this tool to know which candidacy won (or leads) in EVERY child territory of a scope:
e.g. the winner in each province of Spain, or in each municipality of a province, with the
seats it obtained there and how much has been counted.

WHEN TO USE IT:
During or after the vote count (phase 2), for questions like "who won in each province",
"how many provinces did X win", or to draw a winners map.

INPUT PARAMETERS (What it receives):
- params.scope_id (str, required): parent territory from 'elecciones29n_search_scopes'
  (España is '00000000000000000000000b').
- params.chamber ('congreso' default | 'senado').
- params.level (number or name, required): level of the children, one of the scope
  'child_levels' (e.g. 30 'provincia' for España). For the Senado, 'circunscripciones' returns
  every Senate constituency (provinces and islands); it is only offered on España.
- params.data_source ('auto' default | 'pro' | 'def').
- params.limit (1-1000, default 200).

WHAT IT RETURNS:
- territories: per child: scope_id, code, name, 'count_started', 'winner_basis' ('official'
  winner marked by the website, 'inferred_leader' computed from seats then votes, 'tie' or
  'not_started'), 'winner' (code, acronym, name, color, votes, votes_pct, seats; null while
  not started or tied), 'official_winner', 'inferred_leader', 'winner_seats',
  'seats_at_stake', 'census_counted_pct', 'turnout_pct' and the reported ties.
- tally: territories won and seats per candidacy, most territories first (ties excluded).
- count_started, total, truncated, next_step and source.

OPERATING NOTES:
- Before phase 2 it returns no territories and explains why: winners do not exist until
  votes are counted. Never infer winners from turnout.
- Seats in 'tally' are the seats won by each territory's winner only, not each party's total:
  use 'elecciones29n_get_scope_results' on the parent scope for national seat totals.

Inputs: params (required). Returns: Winning party of every child territory.

elecciones29n_list_partiesList 29N candidaciesA
Read-onlyIdempotent
Use this tool to list the candidacies (parties and coalitions) of the 29N call with their
official name, acronym and color, or to resolve how a party appears in the results.

WHEN TO USE IT:
When the user asks which parties run, or uses a name/acronym you need to match with the
'code' or 'acronym' of the results.

INPUT PARAMETERS (What it receives):
- params.chamber ('congreso' default | 'senado'): candidacies differ between chambers.
- params.query (optional str): words matched against name and acronym, ignoring accents and
  case (e.g. 'psoe', 'sumar', 'compromis').

WHAT IT RETURNS:
- parties: code, acronym, name, color and group (agrupación) of each candidacy.
- total, call ('11-26'), next_step and source.

OPERATING NOTES:
- Candidacies that run under different names in some territories share the same 'group'.
- This catalog does not contain votes: use 'elecciones29n_get_scope_results' for results.

Inputs: params (required). Returns: Candidacies of the 29N call.

elecciones29n_search_scopesSearch 29N territoriesA
Read-onlyIdempotent
Use this tool to find the territory (scope) the user asks about: the whole country (España),
an autonomous community, a province, an island, a municipality, a municipal district or a
polling place. Every other results tool needs the 'scope_id' it returns.

WHEN TO USE IT:
After 'elecciones29n_get_status', whenever the user names a place, and to disambiguate
homonyms (e.g. Madrid the community, the province and the city).

INPUT PARAMETERS (What it receives):
- params.queries (list[str], 1-15 terms): names or official territory codes, searched in ONE call. Include
  alternative spellings and official names (e.g. ['Alicante', 'Alacant'], ['Gerona', 'Girona']).
  Matching ignores accents, case, articles and word order. Numeric terms match official territory codes.
- params.chamber ('congreso' default | 'senado'): the scope tree of that chamber.
- params.level (optional, number or name): 1 nacional, 20 comunidad, 30 provincia, 70 isla,
  90 municipio, 100 distrito, 110 local.
- params.limit (1-100, default 20).

WHAT IT RETURNS:
- scopes: matches ordered by exactness and level. Each has 'scope_id' (pass it to the other
  tools), 'code' (official territory code), 'name', 'level'/'level_label', 'parents' (enclosing territories
  from the country down), 'child_levels' (levels accepted as 'children_level' or winners map
  'level'), 'is_constituency' (electoral constituency of the chamber), 'matched_queries' and
  'official_url'.
- total_matches / truncated: refine the terms or add 'level' when truncated.
- next_step and source.

OPERATING NOTES:
- Read 'parents' to pick the right homonym; ask the user if it is still ambiguous.
- Polling places (level 110 'local') feed 'elecciones29n_get_polling_stations'.
- Never build a scope_id yourself.

Inputs: params (required). Returns: Territories matching the search terms.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: status, scope search, scope results, winners map, party catalog, polling station listing, and tally sheet retrieval. The descriptions explicitly sequence the workflow and state what each tool does not cover, reducing misselection. Overlap is minimal and handled by cross-references rather than duplicated functionality.

    Naming Consistency5/5

    All tools use the same `elecciones29n_` prefix followed by a readable verb_noun pattern in snake_case, such as `get_status`, `search_scopes`, `get_scope_results`, and `list_parties`. The convention is predictable throughout, with no mixed casing or inconsistent verb styles.

    Tool Count5/5

    Seven tools is well scoped for an election-results server: status, territory discovery, results, winners, parties, polling stations, and tally sheets each earn their place. There is no obvious redundancy or missing bridge tool that would justify adding or removing one.

    Completeness4/5

    The surface covers the core 29N lifecycle from publication status through territory search, results, winners, parties, polling places, and tally sheets. Minor gaps exist, such as tally-sheet file access depending on a separate MCP resource read and some endpoints being inferred rather than live-validated, but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      MCP server for querying Spanish government open data APIs including grants, legislation, company registry, statistics, and open data catalog. Enables LLMs to access Spanish public information on-the-fly.
      26
      5
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      MCP server for querying Peruvian electoral data (ONPE) including mesa results, candidate votes, and regional statistics. Enables natural language queries about the 2026 presidential election with local SQLite cache and live API fallback.
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables querying official partial results from Brazil's 2026 elections directly from TSE data as MCP tools, covering national, state, and municipal races by office with turnout and candidate vote counts. Responses are normalized, cached, and include the TSE update timestamp and percentage of votes counted.
      2
      4
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to answer Brazilian voters' pre-election questions from TSE open data, including comparing candidates, finding polling places, checking election dates and voting hours, and retrieving candidate details through MCP tools without personal registration data.
      7
      MIT