civicgraph-mcp
A money-in-politics knowledge graph, as an MCP server. It links entities across federal campaign donations, lobbying disclosures, and government contracts.
README
civicgraph-mcp
A money-in-politics knowledge graph, as an MCP server. It links entities across federal campaign donations, lobbying disclosures, and government contracts — so an agent can trace a name from a donor record, to a lobbying client, to a federal contract, and surface the "follow the money" / revolving-door connections nobody else exposes as a tool.
Why this exists
The raw sources each already have MCP servers — FEC (donations), Senate LDA (lobbying), USASpending (contracts). But they're islands. The valuable, hard, unbuilt part isn't the rows; it's the joins: resolving that the "John A. Smith" in an FEC filing, the lobbyist in an LDA report, and the contractor contact in USASpending are (or aren't) the same entity, and letting you walk those connections. That linkage — explainable entity resolution — is the product.
Quick start (offline, no API keys)
The whole pipeline runs on committed sample data, so a fresh checkout works with no network and no keys.
uv sync # create the env, install deps
uv run civicgraph ingest # load the oklahoma-2024 slice from samples
uv run civicgraph build # build the single-source graph (24 nodes, 22 edges)
uv run civicgraph resolve # cross-source entity resolution (8 merges -> 17 entities)
uv run civicgraph eval # measure resolution quality (P/R/F1 on a labeled set)
Then query it:
# Find an entity
uv run civicgraph search "Heartland"
# -> HEARTLAND DEFENSE SYSTEMS, INC. sources: [fec, usaspending]
# Resolve a name to a canonical entity, with confidence + the features behind it
uv run civicgraph resolve-name "James Carter" --state OK --employer "Carter & Lowe LLP" --kind person
# Follow the money: a PAC -> a defense agency, through a donor who is also a contractor
PAC=$(uv run civicgraph search "Oklahoma Prosperity PAC" | jq -r '.results[0].entity_id')
ARMY=$(uv run civicgraph search "Department of the Army" | jq -r '.results[0].entity_id')
uv run civicgraph path "$PAC" "$ARMY"
# OKLAHOMA PROSPERITY PAC <-donated_to (FEC, $7,500)- HEARTLAND DEFENSE SYSTEMS
# -contracted_with (USASpending, $4.2M)-> Department of the Army
Every edge carries its source record URL + date; every resolution carries a confidence score and the features that drove it.
Use it as an MCP server
uv run civicgraph serve # speaks MCP over stdio
Register it with an MCP host (e.g. Claude Desktop). Populate the store once
(ingest / build / resolve), then point the host at the repo:
{
"mcpServers": {
"civicgraph": {
"command": "uv",
"args": ["run", "civicgraph", "serve"],
"cwd": "/path/to/civicgraph-mcp"
}
}
}
Tools
| Tool | What it does |
|---|---|
resolve_entity(name, state?, employer?, kind?) |
Fuzzy-match a name/org to a canonical entity, with confidence, the matching features, and runner-up alternatives. |
entity_profile(entity_id) |
Everything we know: donations, lobbying roles, contracts, aliases, sources — edges summarized by type, each with provenance. |
connections(entity_id, hops=1, types?) |
Neighbors in the graph, optionally filtered to specific edge types. |
path_between(entity_a, entity_b, max_hops=4) |
Shortest sourced path between two entities — how they're connected. |
search(query, limit=10) |
Full-text search across entity names and aliases. |
(ping, graph_stats are also exposed.)
Live data
The offline demo uses synthetic samples. To ingest real federal data for the
slice, get free keys (FEC,
Senate LDA; USASpending needs none), copy
.env.example to .env, fill them in, and:
uv run civicgraph ingest --live
uv run civicgraph build && uv run civicgraph resolve
FEC's 1,000 req/hr limit is respected via on-disk caching + backoff; raw snapshots
are written under data/raw/ before normalization so runs are auditable.
How it works
FEC ─┐
LDA ─┼─▶ adapters (snapshot → normalize) ─▶ staging ─▶ graph (raw nodes + edges)
USAspending ─┘ │
entity resolution (block → score → merge)
│
DuckDB store ◀── canonical entities + node_map
│
FastMCP server / civicgraph CLI
- Bounded slice. v1 is Oklahoma, 2024 cycle — see docs/slice.md. Scope discipline is a feature: a correct, explainable small graph first.
- Explainable resolution. A strong name match alone never merges; identity needs corroboration (shared employer/firm, state, zip), and conflicting evidence is penalized. Auto-merge above a high threshold, surface a candidate in the middle band, never link below. See docs/resolution-eval.md for the measured precision/recall.
- Non-destructive. Edges reference raw nodes; resolution only repoints a
node_map, so it's re-runnable and merges are never destructive.
Development
uv run pytest # full offline suite
uv run ruff check . # lint
If uv run civicgraph ... ever reports No module named 'civicgraph' (a known
editable-install quirk on some setups, e.g. project paths containing spaces), run
with PYTHONPATH=src uv run civicgraph ... — the test suite is unaffected.
See SPEC.md, BUILD_PLAN.md, and CLAUDE.md for the design.
License
MIT.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。