Skip to main content
Glama
@betanyc/nys-openlegislation-mcp

@betanyc/nys-openlegislation-mcp

@betanyc/nys-openlegislation-mcp

An MCP server for the NYS Open Legislation API, maintained by the New York State Senate. Gives AI assistants direct access to the full NYS legislative record — bills, laws, members, committees, calendars, agendas, and transcripts — covering 150,000+ bills and resolutions dating back to 2009.

Built by BetaNYC as part of a suite of civic data MCP servers for New York.

What's changed: new tools, corrections and other changes a reader would notice, newest first. Developer detail is in CHANGELOG.md.


What it covers

Resource

Tools

Bills

Search, get by print number, list by session, get votes, track updates

Laws

List all law bodies, browse law trees, retrieve section text

Members

List and search Senate and Assembly members

Committees

List committees, get details and meeting history

Floor Calendars

List and get Senate floor calendars

Agendas

List and get committee agendas with vote records

Transcripts

Floor session and public hearing transcripts

Updates

Aggregate change feed across all content types

Search

Full-text ElasticSearch within a content type (bills, laws, agendas, calendars, transcripts, hearings)

About this server

What changed in it, who built it, and where its data comes from


Related MCP server: Lawmesh MCP Server

API key

A free API key is strongly recommended, and required for live data. Get one from the NYS Open Legislation portal and set it as the NYS_LEGISLATION_API_KEY environment variable:

  1. Register at legislation.nysenate.gov/public

  2. You'll receive an API key by email

  3. Set it as NYS_LEGISLATION_API_KEY (e.g. export NYS_LEGISLATION_API_KEY="your-api-key"), or pass it in your MCP client's env block — see Installation

Without a key, the server still starts as long as a local corpus exists, and serves it in local-only mode. Results are labelled with the corpus sync date and a note saying what refreshes them. The 5 tools with no local coverage (get_bill_votes, get_bill_updates, get_committee_meetings, get_updates, search) return a message naming the key rather than failing opaquely, and a lookup that finds nothing in the corpus says so explicitly — offline, "not in the corpus" and "does not exist" are not the same claim.

The server refuses to start only when both the key and the corpus are missing.

Bill URLs returned by this server point to the public nysenate.gov website — no login required.

How the server talks to the API. The key is read only from NYS_LEGISLATION_API_KEY. The API accepts it only as the key query parameter, so it is part of each request URL; the server removes it from every error message it returns. Requests follow the API's rate-limit guidance (limits per key from December 1, 2026): one request at a time, at least 0.1 seconds apart; a 30-second timeout, with no resend of a slow request; at most two retries, only after HTTP 429 or 503, waiting at least as long as Retry-After asks. Each request sends a User-Agent naming this package and its version. The server never polls in the background. Errors are a plain sentence saying what went wrong and what to try, with at most 500 characters of the API's own reply (src/http.ts, src/handlers.ts).


Installation

Requires Node.js 20 or newer.

No global install needed. Add to your Claude Desktop config and npx handles the rest.

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "nys-openlegislation": {
      "command": "npx",
      "args": ["-y", "@betanyc/nys-openlegislation-mcp"],
      "env": {
        "NYS_LEGISLATION_API_KEY": "your-api-key-here"
      }
    }
  }
}

Restart Claude Desktop. The server starts automatically.

Global install

npm install -g @betanyc/nys-openlegislation-mcp

Then in your MCP config:

{
  "mcpServers": {
    "nys-openlegislation": {
      "command": "nys-openlegislation-mcp",
      "env": {
        "NYS_LEGISLATION_API_KEY": "your-api-key-here"
      }
    }
  }
}

Local corpus (optional)

By default the server queries the live NYS Open Legislation API on every request. If you run large workloads — bulk research, repeated searches, or offline use — you can build a local SQLite corpus that the server queries first, falling back to the API only on a cache miss.

The corpus is also what makes the server usable without an API key: with a corpus present and no key, it starts in local-only mode instead of exiting. Building the corpus in the first place does require a key (npm run sync calls the live API), so this is a "borrow a colleague's corpus" or "key expired" path, not a way to skip registration entirely. The corpus location defaults to data/corpus.db in the package and can be overridden with NYS_CORPUS_DB.

