Skip to main content
Glama
GILSMON

MCP Policy Gatekeeper

by GILSMON

delete_file

Remove files while enforcing organizational policies on naming conventions, security, and compliance rules before deletion.

Instructions

Delete a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesFile path

Implementation Reference

  • The handler logic for the 'delete_file' tool within the call_tool function. It resolves the provided path, checks if the file exists, deletes it using path.unlink() if it does, and returns an appropriate success or error message.
    elif name == "delete_file": path = resolve_path(arguments["path"]) if not path.exists(): return [TextContent(type="text", text=f"Error: File '{arguments['path']}' not found")] path.unlink() return [TextContent(type="text", text=f"✓ File deleted: {arguments['path']}")]
  • server.py:112-122 (registration)
    Registration of the 'delete_file' tool in the list_tools() function, including name, description, and input schema.
    Tool( name="delete_file", description="Delete a file", inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] } ),
  • Input schema definition for the 'delete_file' tool, specifying the required 'path' parameter.
    inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] }
  • Helper function used by the delete_file handler (and others) to resolve relative paths to absolute paths within the protected directory, enforcing security.
    def resolve_path(relative_path: str) -> Path: full_path = (PROTECTED_DIR / relative_path).resolve() if not str(full_path).startswith(str(PROTECTED_DIR)): raise ValueError("Access denied: Path outside protected directory") return full_path

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