Skip to content

Repository files navigation

Victorian Budget 2026-27 Statement of Finances — structured data + MCP server

Extracts every numeric table and the narrative text of the 2026-27 Victorian Budget Paper No. 5 (Statement of Finances, incorporating Quarterly Financial Report No. 3) into SQLite, and serves it as a public read-only MCP server on Cloudflare Workers + D1.

Live MCP endpoint: https://vic-budget-mcp.aicolab.workers.dev/mcp (streamable HTTP; /sse also available for legacy clients)

Connect from Claude Code:

claude mcp add --transport http vic-budget https://vic-budget-mcp.aicolab.workers.dev/mcp

What was extracted

count
Tables (Ch 1–6, Appendix A & B) 199
Table columns 810
Line items (with hierarchy + row types) 4,148
Facts (individual printed values) 14,102
Narrative text chunks (FTS-indexed) 785 (~400k chars)
Charts (metadata; data points where printed) 9

QA: every printed Total … row is recomputed from its component rows — 1,986 / 1,986 checks pass (100%), using rounding tolerance consistent with the paper's "totals are based on unrounded figures" convention.

MCP tools

  • get_overview — schema, conventions, dataset counts (start here)
  • run_sql — read-only SELECT/WITH against the full schema
  • list_tables — filter by chapter / entity / sector / keyword
  • get_table — reconstruct any table by printed number ('4.2', 'B.1', '3.5.1')
  • find_line_item — search line items by label across all tables
  • search_text — FTS5 over the narrative corpus
  • fiscal_aggregates — headline GG-sector aggregates across forward estimates

Schema (SQLite / D1)

Tidy fact model, multi-year ready (keyed by editions):

editions ─┬─ source_tables ─┬─ table_columns   (position, header_label, fy_label, kind)
          │                 └─ line_items      (label, parent_id, level, row_type,
          │                                    note_ref, note_marker, fy_hint)
          │                        └─ facts    (value, value_millions, raw_text)
          ├─ text_chunks (+ text_search FTS5)
          └─ charts ── chart_points

Conventions:

  • value is as printed (parentheses → negative; .. → 0 per the paper's style conventions, with raw_text preserving the printed form).
  • value_millions normalises $thousand/$billion tables; NULL for per-cent rows.
  • row_type: header (section rows), item (leaves), total, derived (Net result, Net lending etc.).
  • Appendix A tables A.5/A.6 print two budget years as bold/italic row pairs; line_items.fy_hint carries '2026-27' (bold) / '2025-26' (italic).
  • source_tables.pages = source PDF pages for provenance.
  • Charts are captured as metadata only unless values are printed on the chart (charts.confidence).

Pipeline (repeatable)

python3.13 -m venv .venv && ./.venv/bin/pip install pymupdf pdfplumber
cd pipeline
../.venv/bin/python inventory.py    # manifest of 199 tables from unit markers
../.venv/bin/python extract.py      # word-coordinate table parser -> staging JSON
../.venv/bin/python qa.py           # recompute all printed totals (must be 100%)
../.venv/bin/python textcorpus.py   # narrative chunks
../.venv/bin/python charts.py       # chart metadata
../.venv/bin/python build_db.py     # -> data/budget.sqlite
../.venv/bin/python export_d1.py    # -> data/d1_schema.sql + d1_data.sql

Deploy:

cd server && npm install
npx wrangler d1 execute vic-budget-2026-27 --remote --file=../data/d1_schema.sql -y
npx wrangler d1 execute vic-budget-2026-27 --remote --file=../data/d1_data.sql -y
npx wrangler deploy

Source

“2026-27 State Budget - Statement of Finances.pdf” (278 pages), Department of Treasury and Finance, State of Victoria, published May 2026, CC BY 4.0.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages