Racemodel

io.github.CloudCorpRecords由 GitHub 帳號 CloudCorpRecords 發布v0.1.0更新於 Nov 4, 2026

Model and map U.S. election races: scenarios, swing, turnout and precinct-level roll-ups.

概覽

AI 產生的概覽

本機 stdio 橋接,連接託管的美國選舉建模服務,讓助理建立選情情境、套用搖擺並讀取票數、翻轉席次、地圖與投票所層級彙總。

可以做什麼
  • 解析地點、地址、候選人與選區選舉,並瀏覽選舉行事曆
  • 建立與管理情境和模擬,設定候選人名單、得票率、投票率與選區範圍,提交或比較版本
  • 套用統一或依條件篩選的搖擺,讀取票數統計、翻轉席次、模擬比較與投票所層級彙總,含初選
  • 讀取、設定與渲染地圖檢視和圖表,新增或列出地圖留言
  • 讀取投票率、選民登記、歷史資料、提前投票與投票所結果,以及郡官員與經濟概況
  • 查看計費與連線狀態、入門指引、說明與目錄
適用情境
適合讓助理探索美國選舉情境與假設分析(搖擺、投票率和候選人得票率變化),並在對話中直接取得投票率、選民登記與投票所層級參考資料。
執行需求
透過 npx 或 Docker 映像在本機執行,需要能連線至上游託管服務的網路。選用 ELECTIONSMCP_MCP_URL 可覆寫上游位址;選用 ELECTIONSMCP_API_KEY 會以 x-electionsmcp-key 標頭送出。預設不需憑證。
安裝前請注意
工具呼叫會轉送至第三方託管服務,情境狀態也存放在該服務上,因此建立情境或設定得票率等寫入操作會變更遠端資料。若設定了 API 金鑰,它會在每次上游請求中傳輸。計費狀態僅供讀取,未提供付款類工具。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Racemodel,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

racemodel

racemodel is a thin local bridge to the ElectionsMCP hosted MCP server, a modelling service for U.S. election races. Upstream, a user can resolve places and candidates, build a scenario, set candidate shares and turnout assumptions, apply a swing, and then read the race back as tallies, flipped seats, maps, charts and precinct-level roll-ups — including separate handling for primary races.

The bridge holds no election data and computes no forecast of its own. It serves the upstream server's tool list locally — exactly as captured from the live endpoint — and forwards each tool call upstream, returning the result untouched. Scenario and simulation state lives upstream, so writes such as creating a scenario or setting shares are the service's own modelling operations, forwarded like every other call. billing_status is a read; there is no payment, donation or purchase tool in the surface.

Tools

Geography, candidates and contests:

  • resolve_geography — turn a place name or shorthand into a canonical geo id (query, required).
  • resolve_candidate — find who holds or runs for a seat from a person's name (name, required).
  • search_candidates — browse the candidate registry by filters without supplying a name.
  • lookup_address — resolve an address (address, required) to its geography.
  • list_contests — list contests for a geography (geo_id, required).
  • election_calendar — the election calendar. No required arguments.

Scenarios and simulations:

  • create_scenario — start a new scenario (name, required).
  • list_scenarios, get_scenario (scenario_id), commit_version (scenario_id), and diff_versions (scenario_id, version_a, version_b) — manage and compare saved scenario versions.
  • set_performance — set shares for a geography in a scenario (scenario_id, geo_id, shares).
  • target_precincts — precinct targeting for a scenario (scenario_id, required).
  • set_candidates — set the candidate list for a simulation (simulation_id, level, candidates).
  • set_turnout — set turnout assumptions (simulation_id, required).
  • set_race_scope — set a simulation's race scope (simulation_id, required).
  • list_simulations and get_simulation (simulation_id, required) — enumerate and read simulations.
  • share_simulation — share a simulation (simulation_id, required).

Views, swings and roll-ups:

  • get_view, render_view and set_view — read, render or set a simulation's view (each takes simulation_id).
  • render_chart — render a chart (type, required).
  • add_map_comment (simulation_id, body) and list_map_comments (simulation_id) — annotate and read back a simulation's map.
  • apply_uniform_swing — apply a uniform swing in percentage points (simulation_id, level, swing_pp).
  • apply_swing_to_query — apply a swing scoped by a query (simulation_id, state, filter).
  • get_tally — the tally at a level (simulation_id, level).
  • list_flipped — seats that flipped at a level (simulation_id, level).
  • compare_simulations — compare two simulations at a level (simulation_id_a, simulation_id_b, level).
  • roll_up_race — roll a simulation up to the race level (simulation_id, required).

Turnout, returns and reference data:

  • get_early_voting_turnout — early-voting turnout for a state (state, required).
  • get_county_voter_turnout_and_registration, get_state_historical_turnout, get_live_early_vote_returns and get_precinct_election_returns — turnout, registration, historical and returns reads. No required arguments.
  • get_county_officials and get_county_economic_and_wealth_profile — county reference profiles. No required arguments.
  • billing_status and connection_status — account and connection reads. No required arguments.
  • get_campaign_onboarding, help and get_catalog — onboarding, help and catalog reads. No required arguments.

Primaries:

  • list_primary_calendar — primary calendar for a party (party, required).
  • set_primary_shares — set primary shares (simulation_id, party).
  • roll_up_primary — roll a primary up (simulation_id, party).
  • primary_batch_edit — batch-edit a primary (simulation_id, edits).

Meta:

  • call_tool — invoke another tool by name through the upstream (name, required).

Configuration

  • ELECTIONSMCP_MCP_URL (optional) — override the upstream endpoint. Defaults to https://www.electionsmcp.com/mcp. (The override hook is this rebuild's own labelled reconstruction.)
  • ELECTIONSMCP_API_KEY (optional) — when set, its value is sent on every upstream request under the header name the registry record pins for this remote, x-electionsmcp-key. When it is unset, no auth header is sent. (This forwarding is a labelled reconstruction; the original capture was keyless.)

Forwarding mechanics

On the first tool call the client opens a streamable HTTP session with the upstream: a JSON-RPC initialize request (protocolVersion 2025-03-26, clientInfo name racemodel), then a notifications/initialized notification, then the tools/call request carrying the caller's arguments unchanged. When the upstream answers initialize with an Mcp-Session-Id header, that value rides on every later request of the session, which is reused for the life of the process. Replies may arrive as plain JSON or as server-sent events; both are read.

Successful upstream results pass through verbatim, including any isError flag the upstream sets. Failures — a JSON-RPC error, a non-2xx status, an unreadable response, or a request that cannot be completed — come back as an isError result whose text starts with racemodel error: (this rendering is this rebuild's own labelled reconstruction).

CLI

Each tool is also a subcommand taking one JSON argument string (omit it for tools that take none):

bash
npx @reneturcios/racemodel resolve_geography '{"query":"CA-03"}'npx @reneturcios/racemodel create_scenario '{"name":"Baseline 2026"}'npx @reneturcios/racemodel get_catalognpx @reneturcios/racemodel --version

Exit codes: 0 on success, 1 on an isError result, 2 on a usage error.

MCP server

bash
npx -y @reneturcios/racemodel mcp

MCP client config:

json
{  "mcpServers": {    "racemodel": {      "command": "npx",      "args": ["-y", "@reneturcios/racemodel", "mcp"]    }  }}

Docker

bash
docker run -i ghcr.io/cloudcorprecords/racemodeldocker run --rm ghcr.io/cloudcorprecords/racemodel --version

The container's default command is mcp, so the first form is a stdio MCP server; any other arguments reach the CLI normally.

Development

bash
npm installnpm run buildnpm testnpm run dev

The test suite runs entirely against a stubbed JSON-RPC upstream — no live network calls.

License

MIT — see LICENSE.

來源:README.md,提交 f2ce3b9

工具

48

resolve_geography

Turn a place name or shorthand into its canonical geo_id — resolve natural-language or structured location input. Handles "CA-03"/"NC-4" (congressional districts), bare state names/abbreviations, "<County> County…

輸入參數yearquery必填workspace_scope

resolve_candidate

WHO holds or runs for WHAT — turn a candidate/officeholder name into their seat + next race. Given a name (full, last-name, or a registry alias — "Lauren Boebert", "Boebert"), returns the person(s) who match with their…

輸入參數name必填cyclelimitpartyofficeworkspace_scope

search_candidates

BROWSE the canonical candidate registry WITHOUT a name — the nameless companion to resolve_candidate (which requires a name). Filter the registry of canonical people by party, office, and/or a name substring:…

輸入參數qlimitpartyofficeworkspace_scope

lookup_address

Resolve a US street address, ZIP, state, or U.S. House district and show workspace campaigns covering the result. Street addresses return a geocoded point and containing districts, with a precinct when coverage exists.…

輸入參數address必填workspace_scopeinclude_officials

list_contests

Discover contests for a geography and election cycle. Filter general, primary (dem_primary/rep_primary), or all stages; count describes the returned top-level rows. National presidential primaries are discoverable in…

輸入參數cyclestagegeo_id必填workspace_scope

election_calendar

The election planning calendar. National form ({cycle}) returns federal contests, governors and by_state office lists; state form ({state,cycle}) returns a four-year horizon. Other statewide executive offices use the…

輸入參數cyclestateworkspace_scope

set_performance

Set a candidate's vote share, such as the Democratic candidate to 54%, in one specific county, district, state, or precinct (the general-election override). Routes a county/state/district geo_id to a feature override…

輸入參數levelgeo_id必填marginshares必填turnoutrebalancescenario_id必填total_votessimulation_idworkspace_scopeexpected_version

target_precincts

Return structured precinct model rows: precinct_id, name, county, county_fips, baseline_share, modeled_share, ballots_est, overridden, and gap_to_goal. The response does not include demographic columns or demographic…

輸入參數limitfiltergeo_idmarginoffsetcontextgoal_modetarget_pctscenario_id必填candidate_idrolloff_rateworkspace_scope

create_scenario

Create a new Scenario (a modeled path) — optionally inside a Race and seeded from a contest_id or an existing scenario (import_from). Seeds an immutable baseline version (v1). Returns scenario_id + version_id. (A…

輸入參數name必填tagsrace_idcontest_idbaseline_idcampaign_idimport_fromidempotency_keyworkspace_scopeboundary_versionexpected_campaign_revision

get_view

Read the exact map/view state the application renders for a canonical scenario: headline totals, selected geography, modeled feature colors, annotations, primary-calendar playhead, candidate roster, presence, and a…

輸入參數viewcyclegrainlevelstateversion_aversion_bversion_idcampaign_id_acampaign_id_bsimulation_id必填expected_hash_a另有 5 個

render_view

A headless server-rendered IMAGE of the map — the rendered view a viewer sees, as SVG or PNG, WITHOUT a browser (tk_0b6d3501 P2). For a scenario + level (president | senate | house | governor | the execs) it draws the…

輸入參數asofviewgrainlevelsharestatethemetitleformatgeo_idlayersregion另有 16 個

render_chart

share_comparison compares candidate shares for two saved versions of one model or two same-contest statewide general-election models. Returns canonical integer candidate votes, all-ballot shares, D-minus-R margins,…

輸入參數asoftype必填cyclelevelpartysharestatestylethemetitleclinchformat另有 17 個

set_view

Set the active scenario view and selected map context: race stage, calendar playhead, geography grain, result source, selected feature, camera, map theme, and rail. The same persisted view state and deep link are used…

輸入參數asofrailzoomcyclelevelstagestatelayerssourcecontestmap_grainmap_theme另有 5 個

get_scenario

A Scenario at its latest version (or a specified version_id): metadata (incl. latest_hash) + the version's top_line (margin / EC / viability) + its content hash/prev_hash. EM-119: pass a version_id (or…

輸入參數version_idscenario_id必填include_stateworkspace_scopeexpected_version_hash

commit_version

Save the scenario's current state as a new immutable, hash-stamped version in the append-only chain. Records a diff vs the parent version and the recomputed top_line, and returns a content `hash` (+ `prev_hash`…

輸入參數titlesummaryinsight_idsscenario_id必填include_diffannotation_idsworkspace_scope

list_scenarios

Page saved scenarios/simulations in this workspace by updated_at descending and scenario_id ascending, without version blobs. Returns scenario_id, name, level, cycle, contest_id, race_id, tags, durable_id, published…

輸入參數tagslimitoffsetworkspace_scope

diff_versions

Structured diff between two immutable versions. Raw before/after remain stored override patches (null means no saved override). Precinct cells also include effective_before/effective_after shares with their…

輸入參數limitoffsetversion_a必填version_b必填scenario_id必填workspace_scope

get_early_voting_turnout

Read early voting, absentee/mail, election-day, and provisional vote-method breakdowns alongside registered-voter, ballots-cast, and undervote/overvote turnout statistics by race and candidate from RoutPoint v2…

輸入參數state必填officedistrictsource_idcounty_fipsoffice_levelelection_dateelection_typeworkspace_scopeinclude_precincts

get_county_voter_turnout_and_registration

Read county voter registration, party registration (DEM/REP/UNA/Other), voting-age population, 2024/2022/2020/2026 ballots cast and turnout percentages, 2020-to-2024 partisan swing, and competitiveness tiers across…

輸入參數sorttierlimitstateoffsetcounty_fipsworkspace_scope

get_state_historical_turnout

Read 50-year statewide prior-cycle turnout and vote totals (1976 through 2026 across all 50 states and DC): ballots cast, registered voters, voting-age population, turnout percentage, DEM/REP vote shares, margin, and…

輸入參數yearlimitstateoffsetworkspace_scope

get_live_early_vote_returns

Read live 2026-11-03 General Election pre-election mail ballot requests, mail ballots returned, early in-person ballots, and ballot composition by voter registration party (DEM/REP/UNA/Other) from continuously…

輸入參數limitstateoffsetcounty_fipselection_dateworkspace_scopeinclude_precincts

get_precinct_election_returns

Read precinct-level election returns and normalized early-voting, absentee/mail, election-day, and provisional breakdowns across 87.7M precinct rows (linked to mapsmcp_precinct_id) from RoutPoint v2.

輸入參數yearlimitpartystateofficeoffsetdistrictcontest_idcounty_fipselection_idoffice_levelelection_date另有 3 個

get_county_officials

Read current local, county, municipal, judicial, and school-board officials (40,431 local officials; 97,231 total officials) by 5-digit county FIPS or state from RoutPoint v2.

輸入參數qfipslimitpartystateoffsetoffice_levelworkspace_scope

get_county_economic_and_wealth_profile

Read a county’s economic vitality dossier (Census 15-sector business patterns, establishments, employees, payroll, average annual wage, new SOS LLC/Corp formations, SEC Form D capital raises, Form 4/FEC major donors,…

輸入參數fipssortlimitstateoffsetworkspace_scope

billing_status

BILLING — your subscription state: {billing_enabled, logged_in, plan (personal|team|null), status, active, renews, can_save}. billing_enabled is false until the server is configured with Stripe; while it is false,…

輸入參數workspace_scope

connection_status

WHO AM I — how THIS session is authenticated and which workspace this request resolved to. Returns authentication fields plus workspace {workspace_id, role, selection_source}. Modern MCP clients select a workspace with…

輸入參數workspace_scope

set_candidates

Replace the entire candidate roster for a simulation+level in one call (add / edit / remove / reorder). Each candidate: {id?, name, party, color?, incumbent?}; ids auto-assigned if omitted. Use this to set the real…

輸入參數level必填candidates必填simulation_id必填workspace_scopeexpected_version

set_turnout

Set the turnout (mobilization) model. PRESIDENT (default, unchanged): each dial is a percentage-point boost toward toward_candidate_id in counties over an ACS threshold (college = >20% BA share, immig = >15%…

輸入參數clearimmiglevelsourcecollegegeo_idshiUnemplowHomecountieshighHomecriterionassumption另有 5 個

add_map_comment

Leave a Google-Docs-style COMMENT on the scenario map — a threaded, resolvable discussion anchored to a place. CAMPAIGN ISOLATION: when working inside a campaign, pass campaign_id; the scenario must be filed under it…

輸入參數latlngbody必填leveltitleobjectpayloadregionscategoryicon_typeparent_idfeature_id另有 10 個

list_map_comments

List one campaign's map comments on a scenario (oldest-first), each with its campaign_id, anchor, author, body, @mentions, parent_id, and resolved state. Pass campaign_id inside a campaign; only that exact campaign is…

輸入參數campaign_idcomment_idssimulation_id必填workspace_scopeinclude_resolved

apply_uniform_swing

Apply an incremental swing in points toward one candidate at the requested office. A saved race_scope restricts writes to that state or district and refuses a different office or unresolved geography. Unscoped and…

輸入參數as_oflevel必填swing_pp必填simulation_id必填decay_halflifeworkspace_scopedecay_start_datetoward_candidate_id

get_tally

Compute the current per-candidate tally for a simulation+level. For President: state-aggregated EVs. For others: feature counts. For level:"senate" the default is the 50-state per-candidate race scoreboard; pass…

輸入參數cyclelevel必填chambersimulation_id必填workspace_scope

list_simulations

List saved simulations in this workspace (id, name, level, cycle, mode, contest_id, last-modified; rows stamped with an identity also carry created_by/updated_by member user_ids). Optional filters narrow a large…

輸入參數qmodecyclelevellimitowneroffsetrace_idcontest_idupdated_sinceworkspace_scope

get_simulation

Read the canonical simulation/scenario state, including candidates, race scope, geography overrides, active version identity, provenance, and optional summary or selected dot-path fields.

輸入參數fieldssimulation_id必填workspace_scope

list_flipped

List baseline-to-model winner changes. Defaults to state for statewide offices, county for president, and district for house/state legislature. Explicit grain:county|precinct uses canonical integer local votes for a…

輸入參數grainlevel必填limitstateoffsetsimulation_id必填workspace_scope

compare_simulations

Compare two simulations. Without grain, returns the existing chamber/feature comparison. With grain:county|precinct and one state, compares exact saved canonical vote rows: margin(B)-margin(A), winners, flips, ballots…

輸入參數grainlevel必填limitstateformatoffsetversion_aversion_bcampaign_id_acampaign_id_bexpected_hash_aexpected_hash_b另有 3 個

share_simulation

Mint a public, read-only link to the exact canonical scenario/version. Authenticate for durable workspace ownership; revoke_share disables the link.

輸入參數sectionsttl_dayscampaign_idsimulation_id必填include_deltasinclude_impactworkspace_scope

roll_up_race

Roll up precincts to a race outcome under the current simulation. Sums baseline votes for all precincts inside the district boundary, applying overrides in precedence order: a per-precinct override wins, else…

輸入參數levelregiondistrict_idregion_groupsimulation_id必填workspace_scope

apply_swing_to_query

Apply a uniform swing or an explicit per-precinct weights vector to a filtered cohort in one atomic call. Weights select only their named IDs, support canonical statewide mechanisms, and optionally rescale a persuasion…

輸入參數mixmodelevelstate必填filter必填sourceweightsswing_ppassumptionmax_precinctssimulation_id必填workspace_scope另有 2 個

get_campaign_onboarding

CAMPAIGN ONBOARDING — guide a campaign manager or joining staff member through setup in their connected AI. Read one step or the complete guide: connection, campaign identity, team access, optional data imports, first…

輸入參數sectionworkspace_scope

help

Orient an AI client to campaign onboarding through get_campaign_onboarding, user-controlled election modeling, candidate and presidential-primary workflows, supported geography, scenario versions, contextual War Room…

輸入參數workspace_scope

get_catalog

DISCOVERY — browse workflow/category groups, search tool names and descriptions, or fetch one complete schema and AI guide with tool. No arguments returns a compact counted index of the authorized inventory. Core…

輸入參數toollimitquerycursorcategoryworkflowworkspace_scopeexpected_catalog_version

list_primary_calendar

Read the 2028 primary calendar with source dates, schedule certainty, modeled delegate coverage, missing jurisdictions, and threshold basis. New calendars include the six DNC-approved early dates; other unverified…

輸入參數party必填simulation_idworkspace_scope

set_primary_shares

Set a party's presidential-primary vote shares — one state, or MANY states in a single call. SINGLE STATE: pass `state` + `shares` (unchanged behavior; echoes the full running roll_up). BATCH: pass `states` = { "SC":…

輸入參數party必填statesharesstatessimulation_id必填include_rollupworkspace_scope

roll_up_primary

The running delegate count — OR, for a race-scoped downballot sim, that race's own share rollup. DOWNBALLOT (tk_2110d54c1d0871): when the scenario is race-scoped to a non-presidential office (set_race_scope…

輸入參數asofparty必填stateby_districtsimulation_id必填include_statesworkspace_scope

primary_batch_edit

ATOMIC batch-edit transaction for a PRIMARY scenario — validate, preview, apply, and roll back a whole SET of candidate / share / calendar edits as ONE transaction. Pass edits:[{op, ...}, …] where each entry carries…

輸入參數edits必填forcepartydry_runsimulation_id必填setup_evidenceworkspace_scopecheckpoint_labelexpected_version_hash

set_race_scope

Bind the canonical scenario to one race/campaign so its map, tally, candidates, War Room context, operations, outputs, and MCP actions share the same race identity.

輸入參數cyclelevelstageofficerebindcandidatecandidatesgeography_idsimulation_id必填workspace_scope

call_tool

Run any other tool you are authorized for that is not in this list. Find it and its exact input schema with get_catalog (search, a workflow, or {tool: name}), then call call_tool({ name, arguments }). The named tool…

輸入參數name必填arguments

版本歷史

1
  1. v0.1.0最新Nov 4, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分