Skip to main content
Glama
construction-safety-inspector

construction-safety-inspector

by iamalii27

# Construction Site Safety Inspector

An LLM-powered system for automated construction site hazard detection and incident analysis.

## Overview

This system analyzes construction site photos and incident PDF reports to detect safety hazards, retrieve similar past accidents from a KOSHA database, and generate professional bilingual safety reports with citations.

Built as a final project for LLM-AE-AI course at Kyung Hee University.

## Features

- Vision Hazard Detection: Claude analyzes site photos and identifies safety violations with severity levels

- PDF Incident Analysis: Extracts and analyzes construction accident report PDFs

- RAG Pipeline: Searches 37 real KOSHA accident cases using hybrid BM25 and VoyageAI search

- Tool Use: classify_hazard() function assigns hazard type and KOSHA regulation codes

- Bilingual Reports: Professional safety reports in Korean and English with citations

- Urgent Prevention Alerts: Automatically fires alerts when HIGH severity hazards are detected

- 2D Hazard Visualization: Draws colored bounding boxes on site photos

- YOLO vs Claude Comparison: Side by side comparison showing why Claude beats YOLO

- Weekly Safety Summary: Management level weekly report of all inspections and alerts

- MCP Server: Exposes all tools via FastMCP for Claude Desktop integration

- PDF Report Generation: Professional PDF reports with metrics, images, and hazard cards

## Technology Stack

W1 - Prompt Engineering: Domain safety inspection system prompt

W2 - Claude API: Core backend for all AI operations

W3 - LLM-as-Judge: Evaluates report quality automatically

W4 - Tool Use: classify_hazard() function

W5 - RAG Pipeline: VoyageAI + BM25 + RRF on KOSHA PDFs

W6 - Vision, PDF, Citations, Caching: Photo analysis, document reading, cited output

W7 - MCP Server via FastMCP: Claude Desktop integration

## Project Structure

safety-inspector/

app.py Streamlit web interface

inspector.py Core AI pipeline

rag_builder.py Builds RAG index from KOSHA PDFs

yolo_compare.py YOLO vs Claude comparison

mcp_server.py MCP server

pdf_generator.py PDF report generation

data/pdfs/ KOSHA accident PDFs

outputs/ Generated reports and alerts

## Setup

1. Clone the repository

2. Create virtual environment: python -m venv venv

3. Activate: venv\Scripts\activate

4. Install dependencies: pip install -r requirements.txt

5. Create .env file with your API keys:

ANTHROPIC_API_KEY=your_key_here

VOYAGE_API_KEY=your_key_here

6. Download KOSHA PDFs into data/pdfs/

7. Build RAG index: python rag_builder.py

8. Run the app: streamlit run app.py

## Demo

Streamlit Web App:

streamlit run app.py

MCP Server:

npx @modelcontextprotocol/inspector python mcp_server.py

## Data Source

KOSHA construction accident case reports:

https://portal.kosha.or.kr

## Developer

Muhammad Ali

Student ID: 2026311007

Course: LLM-AE-AI

Professor: 백장운

Kyung Hee University

Graduate School of Architecture Engineering

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    • IncidentVault is incident management software (incident reporting and claims management) for multi-location businesses, with an MCP server that works with ChatGPT, Claude, Cursor and VS Code. Its MCP server lets Claude, ChatGPT and other MCP clients work with incidents, claims, cases, locations, policies, regulatory inspections, reports and dashboards, always limited to the signed-in user's role. Tools: incidentvault_dashboard (incident, claim, audit and follow-up workload), find_records (find incidents, claims, tasks or inspections), review_record (status, deadline, priority and audit percentage), search and fetch (operational records with citations), record_fields (allowed status and priority options), check_action (outcome of a submitted action) and workspace_profile (connected workspace). Connect in ChatGPT (web): Plugins (chatgpt.com/plugins) → + → Add custom MCP server → Server URL https://app.incidentvault.com/api/mcp/apps/chatgpt → Authentication: OAuth → create the plugin, install it and sign in. Connect in Claude: Settings → Connectors → Add custom connector → paste https://app.incidentvault.com/api/mcp/apps/claude → Connect and sign in. Cursor, VS Code and other clients: add https://app.incidentvault.com/api/mcp/apps/server as a remote HTTP MCP server. How to connect: an Admin enables MCP in IncidentVault and shares the connection details. Add IncidentVault in your assistant, sign in with OAuth, review the consent screen (read permissions preselected, write permissions off unless you opt in) and approve. Admins control approval rules, approved clients, masked fields and an emergency shutdown. Setup guide: https://incidentvault.com/ai-assistants-mcp-api/ Support: kcatolico@incidentvault.com

    • Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.

      https://api.p7n.dog/mcp
    • Connect Claude to your Platform7n workspaces: chat, links, work and decks. One-click OAuth.

      https://api.p7n.tech/mcp
    • RetailHardHat is site development and construction project management software for retail and restaurant brands, with an MCP server that works with ChatGPT, Claude, Cursor and VS Code. Its MCP server lets Claude, ChatGPT and other MCP clients work with an organization's sites, projects, budgets, bids, permits and tasks, including an interactive operations dashboard. Tools: get_operations_dashboard (overruns, opening risks, bids and pending approvals), list_sites, list_projects, summarize_budget_overruns (actual-versus-estimated by category), compare_site_bids (contractor bids for a location), list_permits, identify_opening_blockers (overdue tasks and rejected or expired permits), list_tasks, list_daily_logs (field logs) and get_milestone_matrix (milestones across sites). Connect in ChatGPT (web): Plugins (chatgpt.com/plugins) → + → Add custom MCP server → Server URL https://app.retailhardhat.com/api/mcp → Authentication: OAuth → create the plugin, install it and sign in. Connect in Claude: Settings → Connectors → Add custom connector → paste https://app.retailhardhat.com/api/mcp → Connect and sign in. Cursor, VS Code and other clients: add https://app.retailhardhat.com/api/mcp as a remote HTTP MCP server. How to connect: add a custom connector with the server URL https://app.retailhardhat.com/api/mcp (in Claude: Settings > Connectors > Add custom connector) and sign in. An organization admin grants modules and read-only or guarded-write access; sensitive writes need human review by default. Setup guide: https://retailhardhat.com/ai-assistants-mcp-api/ Support: kcatolico@retailhardhat.com

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables LLMs to autonomously analyze camera images for occupational safety violations, generate risk reports per ISG regulations, and log violations to a database.
      1
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables parsing a master resume, analyzing job descriptions for ATS/match scores, generating truthful tailored resumes, tracking applications, and producing PDF reports through Claude Desktop.
      17
      MIT