Odel
openstates mcp server

openstates mcp server

@cyanheadsDeveloper Tools1TypeScriptApache-2.0Updated 1w ago

Search bills, legislators, committees, and events across all 50 US states, DC, and Puerto Rico.

Server endpointStreamable HTTP

This is the third-party server itself — Odel doesn't run it. Hitting this URL directly talks straight to the upstream server with no auth or proxying. Connect through Odel to front it with managed auth.

@cyanheads/openstates-mcp-server

Search bills, legislators, committees, and events across all 50 US states, DC, and Puerto Rico via MCP. STDIO or Streamable HTTP.

10 Tools • 1 Resource • 2 Prompts

Version License Docker MCP SDK npm TypeScript Bun


Tools

10 tools covering the full Open States v3 API surface — bills, legislators, committees, events, and jurisdictions:

ToolDescription
openstates_search_billsSearch state legislative bills across all covered US jurisdictions with full-text search, jurisdiction/session filtering, subject tags, and sponsor lookups
openstates_get_billFetch full detail for a specific bill by OCD ID or three-part path (jurisdiction + session + bill_id)
openstates_search_peopleSearch state legislators and officials by name, jurisdiction, chamber, district, or party
openstates_get_legislators_by_locationFind all legislators representing a geographic coordinate (latitude/longitude)
openstates_search_committeesList committees for a jurisdiction (experimental — not all states have coverage)
openstates_get_committeeFetch committee detail by OCD organization ID, with optional membership roster
openstates_search_eventsSearch hearings, floor sessions, and committee meetings (experimental)
openstates_get_eventFetch full event detail including agenda, participants, and media links
openstates_list_jurisdictionsList all 52 jurisdictions covered by Open States with session identifiers and coverage metadata
openstates_get_jurisdictionFetch full metadata for a specific jurisdiction including all legislative sessions and their identifiers

openstates_search_bills

Search state legislative bills with rich filtering and inline related data.

  • Full-text search across bill titles, abstracts, and text (q)
  • Filter by jurisdiction (state name, two-letter abbreviation, or OCD-ID), session, chamber, classification, subject tags, and sponsor
  • Sort by latest action, first action, or update time — use sort=latest_action_desc for bills currently moving through the legislature
  • include parameter requests sponsorships, actions, votes, abstracts, versions, and related bills inline — eliminates follow-up openstates_get_bill calls for most research workflows
  • action_since and updated_since date filters for change-tracking
  • Pagination up to 20 results per page
  • Empty-result recovery: echoes applied filters and suggests how to broaden

openstates_get_bill

Fetch complete bill detail by OCD ID or path lookup.

  • Two lookup modes: openstates_id (OCD bill ID from search results, preferred) or the three-part path jurisdiction + session + bill_id
  • Accepts bill identifiers in legislature format (e.g., HB 1000, SB 42)
  • include=votes returns full vote tallies and per-legislator positions
  • include=versions,documents provides links to bill text and fiscal notes
  • Sponsors carry linked person records (OCD person ID + name) when available

openstates_search_people

Search legislators and officials by name, jurisdiction, chamber, or district.

  • Case-insensitive substring matching on name
  • org_classification targets a specific chamber: upper (Senate), lower (House/Assembly), legislature (all), executive (governors and executive officials)
  • include=offices returns phone, fax, and mailing address
  • include=links returns website and social media links
  • Strongly recommended to provide jurisdiction — omitting it returns legislators across all states

openstates_get_legislators_by_location

Find all state legislators representing a geographic coordinate.

  • Pass decimal-degree latitude/longitude to get state senators and representatives for that location
  • Useful for constituent-to-representative matching, address-based policy research, and electoral boundary analysis
  • Does not geocode addresses — the caller must provide coordinates
  • Returns a coverage note when no legislators are found (e.g., coordinates outside US boundaries)

openstates_list_jurisdictions and openstates_get_jurisdiction

Discover and look up jurisdiction coverage metadata.

  • openstates_list_jurisdictions returns all 52 jurisdictions (50 states + DC + Puerto Rico) in a single call with per_page=52 (the default)
  • include=legislative_sessions returns all historical and current session identifiers — required before filtering bill searches by session, since formats vary widely by state (e.g., 2025, 2025-2026, 2025rs, 2025s1)
  • openstates_get_jurisdiction fetches one jurisdiction by OCD-ID, state name, or two-letter abbreviation

Committee and event tools (experimental)

openstates_search_committees, openstates_get_committee, openstates_search_events, and openstates_get_event are experimental — Open States is actively working to restore committee support and most states do not publish event data. Empty results may indicate the state lacks data, not that no committees or events exist. All four tools include a coverage_note in their output documenting this limitation.

Resources and prompts

TypeNameDescription
Resourceopenstates://jurisdiction/{jurisdiction_id}Jurisdiction metadata including current sessions, coverage dates, and bill/people update timestamps
Promptopenstates_bill_researchStructured framework for analyzing a state bill: summary, sponsors, committee referrals, action timeline, vote record, and related legislation
Promptopenstates_legislator_profileResearch framework for profiling a legislator: sponsored bills, committee assignments, voting record, and contact details

All resource data is also reachable via tools. Use openstates_get_jurisdiction for programmatic jurisdiction lookups; the resource is useful for injecting jurisdiction context as stable reference material.

Features

Built on @cyanheads/mcp-ts-core:

  • Declarative tool, resource, and prompt definitions — single file per primitive, framework handles registration and validation
  • Unified error handling — handlers throw, framework catches, classifies, and formats
  • Pluggable auth: none, jwt, oauth
  • Swappable storage backends: in-memory, filesystem, Supabase, Cloudflare KV/R2/D1
  • Structured logging with optional OpenTelemetry tracing
  • STDIO and Streamable HTTP transports

