Skip to content

feat: add Bills API tools (search_bills, get_bill_stages)#40

Open
MarkDunne wants to merge 2 commits into
mainfrom
feat/bills-api-tools
Open

feat: add Bills API tools (search_bills, get_bill_stages)#40
MarkDunne wants to merge 2 commits into
mainfrom
feat/bills-api-tools

Conversation

@MarkDunne
Copy link
Copy Markdown
Collaborator

Summary

  • Adds search_bills tool — search bills by title, house, and status; returns current stage with sitting dates and sponsors
  • Adds get_bill_stages tool — get the full legislative history of a bill (all readings, committee stages, royal assent) with dates
  • Adds request_bills_api utility in utils.py following the existing request_members_api pattern

Motivation

A production user asked "when is the second reading for Preet Gill's Private Member's Bill?" and the model answered from training data (March 2025) instead of the correct date (17 April 2026). No bill-tracking tools existed, so the model had no way to look up live bill status.

Response shaping

Responses are carefully trimmed to balance LLM context:

Kept: billId, title, URL, current house, stage description, sitting dates, sponsor name/party/constituency, isAct/isDefeated status

Stripped: Internal IDs (stageId, sessionId, billStageId), lastUpdate, billTypeId, session IDs, member photos/page URLs, sortOrder, promoters/agent/petitioning fields

Example output

// search_bills(SearchTerm="Public Body Ethnicity Data")
[{
  "billId": 3901,
  "title": "Public Body Ethnicity Data (Inclusion of Jewish and Sikh Categories) Bill",
  "url": "https://bills.parliament.uk/bills/3901",
  "currentHouse": "Commons",
  "currentStage": { "stage": "2nd reading", "abbreviation": "2R", "house": "Commons", "dates": ["2026-04-17"] }
}]

Test plan

  • Manual end-to-end test: search_bills and get_bill_stages return correct data for known bills
  • Lint passes (ruff check)
  • Verify tools are available via MCP client in dev

🤖 Generated with Claude Code

MarkDunne and others added 2 commits March 30, 2026 20:39
Add two new MCP tools wrapping the UK Parliament Bills API:

- search_bills: Search bills by title, house, and status. Returns
  bill title, current stage with sitting dates, sponsors, and a
  link to bills.parliament.uk.
- get_bill_stages: Get the full legislative history of a bill with
  all stages and dates in order.

Responses are shaped to give the LLM enough context (title, stage,
dates, sponsors) without the noise (internal IDs, session metadata,
photo URLs). Follows the same patterns as existing member/committee
tools.

Motivated by a production incident where the model answered a bill
scheduling question from training data instead of live data, giving
a date that was months out of date.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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