civic-mcp
A minimal MCP server that exposes U.S. election dates via the get_election_dates tool, supporting all 50 states and DC with fuzzy state name matching.
README
civic-mcp
A minimal MCP server that exposes U.S. election
dates. It has a single tool, get_election_dates, backed by
election_dates.json loaded into memory at startup.
Requirements
- Python 3.10+
pip install "mcp[cli]"
Only have Python 3.9 (macOS's default system Python)? The
mcpSDK requires 3.10+ and won't install on 3.9. Install a newer version alongside your system Python without touching it — e.g. via Homebrew:brew install python@3.12 /opt/homebrew/bin/python3.12 -m venv .venv source .venv/bin/activate pip install -e ".[dev]"Then use
.venv/bin/python,.venv/bin/pytest, etc. for this project.
Run
python server.py
Or, for local development with the MCP Inspector:
mcp dev server.py
Tool: get_election_dates
Input
| field | type | required | description |
|---|---|---|---|
| state | string | yes | USPS two-letter state code (e.g. "CA") or full state name (e.g. "California"), or "DC" / "District of Columbia". Case-insensitive. |
Output
{
"state": "CA",
"state_name": "California",
"primary": "2026-06-02",
"days_until_primary": -47,
"general_election": "2026-11-03",
"days_until_general": 107,
"cycle": "2026",
"source": "Federal Voting Assistance Program (FVAP.gov)",
"source_as_of": "2026-05"
}
days_until_primary / days_until_general are computed from the current
date at request time and may be negative if the date has already passed.
days_until_primary is null if the state has no primary currently
scheduled.
Covers the 50 states + DC only; U.S. territories and local/municipal races are
out of scope (see election_dates.json metadata).
Input handling
Unrecognized input raises UnknownStateError (a ValueError subclass) with a
message listing valid codes — never a silent null or an unhandled crash.
Input is trimmed, internal whitespace is collapsed, and stray punctuation
(e.g. "D.C.") is stripped before matching. A conservative fuzzy match
(cutoff 0.82) against full state names catches common misspellings (e.g.
"Calfornia" → CA); anything below that confidence fails clearly instead
of guessing.
Tests
pip install -e ".[dev]"
pytest
tests/test_server.py covers: a valid two-letter code, a valid full name
(case-insensitive), invalid input, DC (by code, full name, and alias), a
state with no primary currently scheduled, and a snapshot-style check that
general_election is identical across every state. No state in
election_dates.json currently lacks a primary date, so that case is
exercised via monkeypatch on a synthetic entry rather than by inserting a
fabricated date into the real FVAP-sourced dataset.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.