turkiye-secim-mcp
turkiye-secim-mcp
uvx turkiye-secim-mcpTürkçe
Türkiye seçim sonuçlarını, YSK Açık Veri Portalı'ndan, bir yapay zekâ asistanına (Claude, Cursor vb.) doğrudan sorulabilir hale getiren MCP sunucusu. "2018 ile 2023 arasında Hatay'da CHP'nin oyu ilçe ilçe nasıl değişti?" gibi soruları cevaplar; yorum yapmaz, yalnız YSK sayılarını ve farkları aktarır.
Veri YSK'nındır. Bu paket veri içermez. Sorduğunuz kısım, sizin makinenizin önbellek dizinine YSK'nın kendi sunucusundan indirilir (
TURKIYE_SECIM_CACHE_DIRile değiştirilebilir). Veri depoda ve pakette yayımlanmaz; yalnız testlerde küçük kesitler vardır. Ayrıntı: VERI-LISANSI.md.
Kapsam (16 seçim):
Tür | Seçimler |
Milletvekili genel seçimi | 2011, 7 Haziran 2015, 1 Kasım 2015, 2018, 2023 |
Cumhurbaşkanı seçimi | 2014, 2018, 2023 (1. ve 2. tur) |
Halkoylaması (EVET/HAYIR) | 12 Eylül 2010, 16 Nisan 2017 |
Yerel: büyükşehir belediye başkanlığı | 31 Mart 2019, 31 Mart 2024, 23 Haziran 2019 İstanbul yenileme (ayrı seçim) |
Yerel: belediye başkanlığı (il merkezi, ilçe ve belde belediyeleri) | 31 Mart 2019, 31 Mart 2024 |
Düzey: Türkiye / il / ilçe. Belediye meclisi, il genel meclisi, muhtarlık, 2009/2014 yerel seçimleri ve sandık düzeyi bu sürümde yoktur.
Örnek sorular
"2018 ile 2023 arasında Hatay'da CHP'nin oy oranı ilçe ilçe nasıl değişti? En çok artan 5 ilçe hangisi?"
"2017 halkoylamasında Evet oyunun oranı en yüksek 10 ilçe hangisi? 2010'a göre Hatay'da Evet kaç puan değişti?"
"İstanbul büyükşehir seçiminde CHP'nin oyu 31 Mart 2019 ile 23 Haziran 2019 arasında kaç oy ve kaç puan değişti?"
"2024 belediye başkanlığı seçimlerinde Türkiye genelinde parti oyları nasıl dağıldı?"
"2019 ile 2024 arasında Ankara'nın ilçelerinde CHP'nin oyu nasıl değişti?"
"2023 milletvekili seçiminde Türkiye genelinde katılımı en düşük 10 ilçe hangisi?"
"2015 Haziran ile Kasım arasında AK Parti'nin Türkiye geneli oy oranı kaç puan değişti?"
"Bu verilerin kaynağı ve lisansı nedir, sayılar resmî sonuçla ne kadar tutuyor?" (
get_sourcescevaplar)
Kurulum
Python ≥ 3.11 gerekir; uvx uygun Python'u kendisi bulur. Tek satır: uvx turkiye-secim-mcp.
Claude Code
claude mcp add turkiye-secim -- uvx turkiye-secim-mcpClaude Desktop (claude_desktop_config.json) ve çoğu MCP istemcisi (Cursor, Windsurf, VS Code ...)
{
"mcpServers": {
"turkiye-secim": { "command": "uvx", "args": ["turkiye-secim-mcp"] }
}
}Kaynaktan çalıştırmak ve test etmek için:
git clone https://github.com/KemalG-u/turkiye-secim-mcp
cd turkiye-secim-mcp
uv venv .venv
uv pip install -e ".[dev]"
.venv/bin/python -m pytest # ağsız testler (Windows: .venv\Scripts\python.exe)İlk kullanım: tek seferlik hazırlık
İl düzeyindeki sorular (Türkiye ve il sonuçları, iki seçimin il farkı) hemen çalışır: birkaç küçük istekle gelir. Türkiye geneli ilçe soruları (ilçe sıralaması, ilçe araması, ilçe tablosu) için seçimin ilçe verisi bir kerede indirilir: seçim başına yaklaşık 81 küçük istek (büyükşehir başkanlığında 30), YSK'ya nazik davranıldığı için yaklaşık 2 dakika. Bundan sonra her sorgu birkaç saniyede biter.
uvx turkiye-secim-mcp --hazirla 2023-05-14-mv 2024-03-31-bld # seçilen seçimler
uvx turkiye-secim-mcp --hazirla # hepsi (16 seçim, ~25 dk)
uvx turkiye-secim-mcp --durum # hangisi hazırHazırlık ilerleme mesajı yazar, kesilirse kaldığı yerden devam eder. Hazırlık yapılmadan ilçe sorusu sorulursa araç ne olduğunu ve ne kadar süreceğini sade söyler; asistan prepare_data aracıyla indirmeyi kendisi de yapabilir (her çağrı en çok 45 sn, bitene dek yinelenir).
Önemli: sayılar HAM'dır, resmî sonuç yerine geçmez
Araçlar YSK Açık Veri API'sinin sandık toplamlarını ham okur ve her yanıtta data_label: "ham" ile kaynak, indirme tarihi ve uyarılar verir. Resmî sonuç, YSK'nın kesin sonuç kararı ve Resmî Gazete'de ilan edilendir. Her seçimin resmî kaynağı ve API ile farkı get_sources çıktısındadır. Resmî metinle karşılaştırılan başlıca farklar:
Seçim | API ↔ resmî ilan |
2018, 2023 milletvekili | İttifak işaretli oylar partilere dağıtılmaz (ayrı listelenir); parti oyları ilan edilenden küçük olabilir (Hatay 2023: AK Parti ham 286.568, YSK il PDF'inde 290.055). 2018 geçerli oyda 910 oy fark. |
2018 cumhurbaşkanı | Yurt içi toplamlar ilanla birebir; Türkiye toplamı yurt dışı kaleminde ilandan 682 oy küçük (Erdoğan: ilan 26.330.823, API 26.330.141). |
2010 halkoylaması | Yurt içi satırı birebir; yurt dışı/gümrük kalemi ilandakinden 36.040 geçerli oy küçük, Türkiye toplamı ilandan küçük. |
2017 halkoylaması | Birebir (EVET 25.157.463, HAYIR 23.779.141). |
2019 büyükşehir | İstanbul'un 31 Mart sonucu YSK tarafından iptal edildi, resmî ilan İstanbul'u içermez; API toplamından İstanbul çıkarılınca ilanla birebir. İstanbul'un geçerli sonucu 23 Haziran yenilemesidir (YSK ekiyle birebir). |
2019 ve 2024 belediye başkanlığı | API toplamı ilandan fazladır; fark, ilanda sayılmayan iptal edilmiş belediye seçimlerinin oylarına birebir eşittir (2019: 29.544 oy, 4 belediye; 2024: 45.725 oy, 7 belediye). |
2024 büyükşehir | Geçerli oy ve parti oyları ilanla birebir. |
Kayıtlı seçmen sayısı API'de ilandan biraz farklı olabilir; Türkiye düzeyinde kayıtlı seçmen ve katılım yalnız yurt içi sandıkları kapsar. 2014 ve Kasım 2015 için Resmî Gazete metni açılamadı, sayılar basın aktarımlarıyla teyit edildi (get_sources bunu yazar).
Parti adları seçimler arasında çoğunlukla aynı kısaltmayla eşleşir. Adı değişen ya da başka listeden girenler için yalnız kaynaklı küçük bir tablo vardır (şimdilik: HDP 2015/2018, 2023'te Yeşil Sol Parti listesinden girdi; oylar birleştirilmez, not düşülür).
Yerel seçimlerde düzeyler: "ilçe" = belediye
Yerel seçim sonuçları parti sütunlarıdır, aday adı değildir; ittifak sütunu yoktur. Ortak aday varsa oyu adayı çıkaran partinin sütununda görünür. Düzeyler seçim türüne göre şu anlama gelir:
Düzey | Büyükşehir belediye başkanlığı | Belediye başkanlığı |
| 30 büyükşehir ilinin toplamı (tüm Türkiye değil) | Bütün belediye başkanlığı yarışlarının oy toplamı |
| O ilin büyükşehir başkanlığı oyları | O ildeki bütün belediye yarışlarının oy toplamı (tek kişinin oyu değil) |
| Aynı büyükşehir yarışının ilçe dökümü | İlçe merkez belediyesi ve her belde belediyesi ayrı satır; belde satırı |
23 Haziran 2019 İstanbul yenilemesi yalnız İstanbul'da yapıldığı için turkiye düzeyi İstanbul'dur ve 31 Mart ile Türkiye toplamı olarak karşılaştırılmaz (province="İstanbul" verin). Belde satırları yalnız tek seçimde bulunabilir; seçimler arası karşılaştırmada eşleşmeyenler unmatched altında sayılır.
Araçlar
Araç | Ne yapar |
| Kullanılabilir seçimler, kimlikleri ( |
| İl/ilçe arama; Türkçe karakter ve büyük-küçük harf duyarsız ("hatay", "ISKENDERUN", "urfa"); |
| Türkiye / il / ilçe sonucu: kayıtlı seçmen, katılım, geçerli/geçersiz oy, parti, aday ya da EVET/HAYIR oyları |
| Katılım ve sıralama (il, bir ilin ilçeleri ya da Türkiye geneli ilçeler) |
| İki seçim arası fark: oy oranı puan farkı, oy farkı, katılım farkı; Türkiye / il / ilçe ya da il/ilçe tablosu |
| İlçe sıralaması: parti oy oranı, oy sayısı, katılım ya da başka seçime göre değişim; Türkiye geneli veya il içi |
| Her verinin kaynağı, indirme tarihi, resmî kaynak, ham/resmî farkı, lisans notu, parti soy zinciri |
| Bir seçimin ilçe verisini bu bilgisayara indirir (tek seferlik), durumu gösterir |
Sınırlar
Belediye meclisi, il genel meclisi, muhtarlık, sandık düzeyi ve ittifak oylarının dağıtılmış hali yoktur. İlçe kimlikleri seçimler arası sabit değildir: ilçeler (il, ilçe adı) ile eşleştirilir, adı ya da sınırı değişenler eşleşmez ve yanıtta sayılır. 2011 milletvekili seçiminde bağımsız oyları tek kalemdir. Bu araç yorum üretmez.
Veri ve nezaket
YSK'nın verisi YSK'nındır; açık bir lisans metni bulunamadığından veri bu depoda yayımlanmaz, kod MIT lisanslıdır. YSK'ya nazik davranılır: istekler arasında en az 0,5 sn, yerel önbellek, 15 sn zaman aşımı, açık bir kullanıcı kimliği (turkiye-secim-mcp/<sürüm>), yalnız acikveri.ysk.gov.tr/api/. sonuc.ysk.gov.tr (CAPTCHA'lı) kullanılmaz.
Related MCP server: bundeswahlleiter-mcp
English
An MCP server that lets an AI assistant (Claude, Cursor, ...) query Turkish election results from the YSK (Supreme Election Council) Open Data Portal, including cross-election comparison and district rankings. It reports numbers and differences; it does not interpret them.
The data belongs to YSK. This package bundles no data. What you query is downloaded from YSK into your own user cache directory (override with
TURKIYE_SECIM_CACHE_DIR). See VERI-LISANSI.md.
Coverage (16 elections): parliamentary 2011, June 2015, November 2015, 2018, 2023; presidential 2014, 2018, 2023 (rounds 1 and 2); constitutional referendums 12 Sep 2010 and 16 Apr 2017 (EVET/HAYIR); local elections 31 Mar 2019 and 31 Mar 2024 as two separate races each, metropolitan mayor (buyuksehir_belediye_baskani) and mayor (belediye_baskani), plus the 23 Jun 2019 Istanbul re-run as its own election. Levels: Turkey / province (il) / district (ilce). Not included: municipal councils, provincial councils, mukhtar elections, 2009/2014 local elections, ballot-box level.
Example questions
"How did CHP's vote share change district by district in Hatay between 2018 and 2023? Which 5 districts rose most?"
"Which 10 districts had the highest EVET share in the 2017 referendum? How did EVET change in Hatay versus 2010?"
"How did CHP's Istanbul metropolitan vote change between 31 March and 23 June 2019?"
"How were party votes distributed across Turkey in the 2024 mayor races?"
"How did CHP's vote change across Ankara's districts between 2019 and 2024?"
"Which 10 districts had the lowest turnout in the 2023 parliamentary election?"
"By how many points did AK Parti's national share change between June and November 2015?"
"What are the sources and licence of this data, and how close are the numbers to the official results?" (answered by
get_sources)
Install
Python >= 3.11 (uvx finds a suitable interpreter by itself). One line: uvx turkiye-secim-mcp.
Claude Code: claude mcp add turkiye-secim -- uvx turkiye-secim-mcp.
Claude Desktop (claude_desktop_config.json) and most MCP clients: use the JSON block in the Turkish section ("command": "uvx", "args": ["turkiye-secim-mcp"]).
From source: git clone https://github.com/KemalG-u/turkiye-secim-mcp, then uv venv .venv && uv pip install -e ".[dev]" and run pytest (offline tests).
Province-level questions work immediately. Turkey-wide district questions need a one-time download per election (about 81 small requests, 30 for metropolitan mayor races, roughly 2 minutes, polite to YSK): uvx turkiye-secim-mcp --hazirla [election-id ...] (all 16 elections if none given, about 25 minutes; --durum shows status). Without it the tools explain what is missing and how long it takes, and the prepare_data tool can do the download from inside the assistant.
Important: figures are RAW
Tools read the YSK Open Data API's ballot-box totals as-is and label every response data_label: "ham" (raw) with source, download date and caveats. The official result is the one YSK declares in its final-result decision and the Official Gazette; get_sources gives the official reference of every election and how the API differs from it. Findings so far, from comparing with the official texts:
2018 and 2023 parliamentary: alliance-marked votes are not distributed to parties, so party totals can be lower than the declared ones (Hatay 2023: AK Parti raw 286,568 vs. 290,055 declared).
2017 referendum: exact match. 2010 referendum: domestic row exact; the abroad/customs item is 36,040 valid votes below the declaration.
2019 metropolitan: Istanbul's 31 March result was annulled by YSK and is not in the official total; removing it from the API total gives an exact match. The valid Istanbul result is the 23 June re-run (exact match with YSK's annex). 2024 metropolitan: exact match.
2019 and 2024 mayor races: the API total is higher than the declared one by exactly the votes of the annulled municipal races that the declaration leaves out (2019: 29,544 votes, 4 municipalities; 2024: 45,725 votes, 7 municipalities).
Party names are matched by name across elections; the only lineage entry is a sourced note (HDP 2015/2018 vs. Yesil Sol Parti list in 2023) and votes are never merged.
Local elections: what the levels mean
Local results are party columns, not candidates; there is no alliance column, and a joint candidate's votes appear under the party that fielded the candidate. In the mayor race (belediye_baskani) turkiye and il are sums over many separate races (not one person's vote), and the ilce level is the municipality: each district-centre municipality and each belde municipality is its own row, belde rows named DISTRICT - BELDE (e.g. Besni - Kesmetepe). In the metropolitan race (buyuksehir_belediye_baskani) turkiye is the sum of the 30 metropolitan provinces, il is that province's race, and ilce is its district breakdown. The 23 June 2019 Istanbul re-run covers Istanbul only, so it is not compared at Turkey level (use province="İstanbul").
Tools
list_elections, search_place, get_results, get_turnout, compare_elections, rank_districts, get_sources, prepare_data (see the table in the Turkish section).
Limits
No municipal/provincial councils, mukhtar elections, ballot-box level or distributed alliance votes. District ids are not stable across elections, so districts are matched by (province, name); unmatched ones are counted. The server reports numbers; it does not interpret them.
Politeness and licence
The data belongs to YSK; no explicit licence text was found, so the data is not redistributed here. The code is MIT. Requests to YSK: at least 0.5 s apart, local cache, 15 s timeout, an identifying user agent (turkiye-secim-mcp/<version>), acikveri.ysk.gov.tr/api/ only; sonuc.ysk.gov.tr (CAPTCHA) is never used.
Available Tools
8 toolscompare_electionsCompare ElectionsA
Compare two elections (A = earlier, B = later): change in vote share (percentage POINTS, B minus A), votes and turnout. With no province/district/level it compares Turkey as a whole (all parties). With province it compares that province; with province+district one district. With level='il' (or level='ilce', optionally with province) it returns a table of units sorted by the change in 'party' (or by turnout change if no party is given), biggest rise first (order='desc'). Party and candidate names are matched by name across elections; a documented lineage note is attached when a party did not run under its own name (e.g. HDP 2018 vs Yesil Sol Parti 2023); votes are never merged. Turkey-wide district tables need the one-time district download for both elections (prepare_data). RAW YSK API figures.
Inputs: election_a (required), election_b (required), level, order, +4 more. Returns: object
get_resultsGet ResultsA
Vote totals for an election at Turkey, province or district level (omit province for Turkey; pass province, plus district for a district). 'election' is an id from list_elections, e.g. '2023-05-14-mv'. Returns RAW YSK API figures (data_label='ham'): registered voters, turnout, valid and invalid votes, and per-party (or per-candidate; referendums: 'choices' EVET/HAYIR) votes with percent of valid votes. Alliance votes are listed separately and never distributed; vote_basis='alliance_distributed' is not available. In local elections 'district' selects a municipality (district-centre or belde, e.g. 'Besni' or 'Besni - Kesmetepe'); a province result is the sum of all mayor races there (belediye_baskani) or the metropolitan mayor race (buyuksehir_belediye_baskani).
Inputs: election (required), office, district, province, +1 more. Returns: object
get_sourcesGet SourcesB
Provenance of every dataset: data owner (YSK), API base, per election the endpoints used, download dates, official reference (YSK decision / Official Gazette), what 'ham' (raw) means versus official results, the licence note, the party lineage table with its sources, and fetch politeness settings.
Inputs: no named parameters. Returns: object
get_turnoutGet TurnoutA
Voter turnout (registered voters, voters who voted, turnout percent) ranked by turnout. level='il' ranks provinces (or returns one province if 'province' is given); level='ilce' returns the districts of the given province, or all districts of Turkey when province is omitted (that needs the one-time district download, see prepare_data). RAW YSK API figures. scope_total holds the total for the whole scope.
Inputs: election (required), level, order, top_n, +1 more. Returns: object
list_electionsList ElectionsA
List the elections available in this server with ids, dates, kind and supported levels (turkiye, il, ilce): parliamentary 2011, 2015 June, 2015 November, 2018, 2023; presidential 2014, 2018, 2023 (rounds 1 and 2); referendums 2010 and 2017 (kind 'halkoylamasi', EVET/HAYIR); local 2019 and 2024: 'buyuksehir_belediye_baskani' (metropolitan mayor, 30 provinces; also the 23 June 2019 Istanbul re-run) and 'belediye_baskani' (all other mayor races). Local elections carry a 'note' explaining what 'il' and 'ilce' (= municipality) mean for them; read it.
Inputs: kind, year_to, year_from. Returns: object
prepare_dataPrepare DataA
Download the district-level data of an election to this computer (one-time, ~81 small requests, about 1.5 minutes; YSK is queried politely, at most 2 requests per second). Call with election=None to see the status of all elections. Each call downloads for at most max_seconds (default 45) and can be repeated; progress is kept. 'complete': true means district queries for that election are fast.
Inputs: election, max_seconds. Returns: object
rank_districtsRank DistrictsA
Rank districts (ilce) by a party's vote share ('pct'), votes ('votes'), turnout ('turnout', no party needed) or the change in vote share versus another election ('change_vs', needs compare_to; change = election minus compare_to, percentage points). Within one province (province given) or across Turkey (province omitted; needs the one-time district download for the election, see prepare_data). Districts are matched across elections by (province, district name); unmatched ones are counted in 'unmatched'. RAW YSK API figures.
Inputs: election (required), order, party, top_n, +3 more. Returns: object
search_placeSearch PlaceA
Find a province (il) or district (ilce) by name. Case, Turkish characters and accents are ignored ('hatay', 'ISKENDERUN', 'urfa' all work). Province search always works; district search needs the one-time district download (see prepare_data) and says so if it is missing. Pass 'election' (e.g. a local election id) to search that election's own units: in local elections these are municipalities, including belde municipalities named 'DISTRICT - BELDE'.
Inputs: query (required), level, limit, election. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a reasonably distinct role, but there is some overlap between get_results, get_turnout, compare_elections and rank_districts — turnout and district rankings can partly be derived from get_results. Descriptions do a good job disambiguating by spelling out parameters and levels, though an agent may still hesitate between rank_districts(change_vs) and compare_elections(level='ilce').
All eight tools follow a consistent snake_case verb_noun pattern: list_elections, search_place, get_results, get_sources, get_turnout, compare_elections, rank_districts, prepare_data. The verbs (list/get/search/compare/rank/prepare) map sensibly onto the action performed.
Eight tools is well within the ideal 3-15 range and each one earns its place: discovery, place lookup, results, turnout, comparison, ranking, provenance and a data-preparation step. No tool looks redundant or filler.
The surface covers the full analysis lifecycle: list elections, find places, fetch raw results, turnout, compare, rank, verify provenance and pre-download district data. Minor gaps exist — no tool to list parties/candidates or party lineage directly, and province-level ranking (as opposed to district ranking) is not available — but agents can work around these via get_results and get_sources.
Maintenance
Related MCP Connectors
Turkey data API for AI agents: 40 tools + search/call for 230+ endpoints. Addresses (provinces, districts, postal codes, boundaries), validation (IBAN, tax ID/VKN, TCKN, phone, barcode), tax and salary calculators, Official Gazette, exchange rates, gold, crypto, economic indicators, prayer times, holidays and business days, weather, air quality, earthquakes, dam levels, fuel prices, EV charging, power outages, tolls, pharmacies on duty, football standings. Turkish JSON, free plan.
Countries, admin units, Turkey's official mahalle list, boundaries, timezones, postal codes, phones
US & Canada election maps: precincts, ZIP codes, 2026 districts, ridings. GeoJSON + point lookup.
Türkiye public holidays (incl. half-day eves, Diyanet dates) and business-day math, 2022–2035.
Related MCP Servers
- AlicenseAqualityCmaintenanceProvides unified access to Turkish official data from TÜİK (statistics via SDMX) and TCMB EVDS (financial series), enabling search, query, and tidy CSV export with full frequency, aggregation, and formula support.162MIT
- AlicenseAqualityBmaintenanceProvides read-only access to official Bundestag election results for 2017, 2021, and 2025, covering national and party results, constituency outcomes, and turnout.6PolyForm Noncommercial 1.0.0
- AlicenseBqualityAmaintenanceEnables AI assistants and TypeScript applications to retrieve live, source-attributed Turkish public data across finance, earthquakes, official publications, weather, energy, health, city services, geography, and calendars/prayer times. It exposes this data through MCP tools and a typed library, with source and timestamp included in each response.291MIT
- AlicenseNot gradedqualityCmaintenanceEnables querying Danish national election and referendum results from 2009 onward, including party votes, percentages, seats, turnout, invalid votes, and historical party trends down to polling-station areas.MIT