Skip to main content
Glama
AshwinSundar

Congress[.]gov MCP Server

by AshwinSundar

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

TableJSON Schema
NameRequiredDescriptionDefault
congressNo
offsetNo
limitNo

Implementation Reference

  • 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()

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