Skip to main content
Glama
GILSMON

MCP Policy Gatekeeper

by GILSMON

create_file

Create files with automatic snake_case naming enforcement to maintain organizational coding standards and prevent policy violations.

Instructions

Create a new file (automatically applies snake_case naming convention)

Input Schema

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

Implementation Reference

  • The handler logic for the 'create_file' tool. Normalizes the filename to snake_case, resolves the path securely, checks if the file already exists, creates necessary directories, writes the provided content to the new file, and returns a success message with naming explanation.
    if name == "create_file":
        # Apply naming convention
        requested_path = arguments["path"]
        normalized_path, explanation = enforce_naming_convention(requested_path)
        
        path = resolve_path(normalized_path)
        content = arguments.get("content", "")
        
        # Check if file already exists
        if path.exists():
            return [TextContent(
                type="text",
                text=f"Error: File '{normalized_path}' already exists. Use write_file to update it."
            )]
        
        # Create directory if needed
        path.parent.mkdir(parents=True, exist_ok=True)
        
        # Create the file
        with open(path, 'w', encoding='utf-8') as f:
            f.write(content)
        
        # Return success message with naming convention info
        message = f"{explanation}\nāœ“ File created successfully: {normalized_path}"
        return [TextContent(type="text", text=message)]
  • server.py:70-88 (registration)
    Tool registration for 'create_file' in the @app.list_tools() function, including metadata, description, and input schema definition.
    Tool(
        name="create_file",
        description="Create a new file (automatically applies snake_case naming convention)",
        inputSchema={
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "Desired file path (will be normalized to snake_case)"
                },
                "content": {
                    "type": "string",
                    "description": "File content",
                    "default": ""
                }
            },
            "required": ["path"]
        }
    ),
  • Supporting helper function that enforces snake_case naming convention on the provided file path, returning the normalized path and an explanation message. Called by the create_file handler.
    def enforce_naming_convention(filename: str) -> tuple[str, str]:
        """
        Enforce organizational naming convention: convert to snake_case.
        Returns: (normalized_filename, explanation)
        """
        # Get the filename without path
        path_parts = filename.split('/')
        original_name = path_parts[-1]
        
        # Split name and extension
        if '.' in original_name:
            name_part, extension = original_name.rsplit('.', 1)
        else:
            name_part = original_name
            extension = ''
        
        # Convert to snake_case
        # 1. Replace spaces and hyphens with underscores
        normalized = name_part.replace(' ', '_').replace('-', '_')
        
        # 2. Insert underscore before capital letters (camelCase -> snake_case)
        normalized = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', normalized)
        normalized = re.sub('([a-z0-9])([A-Z])', r'\1_\2', normalized)
        
        # 3. Convert to lowercase
        normalized = normalized.lower()
        
        # 4. Remove consecutive underscores
        normalized = re.sub('_+', '_', normalized)
        
        # 5. Remove leading/trailing underscores
        normalized = normalized.strip('_')
        
        # Reconstruct full filename
        if extension:
            normalized_filename = f"{normalized}.{extension}"
        else:
            normalized_filename = normalized
        
        # Reconstruct full path
        if len(path_parts) > 1:
            path_parts[-1] = normalized_filename
            full_normalized = '/'.join(path_parts)
        else:
            full_normalized = normalized_filename
        
        # Create explanation if name was changed
        if original_name != normalized_filename:
            explanation = f"šŸ“ Naming convention applied: '{original_name}' → '{normalized_filename}'"
        else:
            explanation = f"āœ“ Filename already follows convention: '{normalized_filename}'"
        
        return full_normalized, explanation
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.

Install Server

Other Tools

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