Requirements

The fetch and sync scripts (scripts/) are not included in the npm package — building a local corpus requires a git clone:

git clone https://github.com/BetaNYC/nys-openlegislation-mcp.git
cd nys-openlegislation-mcp
npm install

better-sqlite3 is an optional dependency. The server works without it — it just means every request goes to the live API. If its native build was skipped, install it explicitly with npm install better-sqlite3.

1. Fetch the initial corpus

NYS_LEGISLATION_API_KEY=your-key node scripts/fetch-data.js

Options:

Flag

Default

Description

--start-year=YYYY

2009

Earliest session year to fetch

--types=bills,laws,...

all types

Comma-separated list: bills,laws,members,committees,agendas,calendars,transcripts

--include-law-text

off

Fetch full text of every law section (large — adds significant download time)

--include-transcript-text

off

Fetch full text of floor and hearing transcripts (very large)

--delay-ms=N

150

Delay between API calls in ms

--dry-run

off

Print what would be fetched without writing

The corpus lands in data/corpus.db (override the location with the NYS_CORPUS_DB environment variable — both the server and the scripts honor it). fetch-data.js saves when it downloaded each type, but only when every item of that type came through: if any law, transcript list or other item fails, that type keeps its earlier date (or none), and the run ends with a non-zero exit code and a line saying how many items failed and the command to run again. A full fetch without law or transcript text takes 2–6 hours depending on your start year and network speed. The --types flag lets you fetch only what you need.

2. Run incremental sync (nightly)

NYS_LEGISLATION_API_KEY=your-key node scripts/sync.js

Options:

Flag

Default

Description

--from=YYYY-MM-DDTHH:MM:SS

last sync time

Override the start, in New York local time (the API's own convention)

--delay-ms=N

150

Delay between API calls in ms

--dry-run

off

Print what would be synced without writing

The Senate's API reads every time as New York local time. Each sync asks for the changes from where the last one ended up to two minutes ago, and saves that end time with its New York offset (for example 2026-11-13T16:58:00-05:00). A copy last synced by a version before 3.0.0 saved UTC times with no zone, which made each sync skip the changes made in the four or five hours after the previous one; the next sync reads such a value as UTC and starts from the right time. To pick up changes an older version missed, run the sync once with --from set to the day you first built the copy. fetch-data.js never moves an existing sync time forward, so a partial load such as --types=committees does not make the next sync skip anything.

Cron example (nightly at 2am):

0 2 * * * NYS_LEGISLATION_API_KEY=your-key node /path/to/scripts/sync.js >> /var/log/nys-sync.log 2>&1

How local-first works

When data/corpus.db exists and better-sqlite3 is available, every tool handler queries the local DB first. If the record is found locally, it returns immediately without an API call, annotated with a source note so staleness is visible: "local corpus (synced <date>)" for bills, agendas and calendars, which the sync refreshes, and the date that type was downloaded for laws, members, committees and transcripts, which it does not (see "Data disclaimer"). If the record is not found — or the local result is empty (0 items) — it falls through to the live API transparently; an empty local slice never shadows live data.

Law section text and transcript full text fall back to the API unless --include-law-text / --include-transcript-text were used during the initial fetch.

Known limitations

  • Committees go stale between full fetches. The incremental sync consumes the aggregate updates feed, which only carries AGENDA / BILL / CALENDAR / LAW content types — committee changes never appear in it. Re-run fetch-data.js --types=committees periodically (it is a quick fetch) to refresh committee data.

  • Laws, members and transcripts are not incrementally synced either; re-run fetch-data.js --types=laws (or members, transcripts) periodically. Since this release fetch-data.js records when it downloaded each type, and answers give that date.

  • Member full names come from bill sponsor records already in the corpus, filled in by npm run sync and fetch-data.js (no extra API calls). A corpus built before this change gains the members.full_name column on its next sync. A member who has never prime-sponsored a bill in the corpus has no full name locally.

  • Local results carry no total. Paginated results served from the local corpus return items and size only; the total, offsetStart, offsetEnd and limit fields come from the live API.


Tools

Every tool rejects parameters it does not declare, rather than ignoring them. Passing an undeclared key returns an error naming both the offending key and the parameters that tool accepts. This is deliberate: silently dropping a filter returns real, correctly-sourced data that answers a different question, and nothing in the response would signal it.

Every tool is marked read-only (readOnlyHint: true); none changes anything. The Open Legislation tools are also marked openWorldHint: true, since they may call the live API; the three tools under "About this server" read only this package's own files.

Bills

Tool

Description

search_bills

Full-text bill search with ElasticSearch syntax, optional session year filter (omit it to search all sessions; all sessions in the local corpus, when it answers)

get_bill

Get a specific bill by print number (e.g. S1234) and session year

list_bills

List bills introduced in a session year

get_bill_votes

Get committee and floor vote records for a bill (the votes block of the bill record)

get_bill_updates

Feed of bill changes within a date range

Laws

Tool

Description

list_laws

List all NYS law bodies (Education Law, Labor Law, etc.)

get_law_tree

Get table of contents for a law body

get_law_section

Get text of a specific law section

Citation links. Law records from get_law_section, and search results of type: "laws", carry a nysenate_url field: a link a person can open on nysenate.gov. It is populated only for SECTION and ARTICLE documents, the two shapes checked in a browser on 2026-08-02 (…/laws/EDN/6233, …/laws/EDN/A125). It is null for every other type, including CHAPTER and TITLE, because their URL shape has not been verified, and a wrong link is worse than none. If the field is populated, use it. If it is null, cite the law and section in plain text. Note that www.nysenate.gov returns 403 to curl, so check a new doc type in a browser before adding it.

Members

Tool

Description

list_members

List Senate or Assembly members for a session year

get_member

Get a specific legislator by member ID; errors if the member sits in the other chamber from chamber

search_members

Search legislators by name; every row carries chamber, and fullName where known (a locally served member who has never prime-sponsored a bill has none). Defaults to the current session. Served from the local corpus when present (works without a key)

Committees

Tool

Description

list_committees

List Senate or Assembly committees

get_committee

Get committee details — chair, schedule, location

get_committee_meetings

Get meeting history and bills considered

Calendars & Agendas

Tool

Description

list_calendars

List Senate floor calendars for a year

get_calendar

Get a specific floor calendar with bill lists

list_agendas

List committee agendas for a year

get_agenda

Get a specific agenda with vote records

Transcripts

Tool

Description

list_floor_transcripts

List Senate floor session transcripts

get_floor_transcript

Get a specific floor session transcript

list_hearing_transcripts

List public hearing transcripts

get_hearing_transcript

Get a specific hearing transcript

Tool

Description

get_updates

Aggregate change feed for a date range. type selects the timestamp the range filters on (processed or published); content_type restricts to bills, agendas, calendars, or laws

search

Full-text search within one content type — bills (default), laws, agendas, calendars, transcripts, hearings. One type per call; the upstream API has no unified search endpoint. Search resolutions via type: "bills".

About this server

Tool

Description

whats_changed

What changed in this server, newest first, from WHATS-CHANGED.md, which ships with the package: new tools and corrections, with what to re-check if you used an old answer. Optional since (YYYY-MM-DD), tag (Site, Data, MCP or Correction) and limit (1 to 50)

about_betanyc

Who built the server (BetaNYC, a project of the Fund for the City of New York), its version and repository, where to report a bug in this server or ask for a new feature, and BetaNYC's links. No parameters

about_data

Where the data comes from, from DATA-SOURCES.json, which ships with the package: the source and its publisher (the New York State Senate), whether it is an official record, how current it is on this server, the terms, where to check a record and where to report an error, and BetaNYC's address for questions, lab@beta.nyc. Optional topic: live (the API), corpus (the local copy), or a tool name

These three need no API key and never call the network. Without a key, about_data says the live API is not available on this server; without a local copy, it says the same for the copy, and with one it gives the copy's last sync time. BetaNYC is adding them to each of its MCP servers; src/betanyc-tools.ts is a copy of the canonical file in BetaNYC's workspace, so never edit the copy.

The same list of sources is published as a DCAT-US 3.0 data catalog, data.json. It is built from DATA-SOURCES.json with python3 scripts/whats_changed.py about-data catalog DATA-SOURCES.json; never edit it by hand. CI checks that it is current, and that every tool has a source.


Example queries

Once connected to Claude Desktop, you can ask:

  • "Find NYS bills about congestion pricing introduced in the 2025 session"

  • "Get the vote record for Senate bill S1234 in the 2025 session"

  • "What committees does the NYS Senate Finance Committee oversee?"

  • "Show me the text of Section 701 of the Education Law"

  • "What NYS legislation changed this week?"

  • "Search for bills sponsored by Krueger about climate"


Session years

NYS legislative sessions run in two-year cycles beginning in odd-numbered years. The current session is 2025 (covering 2025–2026). When no session year is specified, tools default to the current session.


Data disclaimer

Results are sourced from the NYS Open Legislation API, maintained by the New York State Senate. Bill text, status, vote records, and law content reflect official legislative data but may be subject to correction or amendment. Verify critical information at legislation.nysenate.gov.

Every data answer ends with the same few lines: for a list, which results it shows, of how many when the API says, and the offset for the next page; then a source line saying what BetaNYC did to the data (the same answer about_data gives), how current the data is, and the official record: the Open Legislation API of the New York State Senate, with a link to legislation.nysenate.gov; then the caveat above. A live answer reads "BetaNYC modified this data: passed on as the Senate's Open Legislation API returns it, with additions that change no value: … Fetched from the source for this answer at 2026-11-18 13:05 EST (New York time). Official record: …". An answer from the local copy says it is a copy BetaNYC saved and indexed, and that its search and list order are BetaNYC's own. A list from the local copy also says its order is the copy's own (for example, bills newest published first), so its page 1 may not be the Senate's page 1. Local search_bills results carry BetaNYC's match score as betanyc.search_score, never under the Senate's rank. Local search_members keeps the Senate's own fields; it fills a missing chamber or fullName only when the Senate's record lacks it, and names what it filled in betanyc.filled. offset counts from 0 (the number of results to skip) in every tool, live or local. Each list tool has a default limit and a maximum, stated in the description of its limit parameter (for example "Max results (default 100, max 200)"). A larger whole-number limit is lowered to the maximum, and the paging line says so ("limit lowered to 200, the most this tool returns"). A limit under 1, a negative offset, or a number that is not whole is refused with a short message saying what is allowed. A short list from the local copy says it is "all the local copy has", since the copy may lack records the Senate has.

How current is it? A live answer gives the time it was fetched, in New York time. An answer from the local copy gives the date of that kind of data:

  • Bills, agendas and calendars: the nightly sync (scripts/sync.js) keeps these current from the API's updates feed, so the answer gives the time of the last sync.

  • Laws, members, committees and transcripts: the nightly sync does not touch these. They change in the copy only when scripts/fetch-data.js downloads them again, so the answer gives the time that download started (stored per type as fetched_at_<type>), and says the sync does not update them. A copy downloaded before this was recorded has no such date: the answer then says the date is not recorded and that the data comes from the last full download. It never shows the sync time for these, and never guesses a date: not in a data answer, and not in about_data, whose "How current on this server" for the local copy gives the sync time for bills, agendas and calendars only and each other type's own download date, or "not recorded". Re-running fetch-data.js --types=<type> records it.


Tests

Two suites, split so that network access is a deliberate choice rather than a side effect of your environment.

npm test        # offline, always — safe to run reflexively
npm run test:live   # real calls to the NYS Open Legislation API; needs a key

npm test covers everything under test/. It never touches the network, regardless of whether NYS_LEGISLATION_API_KEY is set — that is enforced by a directory boundary (test/live/ is outside the default glob) and guarded by test/offline-by-default.test.js.

npm run test:live runs the smoke tests in test/live/, which make one read-only GET per searchable type. Without a key it fails with setup instructions rather than skipping, because reaching it means you asked for it.

npm run eval runs the evaluation set in eval/questions.json: 12 questions a person would ask (who sponsored a bill, how a member voted, the second page of a listing, which link to cite for a law article), each with a known answer, written before scoring. It runs offline: each answer comes from a fixture copied from the example responses in the API's own documentation, so it checks that each tool sends the documented request path and parameters, passes through the fields the question asks about (a sponsor, a status, a vote) from the fixture, and ends with the right paging line and source line, and that bad requests fail with the right error. It does not check a fact against the live service, and it does not test a model's choice of tool. Results go to eval/runs/. npm test runs the same set (test/eval.test.js), and test/stdout.test.js checks that the server writes only protocol messages to stdout.

This split exists because the previous arrangement gated the live test on the API key being present, which meant a machine configured to run this server also made live requests on a plain npm test. Having a key is not the same as intending to use it.


Releases

Releases are automated by .github/workflows/release.yml:

  1. Bump version in package.json, package-lock.json and server.json (both version fields) in a PR, with a CHANGELOG.md entry headed ## [X.Y.Z] - Unreleased. For a release that changes what the server returns or which tools it has, add a WHATS-CHANGED.md entry headed ## Unreleased: Title, tagged MCP, whose MCP version line links to CHANGELOG.md with no anchor. CI's What's changed check fails a version bump without one; a metadata-only release instead carries a No-whats-changed: <reason> line in a commit message. Merge to main.

  2. On release day, one commit on main, with the New York date (TZ=America/New_York date +%F):

    • ## Unreleased: Title becomes ## YYYY-MM-DD: Title in WHATS-CHANGED.md. The title must stay the same; the check rejects a changed one.

    • ## [X.Y.Z] - Unreleased becomes ## [X.Y.Z] - YYYY-MM-DD in CHANGELOG.md.

    • The entry's MCP version link gains the new CHANGELOG.md anchor. Compute it, never type it: python3 -c "import sys; sys.path.insert(0, 'scripts'); import whats_changed as w; print(w.github_slug('[X.Y.Z] - YYYY-MM-DD'))" (for [2.6.0] - 2026-11-13 it prints 260---2026-11-13).

    • Check: python3 scripts/whats_changed.py check WHATS-CHANGED.md --release must pass. It is the same gate the workflow runs before npm publish.

  3. Tag that commit v<version> (e.g. git tag v2.6.0 && git push origin v2.6.0).

  4. The workflow runs the test suite, verifies the tag matches package.json, checks that no WHATS-CHANGED.md entry is left Unreleased, publishes to npm with provenance, and creates a GitHub Release with generated notes.

  5. A successful Release triggers .github/workflows/publish-mcp.yml, which lists that version in the official MCP Registry as io.github.BetaNYC/nys-openlegislation-mcp (from server.json; keep its versions in step with package.json).

See CHANGELOG.md for version history. Publishing requires the NPM_TOKEN org secret (an npm token with publish rights to the @betanyc scope).


About BetaNYC

This project is built and maintained by BetaNYC, New York's civic technology and open-data community. We work to improve lives in New York through civic design, technology, data, and public-interest technology.

Come do civic tech with us. We run public events, meetups, and hands-on data classes throughout the year — including NYC School of Data and CityCamp NYC, and we host frequent civic-tech gatherings. See what's coming up on our events calendar.

Sustain this work. These MCP servers are free and open source. To help keep this work going and find BetaNYC's tools, please consider donating and becoming a Beta Builder.

Building on this? Tell us!

If you build something with this project, we'd love to hear about it. We can help other New Yorkers find it. BetaNYC publishes a weekly newsletter, This Week in NYC's Civic Technology and Open Data.

BetaNYC maintains a suite of open-source MCP servers for NYC and NYS civic data. See the full directory, with install details for each, at beta.nyc/ai-tools.

This server pairs directly with:

  • nyc-council-mcp: compare New York State legislation with its New York City legislative counterpart.


Support our work

Freedom isn't free. Support BetaNYC.

License

MIT © BetaNYC

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to access Washington State Legislature data for bill tracking, committee meetings, legislator lookup, and legislative document retrieval via conversational interfaces.
      9
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables searching US state bills by keyword, sponsor, committee, status, or chamber, and searching speaker-attributed committee hearing testimony across all 50 states and DC. Also retrieves full bill details, hearing transcripts, speaker activity histories, and the list of states with available data.
      49 npm
      MIT