How I Built a Congress MCP Server
Getting structured data out of Congress.gov has always been tedious. Here is how I built an MCP server that makes it conversational.
By Nicholas Wagner ·
Whether you're a civics teacher, a policy researcher, a journalist tracking legislation, or just a curious citizen, getting structured data out of Congress.gov has always been tedious. I built a Model Context Protocol (MCP) server that lets AI tools like ChatGPT, Claude Code, and others pull legislative data directly from the Congress.gov API using natural language. This includes bills, hearing details, committee activity, CRS reports, and more. A full list of available data can be found at https://api.congress.gov/#/.
Example prompts to try include:
-
"Show me recent Senate hearings on AI regulation."
-
"What CRS reports have been published on immigration in the last few months?"
-
"Who sponsored S. RES. 611?"
If you are not familiar with MCP servers, MCP is a standard for providing instructions to a large language model on how to use a tool like a database or software service. The 'server' part means the tool instructions live at a single URL that any compatible AI model can connect to, rather than being copy-pasted into every conversation. MCP was built to avoid recreating the same boilerplate instructions over and over and instead centralize them at one easy-to-reach place.
Resources used
Here's what I used to build this at a total cost of $135:
-
Claude Code. AI coding agent from Anthropic. Makes it very easy to build software using natural language. I use the Opus model for everything with thinking mode enabled. A Max subscription costs $100/month, but I build lots of apps with it so the additional cost was minimal. https://code.claude.com/docs/en/overview
-
Congress.gov API key. Needed to download data in large quantities from the API. You can get one for free at https://api.congress.gov/sign-up/
-
Congress API code repository. Fed as context to Claude Code. Open source available at https://github.com/LibraryOfCongress/api.congress.gov
-
FastMCP. A standard framework from Prefect for building MCP servers. I also fed the repository as context to Claude Code. https://github.com/jlowin/fastmcp
-
Prefect Horizon. Used to host the MCP server online. $35/month. You can avoid this cost by self-hosting, but I was lazy and wanted to make it easy to share. https://horizon.prefect.io/
-
MCP skill from Anthropic for instructing Claude Code on how to build MCP servers properly. I used this after my initial version had some bugs (see below). https://github.com/anthropics/skills/tree/main/skills/mcp-builder
First attempt and debugging
I began this server by pasting the URLs to the Congress.gov API and FastMCP GitHub repositories into Claude Code and asking it to make an MCP server. Claude spat out something that seemed to work ok.
Unfortunately, when I first shared the server with a group chat, one of the members realized that asking for hearings would result in Claude.ai getting stuck in an infinite loop. When asked what was wrong, Claude recognized that it was supposed to modify an API parameter but was unable to. Asking Claude Code to fix this issue directly did not work. It took suggesting the Anthropic MCP building skill along with telling it to build better tests that hit the API directly for the issue to go away.
Known Limitations
A few things to be aware of if you use this tool:
Client-side filtering constraints. Some useful queries run into upstream limitations in the Congress.gov API. For example, when I asked to find all bills from the current Congress that touched on data centers, I discovered there is no way to filter bill summaries by keyword on the Congress.gov server side. That meant paginating through all results (e.g., 3,356 summaries for the 119th Congress at 250 per page, requiring 14 sequential tool calls), parsing the text of each summary client-side, and accumulating matches across pages. This is slow, expensive on the LLM context window, and burns API quota.
Government codebases move slowly. I could generate a pull request to make changes to the API’s codebase, but government code maintainers will have to decide how they want to accept AI-generated code change suggestions, or if they even want to do that at all.
Always verify the output. Any users should be careful and run their own checks before relying fully on the results. LLMs can misinterpret data, and the API itself can have quirks.
Using the MCP yourself
If you want to try this tool, the URL is https://congress-mcp-an.fastmcp.app/mcp. Don't visit the URL directly in your browser, as it won't do anything useful. Instead, follow the instructions below for your platform. The code for the server is open-source and located at https://github.com/nawagner/congress-mcp.
Claude Code
Paste the below command in your terminal:
claude mcp add --scope local --transport http congress-mcp https://congress-mcp-an.fastmcp.app/mcp
Claude.ai
-
Navigate to “Connectors” under your settings.
-
Add a custom connector with the URL above. You do not need to adjust the Advanced settings.
ChatGPT
-
Enable Developer mode. Note that this disables the ChatGPT memory feature.
-
Click “Create app.”
-
Supply the URL and click “Create.”
Other Platforms
Gemini unfortunately does not support integrating custom MCP servers at this time. If you use another platform and need help setting things up, feel free to reach out to me on GitHub or LinkedIn.
Acknowledgments
Thank you to Ashley Nagel for inspiring me to try building this. Her complaining about the lack of a free MCP server for the Congress.gov API inspired me to see what was possible.
This post was originally published on Learning Journey, our Substack. Subscribe there for new posts on AI and society.