Elections Canada MCP Server

by ThreeFortyThree-Canada

115 downloads
Not rated
GitHub

About

This Model Context Protocol (MCP) server provides access to Canadian federal election data. The server exposes resources and tools to query and analyze election results by riding, province, and party.

Details

Author
ThreeFortyThree-Canada
Downloads
115
Categories
Other

- Search ridings by name (accent-insensitive)
- Get vote share and percentages per riding
- Find the winning party in any riding
- Summarize province-wide or national election results
- Identify closest ridings and best/worst party performances
- Access riding, province, and list resources via URI

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Elections Canada MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install via PyPI with uv pip install elections-canada-mcp-server, then configure your MCP client (e.g., Claude Desktop) by adding the server to claude_desktop_config.json. After restarting, ask natural-language questions like "What were the 2021 election results in Toronto Centre?"

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "elections canada mcp server": {
            "elections-canada-mcp-server": {
                "command": "uv",
                "args": [
                    "pip",
                    "install",
                    "elections-canada-mcp-server"
                ]
            }
        }
    }
}

McpServers

{
    "elections-canada-mcp-server": {
        "command": "uv",
        "args": [
            "pip",
            "install",
            "elections-canada-mcp-server"
        ]
    }
}

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

1. Make sure the server is installed:

uv pip install elections-canada-mcp-server

2. Open your claude_desktop_config.json and 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"]
    }
  }
}

3. Restart Claude Desktop.

4. 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:

1. Clone this repository:

   git clone https://github.com/ThreeFortyThree-Canada/elections-canada-mcp-server.git
cd elections-canada-mcp-server

2. Install MCP CLI:

   uv pip install mcp

3. 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

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.