mcpField
B
bill-commons

bill-commons

远程服务
billcommons.org法律与政务09 周前更新

关于 bill-commons

Bill Commons 是覆盖美国 50 个州及华盛顿特区当前立法会期的开源检索平台,面向公众及立法研究者。它通过搜索界面、REST API 和 MCP 服务提供法案全文、发起人、投票与状态信息。

主要功能

  1. 01检索 20.9 万余项州法案
  2. 02查看法案全文、发起人及状态
  3. 03比较法案不同版本
  4. 04追踪立法历史
  5. 05提供 REST API 与覆盖状态页

适用场景

  1. 01查找特定州或主题的法案
  2. 02核对法案修订与投票进展
  3. 03比较各州当前立法议题

MCP 相关

MCP 服务通过 Streamable HTTP 向 MCP 客户端开放立法搜索与法案查询工具,包括 `search_legislation`、`get_bill_record`、`compare_bill_versions` 和 `trace_legislative_history`。

配置

远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。

服务地址https://mcp.billcommons.org/mcp
一键复制安装命令
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。

工具

10
参数类型必填说明
qstring是
limitany否
statusany否
chamberany否
jurisdictionany否

详细介绍

Bill Commons

Bill Commons 是一个公开的开源立法搜索平台,覆盖美国全部 50 个州及 DC 当前届期/两年会期的立法信息。平台提供网页搜索界面、REST API、MCP(Model Context Protocol)服务,以及公开的状态/覆盖范围页面。优先建设公共基础设施:普通搜索和合理的 API 使用不设付费墙——匿名调用者享有宽松的每日限额(每个 IP 每天 2,000 次请求,每个 /24 子网每天 5,000 次);免费 API 密钥可进一步提高限额,只有高频/批量使用才收费。有关 API 密钥和完整语料快照,请参阅 /docs/bulk。

有关已确定的架构和数据模型,请参阅 docs/architecture/ARCHITECTURE.md。

生产环境

托管于 Railway(项目 billcommons:api、mcp、worker 服务 + 托管式 Postgres)和 Vercel(项目 billcommons-web)。完整的部署/回滚流程请参阅 docs/operations/deployment-runbook.md。

与 Claude(或任何 MCP 客户端)搭配使用

托管的 MCP 服务可让 AI 助手直接访问 209k+ 条法案——无需 API 密钥,也无需额外设置,只需运行一条命令:

claude mcp add bill-commons --transport http https://mcp.billcommons.org/mcp

Claude Desktop:前往 Settings → Connectors → Add custom connector,并填写 URL https://mcp.billcommons.org/mcp。Cursor 和其他客户端:在 mcp.json 中将相同 URL 添加为 Streamable HTTP 服务。

提供 10 个工具,包括 search_legislation、get_bill_record、 compare_bill_versions 和 trace_legislative_history。完整操作指南(包括适用于不使用 MCP 的 Agent 的 REST 示例): https://billcommons.org/docs/agents

架构概览

                    ┌─────────────┐
   users ─────────▶ │  apps/web   │  Next.js, billcommons.org
                    │ (Vercel)    │  status.billcommons.org (rewrite → /coverage)
                    └──────┬──────┘
                           │ HTTPS (NEXT_PUBLIC_API_BASE)
                           ▼
                    ┌─────────────┐        ┌──────────────┐
                    │  apps/api   │◀──────▶│  apps/mcp    │  Streamable HTTP
                    │  FastAPI    │        │  10 MCP tools│  mcp.billcommons.org
                    │ /api/v1     │        └──────────────┘
                    │ api.billcommons.org
                    └──────┬──────┘
                           │ reads (SQLAlchemy)
                           ▼
                    ┌─────────────────────────────┐
                    │   Postgres 16 (Railway)      │
                    │  jurisdictions, sessions,     │
                    │  bills, actions, sponsorships,│
                    │  votes, ingest_jobs, coverage  │
                    └──────────────▲──────────────┘
                                   │ writes (idempotent upserts)
                    ┌──────────────┴──────────────┐
                    │  workers/ingest (worker svc)  │
                    │  autoboot: seed → bootstrap →│
                    │  schedule-refresh → job loop  │
                    │  sources: Open States bulk CSV│
                    │  (T2 bootstrap) + v3 API (T2  │
                    │  incremental, OPENSTATES_API_ │
                    │  KEY) + full-text fetcher     │
                    └──────────────┬──────────────┘
                                   ▼
                    RawStore (filesystem, RAWSTORE_ROOT
                    volume in prod) — sha256-addressed
                    raw payload archive

