Skip to content

Add a get_bill MCP tool for looking up one bill by number - #2396

Open
rmabualhaija wants to merge 2 commits into
codeforboston:mainfrom
rmabualhaija:2-mcp-get-bill
Open

rmabualhaija wants to merge 2 commits into
codeforboston:mainfrom
rmabualhaija:2-mcp-get-bill

Conversation

@rmabualhaija

@rmabualhaija rmabualhaija commented Nov 26, 2026 •

Copy link
Copy Markdown

Builds on #2395. Until that merges, this PR also shows its commit. To review only this change, see the get_bill diff or commit 33d2621.

Summary

Adds get_bill to the MCP server: look up one bill by its number and get its full record. Every existing tool searches by meaning, so none of them can answer "tell me about H.100". This is the first exact-lookup tool for the Legislator Research Assistant (tracking: rmabualhaija#2), and it sets the response conventions the next ones will reuse.

  • Input: billId, written any common way (H.100, H 100, h100), an optional court (defaults to the current session) and includeFullText (default false).
  • Output: title, docket number, pinslip, primary sponsor, joint sponsor, cosponsors, current committee (with link), committee recommendations, latest action, full history, hearing IDs, next hearing, canonical MAPLE and malegislature.gov links, and when MAPLE last refreshed the bill (asOf, sources[]).
  • Not found: returns { found: false, message }. This applies both to a bill that doesn't exist and to input that isn't a bill number.

Choices worth a look:

  • No status field. The legislature's API has none. latestAction stands in for it, so the tool never states a status the legislature didn't.
  • AI-written fields are kept apart. MAPLE's summary and topic tags are under aiGenerated, labeled, so they aren't mistaken for the official record.
  • Full text is default turned off, and text.length is always given. Some bills, like the budget, run to hundreds of pages.
  • Cosponsors are listed as malegislature.gov lists them, including the primary sponsor, so counts match cosponsorCount.
  • Dates are ISO strings, not Firestore Timestamps (which serialize as {_seconds, _nanoseconds}). The scraper's epoch placeholder for "no hearing" becomes null.
  • The text has no version or date. The legislature's API doesn't provide one, so text.asOf is the last refresh. Detecting struck-and-replaced text is a separate issue.

New helpers in tools.ts (bill-number normalizing, links, dates, JSON results) are written to be reused by the next lookup tools. Existing tools are unchanged.

Checklist

  • On the frontend, I've made my strings translate-able. (No frontend changes.)
  • If I've added shared components, I've added a storybook story. (None.)
  • I've made pages responsive and look good on mobile. (No pages.)
  • If I've added new Firestore queries, I've added any new required indexes to firestore.indexes.json. (A single-document read by path, no index needed.)

Screenshots

N/A. Calling the tool through an MCP client:

tools: search_bills, search_testimony, search_ballot_questions, search_policies, get_bill, list_topics, list_committees, list_sponsors
get_bill inputs: billId, court, includeFullText | required: billId
{ "found": false, "billId": "clean water", "court": 194, "message": "\"clean water\" isn't a bill number. Use a chamber letter and a number, like H.100 or S.2." }

Known issues

  • Not yet run against real Firestore data, since I don't have dev credentials. Test fixtures copy the structure of a real API document (H.100 in the 194th), with invented names.
  • The existing search tools still return raw Firestore Timestamps (nextHearingAt in shapeBill). Left alone here to keep this PR additive, easy follow-up.

Extra Deploy Steps

None beyond the MCP server's usual manual Cloud Run deploy.

Steps to test/reproduce

  1. cd mcp-server && npm ci && npm test: 64 tests pass (27 new).
  2. With dev access, run against real data:
    gcloud auth application-default login
    cd mcp-server
    FIREBASE_PROJECT_ID=digital-testimony-dev DISABLE_AUTH=true npm run start:http
    curl -s -X POST http://localhost:3001/mcp \
      -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
      -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_bill","arguments":{"billId":"H.100"}}}'
  3. Check that the sponsors, history and links match the bill's page on malegislature.gov, and that H.99999 returns found: false.

🤖 Generated with Claude Code

rmabualhaija and others added 2 commits November 26, 2026 12:52
The MCP server installs with npm (its Dockerfile runs `npm ci`), but
package-lock.json is gitignored repo-wide, so a fresh clone couldn't
build the image and each install resolved dependency versions anew.
A fresh install can now pull @firebase/database-compat 2.1.8, which
requires Node >= 24; the committed lockfile pins 2.1.7, which every
locked package's engines allow on both Node 20 (the current image)
and Node 22.

Update the auth tests for the `help` field auth.ts now adds to 401
responses, and add an MCP Server job to Repo Checks that type-checks
and tests mcp-server on Node 22.

The Docker image stays on Node 20 here; moving it to 22 needs its own
deploy test, as in the Node 22 upgrade that left this Dockerfile out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MCP server's tools all search by meaning; none returns a known
bill. get_bill takes the bill number however it's written ("H.100",
"H 100", "h100") and returns the full record: sponsors and cosponsors,
committee and its recommendations, the latest action and full history,
hearings, canonical MAPLE and malegislature.gov links, and when MAPLE
last refreshed the bill.

A missing bill comes back as found: false with a message, not an
error, so callers can say "not found" without guessing. There is no
status field because the legislature's API has none; latestAction
stands in for it. MAPLE's AI summary and topics are kept under
aiGenerated, apart from the legislature's record. Full text is opt-in,
with its length always given, since some bills run to hundreds of
pages. Dates are ISO strings rather than raw Firestore Timestamps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maple-dev Ready Ready Preview Nov 26, 2026 7:06pm UTC

Request Review

@rmabualhaija
rmabualhaija marked this pull request as ready for review November 26, 2026 19:15
@rmabualhaija rmabualhaija changed the title 2 mcp get bill Add a get_bill MCP tool for looking up one bill by number Nov 27, 2026

This branch was successfully deployed

1 active deployment
Preview – maple-dev — 33d2621b Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant