Skip to main content
Glama
AshwinSundar

Congress[.]gov MCP Server

by AshwinSundar

get_bills

Retrieve U.S. congressional bills by congress, type, number, or date range to access legislative information directly from Congress.gov.

Instructions

Retrieve a list of bills. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/BillEndpoint.md

Args: congress: Congress number (e.g., 118 for 118th Congress) bill_type: Type of bill - hr: House of Representatives Bill - s: Senate Bill - hjres: House Joint Resolution - sjres: Senate Joint Resolution - hconres: House Concurrent Resolution - sconres: Senate Concurrent Resolution - hres: House Simple Resolution - sres: Senate Simple Resolution bill_number: Specific bill number (requires congress and bill_type) offset: Starting record (default 0) limit: Maximum records to return (max 250, default 20) from_datetime: Start timestamp (YYYY-MM-DDTHH:MM:SSZ format) to_datetime: End timestamp (YYYY-MM-DDTHH:MM:SSZ format) sort: Sort order ('updateDate+asc' or 'updateDate+desc')

Returns: dict: Bill data from Congress.gov API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
congressNo
bill_typeNo
bill_numberNo
offsetNo
limitNo
from_datetimeNo
to_datetimeNo
sortNoupdateDate+desc

Implementation Reference

  • server.py:28-97 (handler)
    The primary handler for the 'get_bills' tool. Decorated with @mcp.tool() for registration in FastMCP. Implements logic to query Congress.gov API for bills using provided parameters, handles URL construction, request parameters, and error handling.
    @mcp.tool()
    async def get_bills(
        congress: int | None = None,
        bill_type: str | None = None,
        bill_number: int | None = None,
        offset: int = 0,
        limit: int = 20,
        from_datetime: str | None = None,
        to_datetime: str | None = None,
        sort: str = "updateDate+desc"
    ) -> dict:
        """
        Retrieve a list of bills. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/BillEndpoint.md
    
        Args:
            congress: Congress number (e.g., 118 for 118th Congress)
            bill_type: Type of bill
                - hr: House of Representatives Bill
                - s: Senate Bill
                - hjres: House Joint Resolution
                - sjres: Senate Joint Resolution
                - hconres: House Concurrent Resolution
                - sconres: Senate Concurrent Resolution
                - hres: House Simple Resolution
                - sres: Senate Simple Resolution
            bill_number: Specific bill number (requires congress and bill_type)
            offset: Starting record (default 0)
            limit: Maximum records to return (max 250, default 20)
            from_datetime: Start timestamp (YYYY-MM-DDTHH:MM:SSZ format)
            to_datetime: End timestamp (YYYY-MM-DDTHH:MM:SSZ format)
            sort: Sort order ('updateDate+asc' or 'updateDate+desc')
    
        Returns:
            dict: Bill data from Congress.gov API
        """
        base_url = "https://api.congress.gov/v3/bill"
    
        url = base_url
        if congress:
            url += f"/{congress}"
            if bill_type:
                url += f"/{bill_type}"
                if bill_number:
                    url += f"/{bill_number}"
    
        params = {
            "api_key": congress_gov_api_key,
            "format": "json",
            "offset": offset,
            "limit": min(limit, 100)  # Enforce API max limit
        }
    
        if from_datetime:
            params["fromDateTime"] = from_datetime
        if to_datetime:
            params["toDateTime"] = to_datetime
        if not bill_number:
            params["sort"] = sort
    
        try:
            response = requests.get(url, params=params)
            response.raise_for_status()
            return response.json()
    
        except requests.exceptions.RequestException as e:
            return {
                "error": f"Failed to retrieve bills: {str(e)}",
                "status_code": getattr(e.response, "status_code", None)
            }
  • server.py:28-28 (registration)
    The @mcp.tool() decorator registers the get_bills function as an MCP tool.
    @mcp.tool()
  • Function signature with type annotations and comprehensive docstring defining input parameters and output for the get_bills tool schema.
    async def get_bills(
        congress: int | None = None,
        bill_type: str | None = None,
        bill_number: int | None = None,
        offset: int = 0,
        limit: int = 20,
        from_datetime: str | None = None,
        to_datetime: str | None = None,
        sort: str = "updateDate+desc"
    ) -> dict:
        """
        Retrieve a list of bills. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/BillEndpoint.md
    
        Args:
            congress: Congress number (e.g., 118 for 118th Congress)
            bill_type: Type of bill
                - hr: House of Representatives Bill
                - s: Senate Bill
                - hjres: House Joint Resolution
                - sjres: Senate Joint Resolution
                - hconres: House Concurrent Resolution
                - sconres: Senate Concurrent Resolution
                - hres: House Simple Resolution
                - sres: Senate Simple Resolution
            bill_number: Specific bill number (requires congress and bill_type)
            offset: Starting record (default 0)
            limit: Maximum records to return (max 250, default 20)
            from_datetime: Start timestamp (YYYY-MM-DDTHH:MM:SSZ format)
            to_datetime: End timestamp (YYYY-MM-DDTHH:MM:SSZ format)
            sort: Sort order ('updateDate+asc' or 'updateDate+desc')
    
        Returns:
            dict: Bill data from Congress.gov API
        """

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/AshwinSundar/congress_gov_mcp'

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