MCP Policy Gatekeeper

MCP Policy Gatekeeper

Provides real-time policy enforcement for AI coding agents by intercepting and validating their actions against organizational standards like naming conventions, security policies, and compliance rules before execution. Prevents violations through immediate feedback and auto-correction suggestions.

Category
Visit Server

README

MCP Server as Policy Gatekeeper

Real-time policy enforcement for AI coding agents using Model Context Protocol

Prevent AI agents from violating organizational standards by intercepting and validating their actions before execution.

🎯 Problem

AI coding assistants can bypass:

  • Naming conventions (camelCase vs snake_case)
  • Security policies (secrets in code, destructive commands)
  • Compliance rules (file access, API usage)

Traditional solutions (CI/CD, code review) catch violations after the damage is done.

✨ Solution

MCP server that acts as a policy gatekeeper - validates every agent action in real-time:

Agent: "Create myFirst--File.txt"
   ↓
MCP Server: ❌ Violates snake_case policy
   ↓
Agent: "Creating my_first_file.txt instead"

🚀 Quick Start

# Clone & setup
git clone https://github.com/yourusername/mcpServer_as_gatekeeper.git
cd mcpServer_as_gatekeeper

# Install with uv
uv init
uv add mcp

# Run server
uv run server.py

🔧 Windsurf Integration

Add to ~/.windsurf/mcp_config.json:

{
  "mcpServers": {
    "policy-gatekeeper": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcpServer_as_gatekeeper",
        "run",
        "server.py"
      ]
    }
  }
}

Restart Windsurf. Done.

📋 Built-in Policies

1. Command Validation

  • ❌ Blocks: rm -rf /, curl | bash, chmod 777
  • ✅ Allows: git, npm, docker, safe operations

2. File Naming

  • Enforces: snake_case for files
  • Rejects: camelCase, kebab-case, special characters

3. Sensitive Paths

  • Blocks: /etc/shadow, .ssh/id_rsa, .env files

4. Network Security

  • Prevents: Command injection, data exfiltration

🧪 Test It

Prompt your agent:

Create a file called myTest--File.txt

Expected: Agent auto-corrects to my_test_file.txt

Validate this command: rm -rf /

Expected: Blocked with policy violation ORG-SEC-001

📊 Features

Feature Status
Command validation
File naming enforcement
Audit logging
Statistics dashboard
OPA integration 🔄 Roadmap
Secret scanning 🔄 Roadmap

🏗️ Architecture

┌─────────────────┐
│  AI Agent       │
│  (Windsurf)     │
└────────┬────────┘
         │ MCP Protocol
         ↓
┌─────────────────────────┐
│  Policy Gatekeeper      │
│  - Validate command     │
│  - Check naming rules   │
│  - Scan for secrets     │
│  - Audit log            │
└────────┬────────────────┘
         │
         ↓
    ALLOW / DENY

🎛️ Customize Policies

Edit server.py:

POLICY_RULES = {
    "your_rule": {
        "patterns": [r"your_regex"],
        "message": "Your policy message"
    }
}

Restart MCP server. Policies update immediately.

📈 Scale Impact

For a 50-developer team:

  • 5,000 daily policy checks (100 per dev)
  • ~100 hours/week saved on manual enforcement
  • 80% of violations prevented before code review
  • Zero failed CI builds from policy violations

🔐 Enterprise Use Cases

  • Security: Block secrets, malicious commands
  • Compliance: Enforce SOC2/HIPAA file access rules
  • Quality: Consistent naming, code structure
  • Cost: Prevent expensive CI/CD failures

🛣️ Roadmap

  • [ ] OPA/Rego integration for complex policies
  • [ ] Secret detection (TruffleHog integration)
  • [ ] RBAC (role-based validation)
  • [ ] Multi-team policy federation
  • [ ] VS Code / Cursor support
  • [ ] Dashboard UI for policy management

🤝 Contributing

Have a policy pattern to share? PRs welcome!

  1. Fork the repo
  2. Add your policy to POLICY_RULES
  3. Add test cases
  4. Submit PR

📄 License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured