swims-mcp-server

jezweb/swims-mcp-server

3.2

If you are the rightful owner of swims-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The SWMS MCP Server is a FastMCP server designed to analyze Safe Work Method Statements (SWMS) for compliance with NSW construction regulations using Gemini AI.

Tools
3
Resources
0
Prompts
0

SWMS MCP Server

A FastMCP server that analyzes Safe Work Method Statements (SWMS) for Australian construction compliance using Gemini AI with jurisdiction-specific regulatory context.

🌟 Key Features

Core Compliance Features

  • šŸŒ Multi-jurisdictional Support - All Australian states and territories (NSW, VIC, QLD, WA, SA, TAS, ACT, NT)
  • šŸ“š Regulatory Context - Automatic inclusion of 25+ official documents from Cloudflare R2
  • šŸ“„ Flexible Input - Base64, URL, text, with automatic DOCX to PDF conversion
  • āœ… Comprehensive Analysis - Based on WHS/OHS regulations for each jurisdiction
  • šŸŽÆ Custom Analysis - Flexible prompts and specialized compliance checks
  • šŸ“Š Numerical Scoring - Weighted compliance scores for tracking improvements
  • šŸ¤– Gemini 2.0 Flash - Advanced document understanding with regulatory context

New Business Operation Features

  • šŸš€ SWMS Generation - Create complete SWMS from plain English job descriptions
  • šŸ—£ļø Toolbox Talks - Generate 5/10/15 minute safety talks from SWMS
  • šŸ‘· Worker Summaries - Simplified safety cards with visual symbols
  • šŸ’” Improvement Suggestions - AI-powered recommendations based on best practices
  • šŸ“ø Image Hazard Detection - Identify site hazards from photos using vision AI

šŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/jezweb/swims-mcp-server.git
cd swims-mcp-server

# Install dependencies
pip install -r requirements.txt

# Set up environment
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

Running the Server

# Development
fastmcp dev server.py

# Production
fastmcp run server.py

šŸ“– Usage Examples

Basic SWMS Analysis (NSW)

# Upload document
upload_result = await upload_swms_from_url({
    "url": "https://example.com/construction-swms.pdf"
})

# Analyze for NSW compliance (default)
analysis = await analyze_swms_compliance({
    "document_id": upload_result["document_id"]
})

Victoria-Specific Analysis (OHS)

# Victoria uses OHS terminology, not WHS
analysis = await analyze_swms_compliance({
    "document_id": document_id,
    "jurisdiction": "vic"  # Uses OHS regulations
})

Get Compliance Score

# Get numerical score for tracking
score = await get_compliance_score({
    "document_id": document_id,
    "weighted": True,
    "jurisdiction": "qld"
})
# Returns overall score, category breakdowns, and recommendations

Quick Checks

# Quick check for specific aspects
result = await quick_check_swms({
    "document_id": document_id,
    "check_type": "high_risk",  # or "emergency", "ppe", "controls", etc.
    "jurisdiction": "wa"
})

Custom Analysis

# Custom analysis with your own prompt
custom = await analyze_swms_custom({
    "document_id": document_id,
    "analysis_prompt": "Check if this SWMS adequately addresses mental health and fatigue management for night shift workers",
    "jurisdiction": "sa"
})

Generate SWMS from Description (NEW)

# Generate complete SWMS from job description
swms = await generate_swms_from_description_tool({
    "job_description": "Install electrical wiring and outlets on level 3 of commercial building, including running cables through ceiling cavity and installing GPOs in office spaces",
    "trade_type": "electrical",
    "site_type": "commercial",
    "jurisdiction": "nsw"
})
# Returns complete SWMS document ready for review

# Generate toolbox talk from SWMS
talk = await generate_toolbox_talk_tool({
    "document_id": document_id,
    "duration": "5min",
    "focus_area": "electrical safety"
})
# Returns bullet points for morning safety briefing

šŸ¤– AI Integration Guide

