A Model Context Protocol (MCP) server that enforces custom workflow protocols before allowing AI agents to perform file operations.
Author: Jason Lusk [email protected] License: MIT
This MCP server acts as a gatekeeper that ensures AI coding assistants follow your project's mandatory protocols:
- ✅ Enforces custom protocol steps before planning/coding
- ✅ Tracks required checklist items specific to your project
- ✅ Records compliance violations over time
- ✅ Fully configurable - adapt to any workflow or toolchain
- ✅ Tool-agnostic - works with any MCP servers or development process
Add to your .mcp.json (project-level) or ~/.claude.json (user-level):
{
"mcpServers": {
"protocol-enforcer": {
"command": "npx",
"args": ["-y", "https://gist.github.com/YOUR_USERNAME/YOUR_GIST_ID"]
}
}
}Replace YOUR_USERNAME/YOUR_GIST_ID with your actual gist URL.
- Create a directory:
mkdir -p ~/mcp-servers/protocol-enforcer && cd ~/mcp-servers/protocol-enforcer - Save
package.jsonandindex.jsfrom this gist - Add to
.mcp.json:
{
"mcpServers": {
"protocol-enforcer": {
"command": "node",
"args": ["/full/path/to/index.js"]
}
}
}After adding to .mcp.json:
- Reload your IDE (Cursor:
Cmd+Shift+P→ "Developer: Reload Window") - Check MCP status (in terminal):
~/.cursor/extensions/anthropic.claude-code-*/resources/native-binary/claude mcp list
- You should see
protocol-enforcerin the list
The server supports two configuration scopes:
- Project scope:
.protocol-enforcer.jsonin your project root - User scope:
~/.protocol-enforcer.jsonin your home directory
Project scope takes precedence if both exist.
Ask your AI assistant:
Use the initialize_protocol_config tool to create a project-level configuration file.
Or manually create .protocol-enforcer.json:
{
"enforced_rules": {
"require_protocol_steps": ["step1", "step2"],
"require_checklist_confirmation": true,
"minimum_checklist_items": 2
},
"checklist_items": [
"Follow project coding standards",
"Check for reusable components",
"Run linting before commit"
]
}| Option | Type | Description |
|---|---|---|
require_protocol_steps |
string[] | List of required protocol step names (e.g., ["planning", "analysis", "review"]) |
require_checklist_confirmation |
boolean | Require checking project-specific checklist items |
minimum_checklist_items |
number | Minimum number of checklist items that must be verified |
checklist_items |
string[] | List of project-specific patterns/rules to enforce |
Before making any file changes, you must call the verification tool:
// Complete your required protocol steps first
// (The specific steps depend on YOUR project configuration)
// Then verify compliance
mcp__protocol-enforcer__verify_protocol_compliance({
protocol_steps_completed: ["planning", "analysis"],
checklist_items_checked: [
"Follow project coding standards",
"Check for reusable components"
]
});
// Only if verification passes, proceed with file operationsCreate a new configuration file.
Parameters:
scope(required):"project"or"user"
Example:
mcp__protocol-enforcer__initialize_protocol_config({
scope: "project"
});Verify that mandatory protocol steps have been completed.
Parameters:
protocol_steps_completed(required): string[] - List of protocol step names completedchecklist_items_checked(required): string[] - List of checklist items verified
Returns:
{
"compliant": true,
"message": "Protocol compliance verified. You may proceed with file operations."
}Or if violations exist:
{
"compliant": false,
"violations": [
"VIOLATION: Required protocol step not completed: planning",
"VIOLATION: Only 1 checklist items checked, minimum 2 required"
],
"message": "Protocol compliance check FAILED. Fix violations before proceeding."
}Get current compliance statistics and recent violations.
Parameters: None
Returns:
{
"total_checks": 47,
"recent_checks": 10,
"passed": 8,
"failed": 2,
"recent_violations": [
{
"timestamp": "2025-12-04T10:30:00.000Z",
"violations": ["VIOLATION: Required protocol step not completed: analysis"]
}
]
}Get the current protocol enforcer configuration.
Parameters: None
Returns:
{
"config_path": "/Users/username/project/.protocol-enforcer.json",
"config": {
"enforced_rules": {
"require_protocol_steps": ["planning", "analysis"],
"require_checklist_confirmation": true,
"minimum_checklist_items": 2
},
"checklist_items": [...]
}
}{
"enforced_rules": {
"require_protocol_steps": ["write_tests", "implement", "refactor"],
"require_checklist_confirmation": true,
"minimum_checklist_items": 2
},
"checklist_items": [
"Tests written before implementation",
"All tests passing",
"Code coverage maintained"
]
}{
"enforced_rules": {
"require_protocol_steps": ["design_review", "component_mapping"],
"require_checklist_confirmation": true,
"minimum_checklist_items": 3
},
"checklist_items": [
"Design tokens mapped to variables",
"Figma specs reviewed",
"Accessibility requirements checked",
"Responsive breakpoints defined"
]
}{
"enforced_rules": {
"require_protocol_steps": ["plan"],
"require_checklist_confirmation": true,
"minimum_checklist_items": 1
},
"checklist_items": [
"Reviewed existing code patterns"
]
}This server is tool-agnostic and works with any workflow. Configure it to match YOUR process:
{
"require_protocol_steps": ["reasoning", "planning"],
"checklist_items": ["Analyzed edge cases", "Considered alternatives"]
}{
"require_protocol_steps": ["query_docs", "review_patterns"],
"checklist_items": ["Checked project guidelines", "Followed naming conventions"]
}{
"require_protocol_steps": ["fetch_design", "map_tokens"],
"checklist_items": ["Design reviewed", "Tokens mapped", "Responsive checked"]
}{
"require_protocol_steps": ["your_step_1", "your_step_2"],
"checklist_items": ["Your requirement 1", "Your requirement 2"]
}Update your AI supervisor protocol to enforce verification before file operations:
## Protocol Enforcer Integration
Before ANY file write, edit, or create operation:
1. Complete all required protocol steps defined in your `.protocol-enforcer.json`
2. Call `mcp__protocol-enforcer__verify_protocol_compliance` with:
- `protocol_steps_completed`: array of completed step names
- `checklist_items_checked`: array of verified checklist items
3. If `compliant: false`, fix violations and retry verification
4. Only proceed with file operations if `compliant: true`
**This is a hard requirement - no exceptions.**- Check
.mcp.jsonsyntax - must be valid JSON - Reload IDE -
Cmd+Shift+P→ "Developer: Reload Window" - Verify gist URL - ensure it's publicly accessible
- Check logs - look for MCP server startup errors
- Check file name - must be exactly
.protocol-enforcer.json - Verify JSON syntax - use a JSON validator
- Check file location - project root or home directory
- Call
get_protocol_config- see what's actually loaded
This server provides verification tools - it doesn't automatically prevent violations. You must:
- Update your supervisor protocol to require calling
verify_protocol_compliancebefore file operations - Configure your specific steps in
.protocol-enforcer.json - Review compliance status - use
get_compliance_statusto track violations
AI coding assistants are powerful but can bypass project-specific protocols when under pressure or context limits. This server:
- Enforces consistency - same rules for every task
- Provides traceability - tracks when protocols are followed/violated
- Enables accountability - compliance status shows protocol effectiveness
- Reduces technical debt - prevents shortcuts that violate project standards
- Works with ANY workflow - not tied to specific tools or processes
This is a minimal implementation. Suggestions for improvement:
- File operation hooks - intercept file writes directly (requires IDE integration)
- Git pre-commit integration - block commits with compliance violations
- Custom rule plugins - extend with project-specific validation logic
- Dashboard UI - visualize compliance trends over time
Issues/PRs welcome on the gist discussion.
MIT License - see gist files for details.
Questions? Open a discussion on this gist or contact [email protected]