Skip to main content
Glama
GILSMON

MCP Policy Gatekeeper

by GILSMON

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.

Related MCP server: Hivelore

✨ 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

Available Tools

5 tools
create_fileB

Create a new file (automatically applies snake_case naming convention)

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesDesired file path (will be normalized to snake_case)
contentNoFile content

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the automatic snake_case naming convention, which is useful, but doesn't address critical behavioral aspects like whether this operation requires specific permissions, what happens if the file already exists, whether it's idempotent, or what the response looks like.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that immediately states the core functionality and includes the important behavioral detail about naming conventions. There's zero wasted text, and it's perfectly front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a file creation tool with 2 parameters and no output schema, the description is minimally adequate but has significant gaps. It covers the naming convention behavior but misses important context about error handling, permissions, file existence checks, and what distinguishes it from sibling tools like 'write_file'.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds the important semantic detail about automatic snake_case normalization for the path parameter, but doesn't provide additional context about content parameter usage or file format considerations beyond what's in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('a new file'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'write_file' (which might update existing files) or mention what type of file is being created.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'write_file' or 'list_files'. There's no mention of prerequisites, error conditions, or typical use cases, leaving the agent to infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

delete_fileC

Delete a file

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesFile path

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. 'Delete a file' implies a destructive mutation, but it doesn't specify whether deletion is permanent, reversible (e.g., moves to trash), requires specific permissions, or has side effects (e.g., affecting linked resources). This leaves critical behavioral traits unaddressed for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just three words, front-loaded with the core action. There's no wasted language, making it easy to parse quickly, though this brevity contributes to gaps in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (destructive operation with no annotations and no output schema), the description is incomplete. It doesn't cover behavioral aspects like permanence or permissions, output details (e.g., confirmation message), or error handling, which are crucial for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'path' parameter documented as 'File path'. The description adds no additional meaning beyond this, such as path format examples or constraints. According to the rules, with high schema coverage (>80%), the baseline is 3 even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Delete a file' clearly states the action (delete) and resource (file), which is better than a tautology. However, it doesn't differentiate from sibling tools like 'create_file' or 'write_file' beyond the verb, and it lacks specificity about what type of file deletion occurs (permanent vs. trash, etc.).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'write_file' for modifications or 'create_file' for new files. It doesn't mention prerequisites (e.g., file must exist) or exclusions, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_filesC

List all files in directory

ParametersJSON Schema
NameRequiredDescriptionDefault
pathNoDirectory path

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe important behavioral aspects: whether it returns file metadata or just names, if it handles permissions errors, if it follows symbolic links, or what happens with invalid paths. For a file system tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise at just four words, front-loading the essential information with zero wasted language. Every word earns its place by specifying the action, scope, and target resource efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a file system operation that could have complex behaviors (permissions, recursion, error handling), the description is insufficiently complete. It doesn't explain what format the listing returns, how errors are handled, or important constraints. For a tool interacting with file systems, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'path' clearly documented in the schema. The description adds no additional parameter information beyond what's already in the structured data. The baseline score of 3 reflects adequate but minimal value addition when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List') and resource ('files in directory'), making the purpose immediately understandable. It distinguishes from siblings like create_file or delete_file by focusing on retrieval rather than modification. However, it doesn't specify whether this lists only immediate files or includes subdirectories, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention whether this is for browsing directory contents, checking file existence, or other use cases. With siblings like read_file available, there's no indication of when list_files is preferred over directly reading specific files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_fileC

Read contents of a file

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesFile path

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While 'Read' implies a non-destructive operation, it doesn't disclose important behavioral traits like file format handling, encoding issues, maximum file size limits, permission requirements, or error conditions for missing files.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise at 4 words, front-loaded with the core action, and contains zero wasted words. Every element ('Read', 'contents', 'of a file') contributes essential meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a file reading tool with no annotations and no output schema, the description is insufficient. It doesn't explain what gets returned (text content, binary data, encoding), error handling, or constraints. Given the complexity of file operations and lack of structured information, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single 'path' parameter. The description adds no additional meaning about the path parameter beyond what the schema provides, such as path format examples or relative/absolute path handling.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Read') and resource ('contents of a file'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_files' which also reads information about files but doesn't read their contents.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'list_files' (for metadata) and 'write_file' (for modification), there's no indication of when reading file contents is appropriate versus other file operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

write_fileB

Write to an existing file (naming convention enforced on creation only)

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesFile path
contentYesFile content

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions 'naming convention enforced on creation only', which adds some behavioral context about constraints. However, it doesn't disclose critical traits like whether this operation overwrites or appends content, requires specific permissions, has side effects, or what happens on errors. For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that is front-loaded with the core purpose ('Write to an existing file') and includes a clarifying note. There is zero wasteβ€”every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a file write operation (a mutation with potential side effects), no annotations, and no output schema, the description is incomplete. It lacks details on behavior (e.g., overwrite vs. append), error handling, permissions, or return values. The naming convention note is helpful but insufficient for safe and effective use by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters ('path' and 'content') clearly documented in the schema. The description doesn't add any meaning beyond what the schema providesβ€”it doesn't explain parameter formats, constraints, or examples. Baseline 3 is appropriate when the schema does the heavy lifting, but no extra value is added.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Write to') and resource ('an existing file'), making the purpose immediately understandable. It distinguishes from 'create_file' by specifying 'existing file', though it doesn't explicitly mention all siblings like 'delete_file' or 'read_file'. The naming convention note adds specificity but isn't essential to the core purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying 'existing file', which distinguishes it from 'create_file' for new files. However, it doesn't provide explicit guidance on when to use this versus alternatives like 'read_file' or 'delete_file', nor does it mention prerequisites or exclusions. The context is implied rather than explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.5/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose targeting specific file operations: create, delete, list, read, and write. There is no overlap or ambiguity between these functions, making tool selection straightforward for an agent.

Naming Consistency5/5

All tools follow a consistent verb_noun pattern (e.g., create_file, delete_file) using snake_case throughout. The naming is predictable and aligns perfectly with the operations performed.

Tool Count5/5

With 5 tools, the server is well-scoped for file management, covering essential CRUD operations (create, read, update via write, delete) and listing. Each tool earns its place without being excessive or insufficient.

Completeness5/5

The tool set provides complete coverage for basic file operations in the domain, including create, read, update (write), delete, and list. There are no obvious gaps, and agents can perform full file lifecycle management without dead ends.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Runtime policy enforcement for AI agents. Evaluate every agent action against your organization's policies before execution, with observe and enforce modes.
    1
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Policy and quality engine for AI coding agents that enforces team coding standards and provides validation gates for agent-assisted software delivery.
    7
    54
    4
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to self-govern by scanning code for hardcoded secrets, structural violations, and AI drift in real-time, providing fix packets for automatic remediation.
    26
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GILSMON/mcpServer_as_gatekeeper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server