Python SDK, MCP server, and CLI for Australian heavy vehicle compliance data.
nhvrcontrib-tools gives you quick access to fatigue rules, mass limits, dimension limits, Chain of Responsibility duties, accreditation guidance, permits, breach categories, and NHVR registration lookups.
This project is an independent community contribution. It is not published, operated, or endorsed by the NHVR.
HVNL reform note: ministers approved the final amended HVNL package in May 2026 and it commences on 1 August 2026 (see the NHVR's HVNL reform implementation page). From that date NHVAS is progressively replaced by the Heavy Vehicle Accreditation (HVA) scheme, new BFM/AFM applications are replaced by Alternative Compliance Hours (ACH), and General Mass Limits rise to current CML levels. Until commencement, the pre-amendment rules summarised by this package remain in force; affected responses carry a
reform_notefield.
The upcoming v0.4.0 release uses:
- Distribution name:
nhvrcontrib-tools - Python import path:
nhvrcontrib - CLI commands:
nhvr,nhvr-setup
Choose the smallest install that matches your use case:
| Use case | Install command | First command to try |
|---|---|---|
| Python SDK | pip install nhvrcontrib-tools |
python -c "from nhvrcontrib import NHVR; print(NHVR().fatigue_rules()['summary'])" |
| CLI | pip install "nhvrcontrib-tools[cli]" |
nhvr fatigue rules |
| Claude Desktop / MCP | pip install "nhvrcontrib-tools[mcp]" |
nhvr-setup |
| Live NHVR page scraping | pip install "nhvrcontrib-tools[scraper]" |
playwright install chromium |
| Everything | pip install "nhvrcontrib-tools[all]" |
nhvr --help |
Playwright is optional. Base imports, SDK usage, CLI help, CLI knowledge commands, and MCP server startup work without it.
nhvrcontrib-tools is the package name for the renamed v0.4.0 release. If that release is not yet on PyPI, install from source or from a local wheel.
git clone https://github.com/MBemera/nhvrcontrib-tools.git
cd nhvrcontrib-tools
pip install -e ".[dev]"For a smaller source install:
pip install -e .
pip install -e ".[cli]"
pip install -e ".[mcp]"python -m build
pip install dist/nhvrcontrib_tools-0.4.0-py3-none-any.whlpip install "nhvrcontrib-tools[scraper]"
playwright install chromiumIf Playwright is missing, scraper-specific commands return a readable install hint instead of crashing.
pip install "nhvrcontrib-tools[mcp]"
nhvr-setupnhvr-setup checks the MCP dependency, offers optional Playwright guidance, stores the NHVR API key in your machine credential manager, writes the Claude Desktop config, and verifies that the server imports correctly.
Useful setup commands:
nhvr-setup --help
nhvr-setup --print-config
nhvr-setup --yes --api-key "your-nhvr-api-key"nhvr-setup is safe in non-interactive shells. If there is no stdin, it prints the config snippet instead of crashing or silently overwriting files.
Every response is annotated so you can see where the content came from:
- Built-in knowledge tools return cached summaries that include
source_title,source_url,last_verified, andsource_type: static_knowledge. Markdown responses render aSource:footer with the verification date. - Where a reliable HVNL anchor exists (for example, Chain of Responsibility primary duty at
sec.26C), responses include asection_referenceand adeep_link_urlinto the Queensland legislation view of the HVNL. Markdown output prefers the deep link. - Live
nhvr_search_regulationsandnhvr_scrape_pageresponses includesource_type: live_scrapeand ascraped_atUTC timestamp so callers can tell when the page was fetched. - When live scraping fails, the search tool returns a static fallback clearly flagged with
source_type: static_fallbackand afallback_reason, and still surfaces the underlying provenance.
Treat cached responses as a quick orientation layer. Always verify operational, safety, or legal decisions against the current official NHVR and HVNL sources linked in the footer.
The built-in knowledge tools return cached summaries with provenance footers:
nhvr_get_fatigue_rulesnhvr_get_mass_limitsnhvr_get_dimension_limitsnhvr_get_breach_categoriesnhvr_get_speed_limitsnhvr_get_cor_dutiesnhvr_get_accreditation_infonhvr_get_permit_typesnhvr_get_hml_info
The live-access tools depend on current NHVR systems or live web content:
nhvr_search_vehicle_registrationnhvr_search_regulationsnhvr_scrape_page
Access to the live endpoints should stay within the audience and use case your NHVR API key or operational approval was issued for. The registration endpoint is monitored and is intended for operator fleet management, not bulk extracts.
Claude Desktop config paths:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Use the same Python interpreter that has nhvrcontrib-tools[mcp] installed:
{
"mcpServers": {
"nhvrcontrib-tools": {
"command": "python3",
"args": ["-m", "nhvrcontrib.server"]
}
}
}Desktop registration lookups read the API key from the machine credential manager. For CI, Docker, or other non-desktop environments, keep using NHVR_API_KEY.
# stdio transport
python -m nhvrcontrib.server
# HTTP transport
NHVR_MCP_TRANSPORT=streamable_http \
NHVR_MCP_HOST=0.0.0.0 \
NHVR_MCP_PORT=8080 \
python -m nhvrcontrib.server| Tool | Description |
|---|---|
nhvr_get_fatigue_rules |
Work and rest hour requirements by scheme |
nhvr_get_mass_limits |
General and HML mass limits |
nhvr_get_dimension_limits |
Vehicle dimension limits |
nhvr_get_breach_categories |
Breach severity categories |
nhvr_get_speed_limits |
Speed limits and speed limiter rules |
nhvr_get_cor_duties |
Chain of Responsibility duties |
nhvr_get_accreditation_info |
NHVAS and HVA guidance |
nhvr_get_permit_types |
Access permit types |
nhvr_get_hml_info |
Higher Mass Limits guidance |
nhvr_search_vehicle_registration |
Vehicle registration lookup. Monitored by NHVR. Intended for operator fleet management, not bulk extracts. |
nhvr_search_regulations |
Natural-language topic search with fallback suggestions |
nhvr_scrape_page |
Scrape a specific nhvr.gov.au page |
Install:
pip install "nhvrcontrib-tools[cli]"Common commands:
nhvr fatigue rules
nhvr fatigue rules --scheme bfm
nhvr mass limits --include-hml
nhvr mass hml
nhvr dimension limits
nhvr breach categories --type mass
nhvr cor duties --role operator
nhvr accreditation --module fatigue
nhvr permits --type oversize
nhvr rego ABC123
nhvr search "rest breaks"
nhvr --format json fatigue rulesSearch uses aliases and lightweight fuzzy matching. Queries like bfm, afm, rest breaks, b-double mass, loader duty, executive due diligence, speed limiter, and oversize permits resolve more reliably than plain substring matching. If there is no strong match, the CLI suggests likely topics instead of returning a dead end.
Static markdown responses end with a source footer, source type, section reference where available, and verification date. Live search and scrape responses add a scrape timestamp and a source-type line. JSON responses include the same provenance fields structurally.
from nhvrcontrib import NHVR
client = NHVR()
fatigue = client.fatigue_rules("bfm")
mass = client.mass_limits(include_hml=True)
dimensions = client.dimension_limits()
cor = client.cor_duties("operator")
permits = client.permit_types("oversize")Async methods:
import asyncio
from nhvrcontrib import NHVR
client = NHVR()
rego = asyncio.run(client.search_registration("ABC123"))
search = asyncio.run(client.search("b-double mass"))
page = asyncio.run(client.scrape("https://www.nhvr.gov.au/road-access/mass-and-dimension/mass-limits"))search_registration() resolves credentials in this order:
api_key=passed toNHVR(...)NHVR_API_KEYenvironment variable- System credential manager entry created by
nhvr-setup
The default image runs the MCP server with the mcp extra installed. It is intended for MCP clients, not for interactive CLI use.
Build the image:
docker build -t nhvrcontrib-tools .Use stdio mode when the container is attached directly to an MCP client process:
docker run --rm -i nhvrcontrib-toolsdocker run --rm \
-p 8080:8080 \
-e NHVR_MCP_TRANSPORT=streamable_http \
-e NHVR_MCP_HOST=0.0.0.0 \
-e NHVR_MCP_PORT=8080 \
nhvrcontrib-toolsThen connect your MCP-capable client to port 8080.
| Variable | Purpose | Default |
|---|---|---|
NHVR_MCP_TRANSPORT |
MCP transport mode: stdio or streamable_http |
stdio |
NHVR_MCP_HOST |
HTTP bind host | 0.0.0.0 |
NHVR_MCP_PORT |
HTTP port | 8080 |
NHVR_API_KEY |
Enables registration lookups in Docker and CI | unset |
The default image does not install Playwright. That keeps the container smaller and allows MCP startup without browser dependencies. Scraper-specific operations return a clear install hint instead of crashing.
If you need live NHVR scraping inside Docker, extend the image with:
pip install "nhvrcontrib-tools[scraper]"
playwright install chromiumYou may also need the extra Playwright system packages required by your base image.
That usually means the command ran without interactive stdin. Run nhvr-setup in a normal terminal, or use nhvr-setup --yes to accept default prompts explicitly.
Install the MCP extra:
pip install "nhvrcontrib-tools[mcp]"Install scraper support and the browser:
pip install "nhvrcontrib-tools[scraper]"
playwright install chromiumFor Docker, CI, or shell usage:
export NHVR_API_KEY="your-key"For desktop usage:
nhvr-setup --api-key "your-key"Or pass it directly in code:
from nhvrcontrib import NHVR
client = NHVR(api_key="your-key")Use one of the suggested topics, or scrape a specific NHVR page directly:
nhvr scrape "https://www.nhvr.gov.au/road-access/access-permits"Install the dev environment:
pip install -e ".[dev]"Run the local checks:
ruff check .
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline
pytest
python -m build
python -m twine check dist/*Built-in knowledge is based on official NHVR and HVNL material, including:
- NHVR website
- Heavy Vehicle National Law and regulations
- Queensland legislation view of the HVNL
- NHVR developer portal
This repository remains unofficial. Always verify operational and legal requirements against current official sources.
MIT