FEC Campaign Finance MCP Server
Connects the OpenFEC API to AI assistants for investigating US federal campaign finance through natural language conversations.
README
FEC Campaign Finance MCP Server
Author: Reinaldo Chaves (reichaves@gmail.com)
Leia isto em Português
An MCP server that connects the OpenFEC API to AI assistants, allowing you to investigate US federal campaign finance through natural conversations.
Designed for data journalists, researchers, and citizens who need to explore complex Federal Election Commission (FEC) data without directly knowing the API.
Table of Contents
- What is MCP?
- What does this project do?
- Architecture
- Available Tools
- Installation
- Configuration
- Usage Examples
- Development and Tests
What is MCP?
MCP (Model Context Protocol) is an open standard that enables AI assistants to communicate with external systems — databases, APIs, files, services — securely and uniformly.
The three types of MCP capabilities
| Type | What it is | Example in this project |
|---|---|---|
| Tools | Functions the AI can call to fetch or manipulate data | search_candidates(), get_top_donors() |
| Resources | Static or contextual data that is always available | FEC codes tables, notable IDs, Glossary |
| Prompts | Workflow templates guiding complex investigations | investigate_candidate(), follow_the_money() |
What does this project do?
This project exposes the OpenFEC API as an MCP server. The result: you can investigate political financing just by conversing with an LLM.
Key Capabilities
- Candidate Search: Find any federal candidate by name, state, party, or office.
- Financial Analysis: Totals raised, spent, debts, and Cash on Hand.
- Donor Tracking: Identify the top financiers of a campaign and their employers.
- Geo-analysis: See from which states a candidate's money comes.
- Super PACs and Independent Expenditures: Monitor outside groups spending to support or attack candidates.
- Official Reports: Access filings submitted to the FEC by campaigns and committees.
- Guided Investigation: Ready-to-use workflows for journalistic investigations.
🔍 Methodological Note (OSINT and Data Architecture)
The FEC API separates "Candidate Totals" (the primary endpoint of the official committee) from the money housed in Political Action Committees (PACs). The fec_mcp was designed strictly for the "Zero Hallucination" principle. It exposes data exactly as the government bureaucracy classifies it.
In OSINT investigations, it is up to the AI agent or journalist to use search_candidates to list all Principal Authorized Committees and PACs attached to a politician and query their finances individually.
Multi-language Support (i18n)
The server supports internationalization. The default language for responses and tips is English. You can change this by setting the FEC_MCP_LANG environment variable (e.g., FEC_MCP_LANG=pt-br).
Architecture
fec-mcp-server/
├── README.md # Main documentation in English
├── README.pt-br.md # Main documentation in Portuguese
├── .env.example # Example environment variables (API keys, language)
├── pyproject.toml # Project configuration and modern Python dependencies
├── requirements.txt # List of dependencies for simple installation via pip
├── start_server.py # Entry point: adds src/ to path and starts the MCP server
├── src/fec_mcp/
│ ├── main.py # Imports all modules to register them in FastMCP
│ ├── server.py # Creates the central `mcp = FastMCP(...)` instance
│ ├── context.py # Singleton `fec`: shared instance of FECClient
│ ├── client.py # Active FECClient: HTTP requests, retry/backoff, timeouts
│ ├── i18n.py # Internationalization system (loads text from /locales)
│ ├── logging_config.py # Logging configuration and verbosity levels
│ ├── models.py # Pydantic data models for validating API responses
│ ├── tools/ # MCP Tools (@mcp.tool)
│ │ ├── candidates.py # search_candidates, get_candidate_finances
│ │ ├── contributions.py # search_contributions, get_top_donors, get_contributions_by_state
│ │ ├── expenses.py # get_campaign_expenditures, get_independent_expenditures
│ │ ├── filings.py # get_campaign_filings for financial reports
│ │ ├── search.py # search_pacs for finding political action committees
│ │ └── meta.py # fec_help, suggest_investigation
│ ├── resources/ # MCP Resources (@mcp.resource)
│ │ └── reference.py # FEC codes, notable IDs, glossary, API info
│ ├── prompts/ # MCP Prompts (@mcp.prompt)
│ │ └── investigation.py # investigate_candidate, follow_the_money, compare_candidates
│ ├── data/ # Static JSON files used by tools
│ │ ├── glossary.json # FEC glossary terms
│ │ ├── help.json # Documentation and examples by topic for fec_help
│ │ └── investigations.json # Journalism investigation pitches
│ └── locales/ # Translation files
│ ├── en.json # English translations
│ └── pt.json # Portuguese translations
└── tests/
└── test_server.py # Automated tests for the client and endpoints using pytest and respx
Available Tools
Tools
search_candidates: Search for federal candidates.get_candidate_finances: Get financial totals for a candidate.search_contributions: Search for individual donations (Schedule A).get_top_donors: List the top donors to a committee.get_contributions_by_state: Aggregate donations by state.get_campaign_expenditures: List a campaign's expenditures (Schedule B).get_independent_expenditures: Search for independent expenditures by Super PACs.get_candidate_filings/get_committee_filings: List financial reports submitted to the FEC.search_pacs: Search for PACs and Super PACs by name.fec_help: Internal documentation for the tools.suggest_investigation: Journalistic pitch suggestions based on FEC data.
Resources
| URI | Content |
|---|---|
fec://reference/codes |
Party codes, offices, committee types, filing types, donation limits |
fec://reference/notable_ids |
IDs of presidential candidates, national committees, relevant Super PACs |
fec://reference/api_info |
Data coverage, rate limits, usage tips |
fec://reference/glossary |
Glossary of FEC terminology (e.g., PAC, Schedule A, Cash on Hand) |
Prompts
investigate_candidate(candidate_name): Step-by-step workflow for a complete financial investigation of a candidate.follow_the_money(company_name): Tracks the political influence of a company.compare_candidates(candidate1, candidate2): Side-by-side comparison of two candidates.
Installation
Prerequisites
- Python 3.10+
- FEC API Key: Free at api.data.gov/signup
Steps
git clone https://github.com/your-username/fec-mcp-server.git
cd fec-mcp-server
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
echo "FEC_API_KEY=your_key_here" > .env
Usage Examples
Investigate a candidate
"Investigate the campaign finances of Kamala Harris in 2024"
The LLM will automatically execute:
search_candidates(name="Kamala Harris", election_year=2024)get_candidate_finances(candidate_id="P00009423")get_top_donors(committee_id="C00703975")
Compare candidates
"Compare the finances of Trump and Biden for 2024"
The prompt compare_candidates generates a complete table with all metrics side by side.
Known Limitations
- Federal data only: State and local elections are not in the FEC.
- Dark money: Donations to 501(c)(4) are not disclosed to the FEC.
- Latency: Individual donation endpoints (
schedule_a) can be slow. - Rate limit: 1,000 requests/hour with the free API key.
External Resources
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。