get_congress
Retrieve U.S. Congress information from the official Congress.gov API. Specify a congress number or get all data with pagination controls.
Instructions
Retrieve congress information from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/CongressEndpoint.md
Args: congress: Specific congress number (e.g., 118 for 118th Congress) or None for all offset: Starting record (default 0) limit: Maximum records to return (max 250, default 20)
Returns: dict: Congress data from Congress.gov API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| congress | No | ||
| offset | No | ||
| limit | No |
Implementation Reference
- server.py:227-266 (handler)The handler function decorated with @mcp.tool(), implementing the 'get_congress' tool by querying the Congress.gov API for congress data based on parameters like congress number, offset, and limit.@mcp.tool() async def get_congress( congress: int | None = None, offset: int = 0, limit: int = 20 ) -> dict: """ Retrieve congress information from the Congress.gov API. Full documentation for this endpoint -> https://github.com/LibraryOfCongress/api.congress.gov/blob/main/Documentation/CongressEndpoint.md Args: congress: Specific congress number (e.g., 118 for 118th Congress) or None for all offset: Starting record (default 0) limit: Maximum records to return (max 250, default 20) Returns: dict: Congress data from Congress.gov API """ base_url = "https://api.congress.gov/v3/congress" url = base_url if congress: url += f"/{congress}" params = { "api_key": congress_gov_api_key, "format": "json", "offset": offset, "limit": min(limit, 250) # API max limit for congress } 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 congress information: {str(e)}", "status_code": getattr(e.response, "status_code", None) }
- server.py:227-227 (registration)The @mcp.tool() decorator registers the get_congress function as an MCP tool.@mcp.tool()