get_congress
Retrieve detailed information about US Congress sessions, including legislation and activities, directly from the official Congress.gov API.
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 | ||
| limit | No | ||
| offset | No |
Implementation Reference
- server.py:227-268 (handler)The handler function for the 'get_congress' MCP tool. It is decorated with @mcp.tool() for registration and implements the core logic to query the Congress.gov API for congress information, handling pagination and optional specific congress filtering.@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) }