Skip to main content
Glama

Open States API MCP Server

main.py9.28 kB
# generated by fastapi-codegen: # filename: openapi.yaml # timestamp: 2025-06-29T07:59:01+00:00 import argparse import json import os from typing import * from typing import Optional, Union from autogen.mcp.mcp_proxy import MCPProxy from autogen.mcp.mcp_proxy.security import BaseSecurity from fastapi import Header from models import ( Bill, BillList, BillSortOption, Committee, CommitteeClassification, CommitteeList, Event, EventList, HTTPValidationError, Id, Identifier, Include, Include1, Include3, Include5, Include7, Include8, Include9, Include10, Jurisdiction, JurisdictionClassification, JurisdictionList, OrgClassification, PersonList, Subject, ) app = MCPProxy( description='\n* [More documentation](https://docs.openstates.org/en/latest/api/v3/index.html)\n* [Register for an account](https://openstates.org/accounts/signup/)\n\n\n**We are currently working to restore experimental support for committees & events.**\n\nDuring this period please note that data is not yet available for all states\nand the exact format of the new endpoints may change slightly depending on user feedback.\n\nIf you have any issues or questions use our\n[GitHub Issues](https://github.com/openstates/issues/issues) to give feedback.\n', title='Open States API v3', version='2021.11.12', ) @app.get( '/bills', description=""" Search for bills matching given criteria. Must either specify a jurisdiction or a full text query (q). Additional parameters will futher restrict bills returned. """, tags=['bill_handling'], ) def bills_search_bills_get( jurisdiction: Optional[str] = None, session: Optional[str] = None, chamber: Optional[str] = None, identifier: Optional[Identifier] = [], classification: Optional[str] = None, subject: Optional[Subject] = [], updated_since: Optional[str] = None, created_since: Optional[str] = None, action_since: Optional[str] = None, sort: Optional[BillSortOption] = 'updated_desc', sponsor: Optional[str] = None, sponsor_classification: Optional[str] = None, q: Optional[str] = None, include: Optional[Include] = [], page: Optional[int] = 1, per_page: Optional[int] = 10, apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Bills Search """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/bills/ocd-bill/{openstates_bill_id}', description=""" Obtain bill information by internal ID in the format ocd-bill/*uuid*. """, tags=['bill_handling'], ) def bill_detail_by_id_bills_ocd_bill__openstates_bill_id__get( openstates_bill_id: str, include: Optional[Include1] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Bill Detail By Id """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/bills/{jurisdiction}/{session}/{bill_id}', description=""" Obtain bill information based on (state, session, bill_id). """, tags=['bill_handling'], ) def bill_detail_bills__jurisdiction___session___bill_id__get( jurisdiction: str, session: str = ..., bill_id: str = ..., include: Optional[Include1] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Bill Detail """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/committees', tags=['committee_overview']) def committee_list_committees_get( jurisdiction: Optional[str] = None, classification: Optional[CommitteeClassification] = None, parent: Optional[str] = None, chamber: Optional[OrgClassification] = None, include: Optional[Include3] = [], apikey: Optional[str] = None, page: Optional[int] = 1, per_page: Optional[int] = 20, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Committee List """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/committees/{committee_id}', description=""" Get details on a single committee by ID. """, tags=['committee_overview'], ) def committee_detail_committees__committee_id__get( committee_id: str, include: Optional[Include3] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Committee Detail """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/events', tags=['event_tracking', 'jurisdiction_data']) def event_list_events_get( jurisdiction: Optional[str] = None, deleted: Optional[bool] = False, before: Optional[str] = None, after: Optional[str] = None, require_bills: Optional[bool] = False, include: Optional[Include5] = [], apikey: Optional[str] = None, page: Optional[int] = 1, per_page: Optional[int] = 20, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Event List """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/events/{event_id}', description=""" Get details on a single event by ID. """, tags=['event_tracking'], ) def event_detail_events__event_id__get( event_id: str, include: Optional[Include5] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Event Detail """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/jurisdictions', description=""" Get list of supported Jurisdictions, a Jurisdiction is a state or municipality. """, tags=['jurisdiction_data'], ) def jurisdiction_list_jurisdictions_get( classification: Optional[JurisdictionClassification] = None, include: Optional[Include7] = [], page: Optional[int] = 1, per_page: Optional[int] = 52, apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Jurisdiction List """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/jurisdictions/{jurisdiction_id}', description=""" Get details on a single Jurisdiction (e.g. state or municipality). """, tags=['jurisdiction_data'], ) def jurisdiction_detail_jurisdictions__jurisdiction_id__get( jurisdiction_id: str, include: Optional[Include8] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ Jurisdiction Detail """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/metrics', description=""" Endpoint that serves Prometheus metrics. """, tags=['metrics_analysis'], ) def metrics_metrics_get(): """ Metrics """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/people', description=""" Get list of people matching selected criteria. Must provide either **jurisdiction**, **name**, or one or more **id** parameters. """, tags=['people_information', 'jurisdiction_data'], ) def people_search_people_get( jurisdiction: Optional[str] = None, name: Optional[str] = None, id: Optional[Id] = [], org_classification: Optional[OrgClassification] = None, district: Optional[str] = None, include: Optional[Include9] = [], page: Optional[int] = 1, per_page: Optional[int] = 10, apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ People Search """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/people.geo', description=""" Get list of people currently representing a given location. **Note:** Currently limited to state legislators and US Congress. Governors & mayors are not included. """, tags=['people_information', 'jurisdiction_data'], ) def people_geo_people_geo_get( lat: float, lng: float = ..., include: Optional[Include10] = [], apikey: Optional[str] = None, x_api_key: Optional[str] = Header(None, alias='x-api-key'), ): """ People Geo """ raise RuntimeError("Should be patched by MCPProxy and never executed") if __name__ == "__main__": parser = argparse.ArgumentParser(description="MCP Server") parser.add_argument( "transport", choices=["stdio", "sse", "streamable-http"], help="Transport mode (stdio, sse or streamable-http)", ) args = parser.parse_args() if "CONFIG_PATH" in os.environ: config_path = os.environ["CONFIG_PATH"] app.load_configuration(config_path) if "CONFIG" in os.environ: config = os.environ["CONFIG"] app.load_configuration_from_string(config) if "SECURITY" in os.environ: security_params = BaseSecurity.parse_security_parameters_from_env( os.environ, ) app.set_security_params(security_params) mcp_settings = json.loads(os.environ.get("MCP_SETTINGS", "{}")) app.get_mcp(**mcp_settings).run(transport=args.transport)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ag2-mcp-servers/open-states-api-v3'

If you have feedback or need assistance with the MCP directory API, please join our Discord server