packages/schema(SQLAlchemy 模型 + Alembic)是所有其他软件包/应用导入的唯一真实数据源——每个服务都不维护自己的数据模型副本。

单体仓库布局

apps/web        Next.js 15 (App Router, TS) — search UI + status page
apps/api        FastAPI — REST API (/api/v1)
apps/mcp        MCP server (Streamable HTTP, mounted at /mcp)
workers/ingest  Ingestion workers, job queue, per-source adapters
packages/schema SQLAlchemy models + Alembic migrations (single source of truth)
packages/shared Shared Python utils: bill-number normalization, rawstore, http client
packages/source-registry  Per-jurisdiction source registry (data + loader)
packages/search Search SQL builders / query parsing
infra/docker    Dockerfiles + docker-compose.yml (local stack)
infra/deployment Railway/Vercel configs, DNS runbook
docs/           Architecture, API, sources, operations, state-coverage docs
data/registry   Machine-readable registry (sessions, sources)

本地开发环境设置

前置条件
  • Python 3.12
  • PostgreSQL 16(需提供 pg_trgm、unaccent、pgcrypto 扩展)
  • Node.js 20+(用于 apps/web)
Python 环境
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

这会将 packages/schema 和 packages/shared 作为可编辑安装包安装(分别作为数据模型和共享实用工具的唯一真实数据源),并安装 worker 软件包:.venv/bin/pip install -e workers/ingest。如果你要开发 API,也请安装 API 软件包:.venv/bin/pip install -e apps/api。

数据库

在环境中设置 DATABASE_URL(或设置在 ~/.config/billcommons/.env 中,该文件会作为备用配置读取,且绝不会提交到版本控制):

DATABASE_URL=postgresql://user:password@host:port/dbname

需要使用提供 pg_trgm 和 unaccent 扩展的 Postgres 16(由迁移 0001 创建)。运行迁移:

cd packages/schema
../../.venv/bin/alembic upgrade head
在本地填充数据
# Seed all 51 jurisdictions/sessions/coverage rows from the registry:
.venv/bin/python -m billcommons_ingest seed-registry

# Download a state's Open States bulk-CSV zip and ingest it (see
# docs/operations/ingestion-runbook.md for the full command reference):
python3 workers/ingest/download_bulk.py --only NC
.venv/bin/python -m billcommons_ingest bootstrap --state NC --zip data/bulkzips/NC_2025.zip
.venv/bin/python -m billcommons_ingest recompute-coverage
在本地运行应用
# API (FastAPI, http://localhost:8000, docs at /docs)
.venv/bin/uvicorn main:app --app-dir apps/api --reload --port 8000

# MCP server (Streamable HTTP, http://localhost:8400/mcp by default)
.venv/bin/python apps/mcp/server.py

# Ingestion worker (long-running queue loop; runs schedule-refresh
# periodically inside the same process)
.venv/bin/python -m billcommons_ingest worker

# Web app (Next.js — separate from the Python stack)
cd apps/web
npm install
NEXT_PUBLIC_API_BASE=http://localhost:8000 npm run dev
测试
.venv/bin/pytest packages/shared/tests
.venv/bin/pytest workers/ingest/tests
.venv/bin/pytest apps/api/tests
使用 Docker 在本地运行整个服务栈
cd infra/docker
docker compose up --build

这会启动 Postgres、API、数据摄取 worker 和 MCP 服务。本地开发时,Web 应用(apps/web)需通过 npm run dev 单独运行(占位服务定义请参阅 infra/docker/docker-compose.yml)。

文档

许可证

Apache-2.0。数据归属信息见 LICENSE 和 NOTICE (Open States / Plural Policy,立法数据属于公共领域)。

贡献

请参阅 CONTRIBUTING.md。本项目遵循 Contributor Covenant。

安全

请参阅 SECURITY.md,了解负责任的漏洞披露方式。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。