Skip to content

Latest commit

 

History

History
146 lines (110 loc) · 3.28 KB

File metadata and controls

146 lines (110 loc) · 3.28 KB

MCP Server Syntax Enforcement

Purpose: Force AI clients to use ONLY the correct ArcLang syntax


🔒 ENFORCEMENT MECHANISMS

1. MCP Resource: Syntax Rules

  • URI: arclang://syntax-rules
  • Exposed as MCP resource to AI clients
  • Contains mandatory syntax rules
  • Claude Desktop will read this BEFORE generating code

2. Tool Descriptions Enhanced

Tool descriptions now include:

MANDATORY SYNTAX: Use 'req ID "Title" { }' format
CORRECT: requirements stakeholder { req STK-001 "Title" { } }
WRONG: requirement "REQ-001" { }

3. Syntax Rules Document

  • Location: mcp-server/ARCLANG_SYNTAX_RULES.md
  • 315 lines of detailed rules
  • Shows ✅ CORRECT and ❌ WRONG syntax
  • Complete examples

4. Compiler Validation

  • All generated models validated by compiler
  • Syntax errors rejected immediately
  • Feedback loop forces correct syntax

📋 MANDATORY SYNTAX ENFORCED

Model Declaration

model ModelName { }
model "Name" { }
system "Name" { }

Requirements

requirements stakeholder { req ID "Title" { } }
requirement "ID" { }
requirements { } (top-level)

Architecture

architecture logical { }
logical_architecture { }
logical_architecture ArchName { }

Components

component Name "Display" { }
component "Name" { }
❌ Nested function or port blocks


🎯 HOW IT WORKS

  1. AI Client Connects to MCP server
  2. Reads Resource arclang://syntax-rules
  3. Sees Tool Descriptions with syntax constraints
  4. Generates Code following rules
  5. MCP Server Validates with compiler
  6. Returns Errors if syntax wrong
  7. AI Client Learns and corrects

📝 FILES CREATED

mcp-server/
├── ARCLANG_SYNTAX_RULES.md              # 315 lines - Complete reference
├── src/arclang_mcp/
│   ├── server.py                         # Enhanced tool descriptions
│   └── resources/
│       ├── __init__.py
│       └── syntax_guide.py              # MCP resource implementation

✅ BENEFITS

  1. Consistent Output: All AI clients generate same syntax
  2. No Manual Correction: Syntax enforced automatically
  3. Fast Feedback: Errors caught immediately
  4. Self-Learning: AI clients adapt to rules
  5. MCP Standard: Uses MCP resource protocol

🔧 USAGE

For AI Clients (Claude, etc.)

When connected to MCP server, AI will:

  1. Read arclang://syntax-rules resource
  2. Follow syntax rules automatically
  3. Get validation feedback

For Developers

# MCP server automatically enforces syntax
# No additional configuration needed

📖 EXAMPLE

User asks: "Generate ACC system requirements"

AI reads arclang://syntax-rules resource

AI generates:

model AdaptiveCruiseControl {
    requirements stakeholder {
        req STK-001 "Distance Control" {
            description: "System shall maintain safe distance"
            priority: Critical
            safety_level: ASIL_B
        }
    }
}

NOT:

❌ system "ACC" {
    requirement "STK-001" { }
}

🎯 RESULT

100% compliance with ArcLang syntax
No alternative syntaxes allowed
AI clients forced to use correct format

✅ Mission accomplished!