For AI Assistants Using This MCP Server

This section helps AI assistants understand how to effectively use the SWMS MCP Server tools.

Understanding the Workflow
  1. Always Upload First: Before any analysis, documents must be uploaded using one of:

    • upload_swms_from_url (recommended - works with any public URL)
    • upload_swms_document (for base64-encoded content)
    • upload_swms_from_file (for local files - only works if server has access)
  2. Use the Returned document_id: Upload tools return a document_id (format: "files/abc123..."). This ID is required for all analysis tools.

  3. Choose the Right Tool:

    • Full compliance check: Use analyze_swms_compliance for comprehensive assessment
    • Quick validation: Use quick_check_swms for specific aspects (hrcw, ppe, emergency, etc.)
    • Numerical score: Use get_compliance_score for benchmarking
    • Create new SWMS: Use generate_swms_from_description_tool (no upload needed)
    • Daily briefings: Use generate_toolbox_talk_tool after uploading
Common Patterns
# Pattern 1: Full Analysis Pipeline
upload = upload_swms_from_url(url="https://example.com/swms.pdf")
doc_id = upload["document_id"]
score = get_compliance_score(doc_id, jurisdiction="nsw")
if score["overall_score"] < 85:
    report = analyze_swms_compliance(doc_id, jurisdiction="nsw")
    improvements = suggest_swms_improvements_tool(doc_id)

# Pattern 2: Morning Safety Briefing
upload = upload_swms_from_url(url="https://company.com/todays-swms.pdf")
talk = generate_toolbox_talk_tool(upload["document_id"], duration="5min")
summary = create_worker_summary_tool(upload["document_id"], language_level="simple")

# Pattern 3: Create New SWMS
swms = generate_swms_from_description_tool(
    job_description="Detailed description of work",
    trade_type="electrical",  # Must be from valid list
    site_type="commercial",   # Must be from valid list
    jurisdiction="nsw"         # Must be valid state code
)
Parameter Validation
  • jurisdiction: Must be one of: "nsw", "vic", "qld", "wa", "sa", "tas", "act", "nt", "national"
  • duration: Must be exactly: "5min", "10min", or "15min"
  • check_type: Must be one of: "hrcw", "ppe", "emergency", "signatures", "hierarchy", "hazards"
  • trade_type: See tool description for complete list (electrical, plumbing, carpentry, etc.)
  • site_type: See tool description for complete list (residential, commercial, industrial, etc.)
Error Handling

Common errors and solutions:

  • "Document not found" - Ensure you're using the correct document_id from upload
  • "Invalid jurisdiction" - Use lowercase state codes (nsw, not NSW)
  • "Invalid duration" - Must be exactly "5min", "10min", or "15min"

šŸ”§ Available Tools

Core Analysis Tools

ToolDescriptionKey Parameters
upload_swms_documentUpload from base64 contentfile_content, file_name
upload_swms_from_urlUpload from URLurl
analyze_swms_complianceFull compliance analysisdocument_id, jurisdiction
analyze_swms_textAnalyze text directlydocument_text, jurisdiction
analyze_swms_customCustom prompt analysisdocument_id, analysis_prompt
get_compliance_scoreNumerical scoringdocument_id, weighted
quick_check_swmsRapid specific checksdocument_id, check_type
list_jurisdictionsGet supported jurisdictionsNone
get_server_statusCheck server healthNone

Business Operation Tools (NEW)

ToolDescriptionKey Parameters
generate_swms_from_description_toolCreate SWMS from job descriptionjob_description, trade_type, site_type
generate_toolbox_talk_toolGenerate daily safety talksdocument_id, duration, focus_area
create_worker_summary_toolSimplified safety cardsdocument_id, language_level, include_symbols
suggest_swms_improvements_toolAI improvement suggestionsdocument_id, improvement_focus
extract_hazards_from_image_toolVision-based hazard detectionimage_content, work_type

