get_amendments
Retrieve specific amendments from Congress.gov by filtering congress number, amendment type, amendment number, or date range to access legislative amendment data.
Instructions
Retrieve amendments from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/AmendmentEndpoint.md
Args: congress: Congress number (e.g., 118 for 118th Congress) amendment_type: Type of amendment - hamdt: House Amendment - samdt: Senate Amendment - suamdt: Senate Unprinted Amendment amendment_number: Specific amendment number (requires congress and amendment_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)
Returns: dict: Amendment data from Congress.gov API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amendment_number | No | ||
| amendment_type | No | ||
| congress | No | ||
| from_datetime | No | ||
| limit | No | ||
| offset | No | ||
| to_datetime | No |
Implementation Reference
- server.py:99-159 (handler)The core handler function for the 'get_amendments' MCP tool. Defined with @mcp.tool() decorator which handles registration. It constructs a request to the Congress.gov API /v3/amendment endpoint using provided parameters (congress, amendment_type, etc.), fetches the data with authentication, and returns the JSON response or an error dict.@mcp.tool() async def get_amendments( congress: int | None = None, amendment_type: str | None = None, amendment_number: int | None = None, offset: int = 0, limit: int = 20, from_datetime: str | None = None, to_datetime: str | None = None ) -> dict: """ Retrieve amendments from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/AmendmentEndpoint.md Args: congress: Congress number (e.g., 118 for 118th Congress) amendment_type: Type of amendment - hamdt: House Amendment - samdt: Senate Amendment - suamdt: Senate Unprinted Amendment amendment_number: Specific amendment number (requires congress and amendment_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) Returns: dict: Amendment data from Congress.gov API """ base_url = "https://api.congress.gov/v3/amendment" url = base_url if congress: url += f"/{congress}" if amendment_type: url += f"/{amendment_type}" if amendment_number: url += f"/{amendment_number}" params = { "api_key": congress_gov_api_key, "format": "json", "offset": offset, "limit": min(limit, 250) # API max limit for amendments } 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 amendments: {str(e)}", "status_code": getattr(e.response, "status_code", None) }