Open States-specific:

  • Full Open States v3 API coverage: bills, people, committees, events, and jurisdictions
  • Dual lookup modes on bill and committee fetchers (OCD ID or structured path)
  • Geo-based legislator lookup via the Open States people-by-geo endpoint
  • Server-level instructions prime the agent with session discovery workflow and include parameter strategy before any tool calls

Agent-friendly output:

  • Empty-result recovery: tools echo the applied filters and suggest how to broaden when no results are returned
  • Experimental coverage notes on committee and event tools — agents can surface these to users rather than returning silent empty results
  • include parameter pattern across all search and get tools — avoids N+1 follow-up calls for common research workflows (e.g., include=sponsorships,actions on openstates_search_bills)

Getting started

Requires an Open States API key — register free at open.pluralpolicy.com.

Add the following to your MCP client configuration file:

{
  "mcpServers": {
    "openstates-mcp-server": {
      "type": "stdio",
      "command": "bunx",
      "args": ["@cyanheads/openstates-mcp-server@latest"],
      "env": {
        "MCP_TRANSPORT_TYPE": "stdio",
        "MCP_LOG_LEVEL": "info",
        "OPENSTATES_API_KEY": "your-api-key"
      }
    }
  }
}

Or with npx (no Bun required):

{
  "mcpServers": {
    "openstates-mcp-server": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@cyanheads/openstates-mcp-server@latest"],
      "env": {
        "MCP_TRANSPORT_TYPE": "stdio",
        "MCP_LOG_LEVEL": "info",
        "OPENSTATES_API_KEY": "your-api-key"
      }
    }
  }
}

Or with Docker:

{
  "mcpServers": {
    "openstates-mcp-server": {
      "type": "stdio",
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "MCP_TRANSPORT_TYPE=stdio",
        "-e", "OPENSTATES_API_KEY=your-api-key",
        "ghcr.io/cyanheads/openstates-mcp-server:latest"
      ]
    }
  }
}

For Streamable HTTP, set the transport and start the server:

MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 OPENSTATES_API_KEY=your-key bun run start:http
# Server listens at http://localhost:3010/mcp

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/cyanheads/openstates-mcp-server.git
  1. Navigate into the directory:
cd openstates-mcp-server
  1. Install dependencies:
bun install
  1. Configure environment:
cp .env.example .env
# edit .env and set OPENSTATES_API_KEY

Configuration

All configuration is validated at startup via Zod schemas in src/config/server-config.ts. Key environment variables:

VariableDescriptionDefault
OPENSTATES_API_KEYRequired. Open States API key from open.pluralpolicy.com.
OPENSTATES_API_BASE_URLOpen States API base URL.https://v3.openstates.org
MCP_TRANSPORT_TYPETransport: stdio or http.stdio
MCP_HTTP_PORTHTTP server port.3010
MCP_HTTP_ENDPOINT_PATHHTTP endpoint path./mcp
MCP_PUBLIC_URLPublic origin override for TLS-terminating reverse-proxy deployments.none
MCP_AUTH_MODEAuth mode: none, jwt, or oauth.none
MCP_LOG_LEVELLog level (debug, info, notice, warning, error).info
MCP_GC_PRESSURE_INTERVAL_MSOpt-in Bun-only forced-GC interval (ms). Try 60000 if heap grows under sustained HTTP load.0 (disabled)
LOGS_DIRDirectory for log files (Node.js only).<project-root>/logs
STORAGE_PROVIDER_TYPEStorage backend: in-memory, filesystem, supabase, cloudflare-kv/r2/d1.in-memory
OTEL_ENABLEDEnable OpenTelemetry instrumentation.false

See .env.example for the full list of optional overrides.

Running the server

Local development

  • Build and run the production version:

    # One-time build
    bun run rebuild
    
    # Run the built server
    bun run start:stdio
    # or
    bun run start:http
    
  • Run checks and tests:

    bun run devcheck   # Lint, format, typecheck, security
    bun run test       # Vitest test suite
    bun run lint:mcp   # Validate MCP definitions against spec
    

Docker

docker build -t openstates-mcp-server .
docker run --rm -e OPENSTATES_API_KEY=your-key -e MCP_TRANSPORT_TYPE=http -p 3010:3010 openstates-mcp-server

The Dockerfile defaults to HTTP transport, stateless session mode, and logs to /var/log/openstates-mcp-server. OpenTelemetry peer dependencies are installed by default — build with --build-arg OTEL_ENABLED=false to omit them.

Project structure

DirectoryPurpose
src/index.tscreateApp() entry point — registers tools, resources, prompts, and inits the Open States service.
src/configServer-specific environment variable parsing and validation with Zod.
src/mcp-server/toolsTool definitions (*.tool.ts). Ten tools across bills, people, committees, events, and jurisdictions.
src/mcp-server/resourcesResource definitions. Jurisdiction metadata resource.
src/mcp-server/promptsPrompt definitions. Bill research and legislator profile prompts.
src/services/openstatesOpen States API v3 service layer — HTTP client, request handling, domain types.
tests/Unit and integration tests mirroring src/.

Development guide

See CLAUDE.md for development guidelines and architectural rules. The short version:

  • Handlers throw, framework catches — no try/catch in tool logic
  • Use ctx.log for request-scoped logging, ctx.state for tenant-scoped storage
  • Register new tools and resources via the arrays in src/index.ts
  • Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields

Contributing

Issues and pull requests are welcome. Run checks and tests before submitting:

bun run devcheck
bun run test

License

Apache-2.0 — see LICENSE for details.