Skip to main content

MCP server for searching Canadian Building Codes (NBC, OBC, BCBC, etc.)

Project description

Canadian Building Code MCP Server

A Model Context Protocol (MCP) server that enables Claude to search and navigate Canadian building codes.

What It Does

Ask Claude questions like:

  • "Find fire separation requirements for garages in NBC"
  • "What are the stair width requirements in OBC?"
  • "Show me section 9.10.14 of the Building Code"

Claude will search 20,000+ indexed sections across 13 Canadian building codes and return relevant sections with page numbers.

Supported Codes

Code Version Sections Description
NBC 2025 2,783 National Building Code
NFC 2025 1,044 National Fire Code
NPC 2025 413 National Plumbing Code
NECB 2025 475 National Energy Code for Buildings
OBC 2024 4,108 Ontario Building Code (Vol 1 & 2)
BCBC 2024 2,584 British Columbia Building Code
ABC 2023 2,832 Alberta Building Code
QCC 2020 2,726 Quebec Construction Code
QECB 2020 384 Quebec Energy Code
QPC 2020 428 Quebec Plumbing Code
QSC 2020 1,063 Quebec Safety Code (Fire)
OFC O. Reg. 213/07 1,906 Ontario Fire Code

Installation

Option A: pip install (Recommended)

# Basic installation
pip install git+https://github.com/DavidCho1999/Canada-AEC-Code-MCP.git

# With PDF text extraction support
pip install "git+https://github.com/DavidCho1999/Canada-AEC-Code-MCP.git#egg=building-code-mcp[pdf]"

Option B: Clone and install

git clone https://github.com/DavidCho1999/Canada-AEC-Code-MCP.git
cd Canada-AEC-Code-MCP
pip install -e .          # Basic
pip install -e ".[pdf]"   # With PDF support

Configure Claude Desktop

Find your Claude Desktop config file:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json

Add this to the config file:

{
  "mcpServers": {
    "building-code": {
      "command": "building-code-mcp"
    }
  }
}

Or if using the cloned repository:

{
  "mcpServers": {
    "building-code": {
      "command": "python",
      "args": ["C:/full/path/to/Canada-AEC-Code-MCP/src/mcp_server.py"]
    }
  }
}

Restart Claude Desktop

Close and reopen Claude Desktop. You should see "building-code" in the MCP tools.

Usage Examples

Once installed, just ask Claude naturally:

"Search for egress requirements in NBC"
"What does section 3.2.4.1 say in OBC?"
"Find fire resistance ratings for walls"
"List all available building codes"

Available Tools

Tool Description
list_codes List all available codes and section counts
search_code Search by keywords (e.g., "fire separation")
get_section Get specific section by ID (e.g., "9.10.14.1")
get_hierarchy Get parent, children, siblings of a section
set_pdf_path Connect your PDF for full text extraction (BYOD)

How It Works

Mode A: Map Only (Default)

Returns section metadata: ID, title, page number, keywords. Works without any PDF files.

Mode B: BYOD (Bring Your Own Document)

Connect your legally obtained PDF to get full text:

"Connect my NBC PDF at C:/codes/NBC2025.pdf"

The server extracts text from the exact page and coordinates.

Project Structure

Canada-AEC-Code-MCP/
├── maps/               # 12 code index files (JSON)
├── src/
│   └── mcp_server.py   # MCP server
├── scripts/
│   └── generate_map_v2.py  # Map generation tool
└── README.md

For Developers

Adding New Codes

  1. Convert PDF with Docling:
pip install docling
python scripts/convert_with_docling.py path/to/code.pdf
  1. Generate map:
python scripts/generate_map_v2.py docling_output/code_name/

Disclaimer

This is a structural index for Canadian Building Codes. No copyrighted text is distributed. This is not an official NRC or government product.

Building codes are published by the National Research Council of Canada (NRC) and provincial authorities. Please obtain official copies through proper channels.

Running Tests

# Install test dependencies
pip install pytest

# Run smoke tests
pytest tests/test_smoke.py -v

Troubleshooting

"MCP server not showing in Claude Desktop"

  1. Check the path in config is absolute (not relative)
  2. Make sure Python is in your PATH
  3. Restart Claude Desktop completely

"No results found"

  • Try simpler search terms (e.g., "fire" instead of "fire separation requirements")
  • Check if the code exists: ask Claude "list available codes"

"PDF text extraction not working"

  • Ensure the PDF path is correct and file exists
  • The PDF version must match the map version (e.g., NBC 2025 map needs NBC 2025 PDF)

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Run tests: pytest tests/test_smoke.py -v
  4. Submit a pull request

Changelog

v1.0.0 (2026-01)

  • Initial release with 12 Canadian building codes
  • 18,000+ indexed sections
  • BYOD mode for full text extraction

License

MIT License - See LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

building_code_mcp-1.0.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

building_code_mcp-1.0.1-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file building_code_mcp-1.0.1.tar.gz.

File metadata

  • Download URL: building_code_mcp-1.0.1.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for building_code_mcp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6d17370bd3f870ea9415089278caba90f6bd93df47f7ac1bfba7b4dcaf32e292
MD5 fa402e76deaf31285123a8737336105e
BLAKE2b-256 7222fbc7ffaf0e2d6bfdb104d3f1b05aeebfe491d88b761c4019da1a3277dcf2

See more details on using hashes here.

File details

Details for the file building_code_mcp-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for building_code_mcp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 269fd4368924af64f3e8445c75444349df019af0ea4d79e27a77937e77515629
MD5 a47c6db97b46225ec7c8e6636cb3ec8b
BLAKE2b-256 054354fa5f2cec4a39f58efdbba5de4b615f272f107ee88d46259ab059aedc5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page