šŸ›ļø Jurisdiction Support

State/TerritoryCodeLegislationRegulatorNotes
New South WalesnswWHS Act 2011SafeWork NSWDefault jurisdiction
VictoriavicOHS Act 2004WorkSafe VictoriaUses OHS terminology
QueenslandqldWHS Act 2011WHSQModel laws
Western AustraliawaWHS Act 2020WorkSafe WAAdopted 2022
South AustraliasaWHS Act 2012SafeWork SA3m fall height
TasmaniatasWHS Act 2012WorkSafe TasmaniaModel laws
ACTactWHS Act 2011WorkSafe ACTModel laws
Northern TerritoryntWHS Act 2011NT WorkSafeModel laws
NationalnationalModel LawsSafe Work AustraliaModel framework

šŸ“š Regulatory Document Context

The server automatically includes relevant regulatory documents from R2:

  • Codes of Practice - Construction work guidelines for each jurisdiction
  • SWMS Templates - Official templates and examples
  • Information Sheets - Guidance on SWMS requirements
  • Fact Sheets - Quick reference materials

Documents are fetched from: https://pub-bb6a39bd73444f4582d3208b2257c357.r2.dev

šŸŽÆ Compliance Assessment Areas

The server evaluates SWMS against six key areas:

  1. Document Control (10% weight)

    • Project details, version control, responsibilities
  2. HRCW Identification (20% weight)

    • 18 categories of high-risk construction work
  3. Hazard Identification (15% weight)

    • Site-specific hazards, risk descriptions
  4. Control Measures (25% weight)

    • Hierarchy of controls implementation
  5. Monitoring & Review (15% weight)

    • Review triggers, monitoring procedures
  6. Consultation (15% weight)

    • Worker consultation, sign-off records

ā˜ļø Deployment

FastMCP Cloud

  1. Push to GitHub
  2. Connect repository to FastMCP Cloud
  3. Add environment variables:
    • GEMINI_API_KEY (required)
    • R2_PUBLIC_URL (optional, defaults to configured URL)
  4. Deploy

Local Development

# Install FastMCP
pip install fastmcp

# Run in development mode
fastmcp dev server.py

# Access at default MCP endpoint

šŸ” Environment Variables

# Required
GEMINI_API_KEY=your_gemini_api_key_here

# Optional (defaults provided)
R2_PUBLIC_URL=https://pub-bb6a39bd73444f4582d3208b2257c357.r2.dev

šŸ“ Project Structure

swms-mcp-server/
ā”œā”€ā”€ server.py                 # Main MCP server
ā”œā”€ā”€ r2_context.py            # R2 document management
ā”œā”€ā”€ requirements.txt         # Python dependencies
ā”œā”€ā”€ .env.example            # Environment template
ā”œā”€ā”€ regulatory_documents/    # Local document cache
│   ā”œā”€ā”€ national/          # Safe Work Australia docs
│   ā”œā”€ā”€ nsw/              # NSW specific docs
│   ā”œā”€ā”€ vic/              # Victoria OHS docs
│   └── ...               # Other jurisdictions
└── docs/                   # Documentation
    ā”œā”€ā”€ API_DOCUMENTATION.md
    ā”œā”€ā”€ DOCUMENT_MANAGEMENT.md
    └── R2_DEPLOYMENT_STATUS.md

šŸ¤ Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new features
  4. Submit a pull request

šŸ“„ License

MIT License - see LICENSE file for details

šŸ†˜ Support

  • Issues: GitHub Issues
  • Documentation: See /docs folder
  • API Reference:

šŸ—ļø Built With

šŸ“ˆ Version History

  • v1.0.0 - Initial release with multi-jurisdictional support
  • v1.1.0 - Added R2 integration and regulatory context
  • v1.2.0 - Custom analysis and scoring features
  • v2.0.0 - Added 5 business operation tools for SME workflow management

Made with ā¤ļø for Australian construction safety compliance