loading…
Search for a command to run...
loading…
an api wrapper for the us government info api
an api wrapper for the us government info api
A Model Context Protocol (MCP) server and REST API wrapper for accessing the GovInfo API. This tool provides easy access to government documents, bills, regulations, and related information through both MCP protocol and HTTP REST endpoints.
The government api is located here https://api.govinfo.gov/docs/
This is not the govenments mcp they have their own here https://github.com/usgpo/api/blob/main/docs/mcp.md
I wanted one that exposes all of the apis endpoints for deep research.
I highly suggest understanding the data structures before making promts. The mcp handels the api limits for you but it should be as targeted as possible.
Create a .env file in the project root:
GOV_API_KEY=your_api_key_here
pip install -r requirements.txt
python api_server.py
Server runs on: http://127.0.0.1:8030
Swagger Docs: http://127.0.0.1:8030/docs
python gov.api.mcp.py
In terminal 1:
python gov.api.mcp.py
In terminal 2:
python api_server.py
Endpoint: POST /search
Parameters (query parameters or form data):
query (required): Search query (e.g., "congress bills")offsetMark (optional): Pagination marker (default: "*")sort (optional): Sort field (publishDate, lastModified, title)collection (optional): Collection list to search (BILLS, CFR, FR, etc.)historical (optional): Include historical documents (true/false, default: false)pageSize (optional): Results per page (default: 10)Example:
curl -X POST "http://127.0.0.1:8030/search?query=border+security&collection=BILLS&pageSize=50"
Endpoint: POST /search_synthesis
Description: 🎯 Synthesize search results into a concise summary with AI analysis
Parameters (JSON body):
search_query (required): Search query for synthesiscommittees (optional): List of collection codes (e.g., ["BILLS", "FR"])Examples:
# Immigration search with specific collections
curl -X POST "http://127.0.0.1:8030/search_synthesis" \
-H "Content-Type: application/json" \
-d '{"search_query": "immigration policy", "committees": ["BILLS", "FR"]}'
# Healthcare search with auto-detection
curl -X POST "http://127.0.0.1:8030/search_synthesis" \
-H "Content-Type: application/json" \
-d '{"search_query": "healthcare reform"}'
Endpoint: GET /collections
Returns all available GovInfo collections.
Example:
curl "http://127.0.0.1:8030/collections"
Endpoint: GET /collections/{collection_id}/{last_modified}
Parameters:
collection_id: Collection identifier (e.g., USCODE, BILLS)last_modified: Date in YYYY-MM-DD formatpageSize (optional): Results per page (default: 10)offsetMark (optional): Pagination marker (default: "*")congress (optional): Congress number (default: -1)docClass (optional): Document classbillVersion (optional): Bill versioncourtCode (optional): Court codecourtType (optional): Court typestate (optional): Statetopic (optional): TopicisGLP (optional): GLP statusnatureSuitCode (optional): Nature of suit codenatureSuit (optional): Nature of suitExample:
curl "http://127.0.0.1:8030/collections/USCODE/2025-01-01?pageSize=20&congress=118"
Endpoint: GET /collections/{collection_id}/{start_date}/{end_date}
Parameters:
collection_id: Collection identifierstart_date: Start date (YYYY-MM-DD)end_date: End date (YYYY-MM-DD)pageSize (optional): Results per page (default: 10)offsetMark (optional): Pagination marker (default: "*")congress, docClass, billVersion, courtCode, courtType, state, topic, isGLP, natureSuitCode, natureSuitExample:
curl "http://127.0.0.1:8030/collections/BILLS/2024-01-01/2024-12-31?pageSize=50"
Endpoint: GET /package/{package_id}/summary
Get detailed metadata for a specific package.
Example:
curl "http://127.0.0.1:8030/package/BILLS-118hr123ih/summary"
Endpoint: GET /package/{package_id}/granules
Get all granules (sub-documents) for a package.
Parameters:
package_id: Package identifierpageSize (optional): Results per page (default: 10)offsetMark (optional): Pagination marker (default: "*")Example:
curl "http://127.0.0.1:8030/package/BILLS-118hr123ih/granules?pageSize=50"
Endpoint: GET /package/{package_id}/granules/{granule_id}/summary
Get summary for a specific granule within a package.
Parameters:
package_id: Package identifiergranule_id: Granule identifierpageSize (optional): Results per page (default: 10)Example:
curl "http://127.0.0.1:8030/package/BILLS-118hr123ih/granules/BILLS-118hr123ih-1/summary"
Endpoint: GET /published/{start_date}
Get documents published on or after a specific date.
Parameters:
start_date: Date in YYYY-MM-DD formatcollection (required): Collection identifierpageSize (optional): Results per page (default: 10)offsetMark (optional): Pagination marker (default: "*")Example:
curl "http://127.0.0.1:8030/published/2025-01-01?collection=BILLS&pageSize=100"
Endpoint: GET /published/{start_date}/{end_date}
Get documents published within a date range.
Parameters:
start_date: Start date in YYYY-MM-DD formatend_date: End date in YYYY-MM-DD formatcollection (required): Collection identifierpageSize (optional): Results per page (default: 10)offsetMark (optional): Pagination marker (default: "*")Example:
curl "http://127.0.0.1:8030/published/2024-01-01/2024-12-31?collection=FR&pageSize=50"
Endpoint: GET /related/{access_id}
Find documents related to a specific access ID.
Example:
curl "http://127.0.0.1:8030/related/BILLS-118hr123ih"
Endpoint: GET /related/{access_id}/{collection_id}
Find related documents within a specific collection.
Example:
curl "http://127.0.0.1:8030/related/BILLS-118hr123ih/USCODE"
{API_KEY} with your actual key (handled automatically by the server){"error": "API limit reached"} when limit is exceededError: "API key not found"
Solution: Create a .env file with GOV_API_KEY=your_key_here
Issue: Using collection names instead of document IDs Solution: Use valid IDs (e.g., BILLS-118hr123ih, not USCODE for related documents)
Issue: Incorrect date format Solution: Use YYYY-MM-DD format for dates
Issue: Valid request but no matching results Solution: Try different search parameters or date ranges
gov.api.mcp.py - FastMCP Server
api_server.py - FastAPI Server
/docsHTTP Request → api_server.py → MCP Tool Functions → GovInfo API
↓
JSON Response
Common GovInfo collections:
curl -X POST "http://127.0.0.1:8030/search?query=energy+efficiency&collection=BILLS&sort=publishDate&pageSize=50"
curl "http://127.0.0.1:8030/published/2024-12-01?collection=FR&pageSize=200"
curl "http://127.0.0.1:8030/published/2025-01-01?collection=CFR"
curl -X POST "http://127.0.0.1:8030/search_synthesis" \
-H "Content-Type: application/json" \
-d '{"search_query": "immigration reform legislation", "committees": ["BILLS", "CREC"]}'
For issues with the GovInfo API itself, see api.govinfo.gov
For questions about this wrapper, check the code comments or submit an issue.
This project wraps the publicly accessible GovInfo API provided by the U.S. Government.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"gov-info-api": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.