MCP server for Elections Canada data
Project description
Elections Canada MCP Server
This is a Model Context Protocol (MCP) server that provides access to Canadian federal election data. It currently supports results from the 2021 and 2025 elections. Future updates will include past elections, census demographics, and ThreeFortyThree real-time projections.
Brought to you by ThreeFortyThree, this server powers ThreeFortyThree Chat and is available for use with MCP clients such as Claude Desktop.
🛠 Setup
Installation (via PyPI)
uv pip install elections-canada-mcp-server
Usage with Claude Desktop
- Make sure the server is installed:
uv pip install elections-canada-mcp-server
- Open your
claude_desktop_config.jsonand add the following block:
uv
{
"mcpServers": {
"elections_canada_data_and_predictions": {
"command": "{PATH_TO_UVX}", // Replace with output of: which uvx
"args": ["elections-canada-mcp"]
}
}
}
-
Restart Claude Desktop.
-
Now you can ask Claude questions such as:
- "What were the 2021 election results in Toronto Centre?"
- "Which ridings were closest for the NDP?"
- "Show me the highest-margin wins for the Conservatives in 2021."
Local Development
To test the server using MCP Inspector:
-
Clone this repository:
git clone https://github.com/ThreeFortyThree-Canada/elections-canada-mcp-server.git cd elections-canada-mcp-server
-
Install MCP CLI:
uv pip install mcp
-
Test the server:
mcp dev elections_canada_mcp/server.py
This opens a web UI to test the server locally.
🧰 Tools
| Tool | Description | Input | Returns |
|---|---|---|---|
search_ridings |
Search ridings by name (accent-insensitive) | search_term: str |
List of matching ridings |
get_party_votes |
Get vote share in a riding (optionally by party) | riding_code: str, party_code: str (optional) |
Votes and percentage |
get_winning_party |
Get the winning party in a riding | riding_code: str |
Winning party |
summarize_province_results |
Province-wide summary of votes/seats | province_name_or_code: str |
Party results |
summarize_national_results |
Canada-wide election summary | — | National party results |
find_closest_ridings |
Find most competitive ridings | num_results: int, party: str (optional) |
Closest margins |
best_and_worst_results |
Best/worst ridings for a party | party: str, num_entries: int |
4-category performance summary |
📚 Resources
| Resource | URI |
|---|---|
| All ridings | elections-canada://ridings |
| Single riding | elections-canada://riding/{riding_code} |
| Province | elections-canada://province/{province_code} |
📌 Province Codes
AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT
📌 Party Codes
LPC, CPC, NDP, BQ, GPC, PPC
📄 License
This project is licensed under the MIT License.
© ThreeFortyThree Canada – threefortythree.ca
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file elections_canada_mcp_server-0.1.3.tar.gz.
File metadata
- Download URL: elections_canada_mcp_server-0.1.3.tar.gz
- Upload date:
- Size: 50.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0700c122a91fdc468eeb3cba361588b5879dbeb648a6310099cb8514466842d6
|
|
| MD5 |
37561e8ff1f08bdd59bc3ae2c42846aa
|
|
| BLAKE2b-256 |
b446034fa69d11dc29bf47f7d707385201976932da40d963264adb8996dc83dd
|
File details
Details for the file elections_canada_mcp_server-0.1.3-py3-none-any.whl.
File metadata
- Download URL: elections_canada_mcp_server-0.1.3-py3-none-any.whl
- Upload date:
- Size: 47.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4e6b48ed762f83a3d42ab4fd27942498453ae6184aa500917ba30251bf273c6
|
|
| MD5 |
0065286bb5b4c82f0ed59d5d2518eefc
|
|
| BLAKE2b-256 |
234de49d46dbb5a9f5dce2746b31cc5db6f267e418b0e39be26b5406fe96d8c9
|