get_house_votes
Retrieve detailed House vote data from the official Congress.gov API to analyze legislative decisions and track voting records by congress, session, and roll call number.
Instructions
Retrieve House vote information from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/HouseRollCallVoteEndpoint.md
Args: congress: Congress number (e.g., 118 for 118th Congress) session: Session number (1 or 2) roll_call_number: Specific roll call vote number 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)
Returns: dict: House vote data from Congress.gov API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| congress | No | ||
| session | No | ||
| roll_call_number | No | ||
| offset | No | ||
| limit | No | ||
| from_datetime | No | ||
| to_datetime | No |
Implementation Reference
- server.py:324-380 (handler)The handler function for the 'get_house_votes' MCP tool. It is decorated with @mcp.tool() for registration and implements the logic to fetch House roll call vote data from the Congress.gov API using requests, handling parameters for filtering and pagination, with error handling for API requests.@mcp.tool() async def get_house_votes( congress: int | None = None, session: int | None = None, roll_call_number: int | None = None, offset: int = 0, limit: int = 20, from_datetime: str | None = None, to_datetime: str | None = None ) -> dict: """ Retrieve House vote information from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/HouseRollCallVoteEndpoint.md Args: congress: Congress number (e.g., 118 for 118th Congress) session: Session number (1 or 2) roll_call_number: Specific roll call vote number 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) Returns: dict: House vote data from Congress.gov API """ base_url = "https://api.congress.gov/v3/house-vote" url = base_url if congress: url += f"/{congress}" if session: url += f"/{session}" if roll_call_number: url += f"/{roll_call_number}" params = { "api_key": congress_gov_api_key, "format": "json", "offset": offset, "limit": min(limit, 250) # API max limit for house votes } if from_datetime: params["fromDateTime"] = from_datetime if to_datetime: params["toDateTime"] = to_datetime 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 house vote information: {str(e)}", "status_code": getattr(e.response, "status_code", None) }