Skip to main content
Glama
GILSMON

MCP Policy Gatekeeper

by GILSMON

list_files

Retrieve all files within a specified directory to verify compliance with organizational policies before execution.

Instructions

List all files in directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoDirectory path

Implementation Reference

  • Handler for the 'list_files' tool. Resolves the directory path, recursively finds all files using rglob('*'), collects relative paths of files only, sorts them, and returns as a newline-separated text content.
    elif name == "list_files":
        dir_path = resolve_path(arguments.get("path", ""))
        if not dir_path.exists():
            return [TextContent(type="text", text="Error: Directory not found")]
        
        files = []
        for item in dir_path.rglob("*"):
            if item.is_file():
                files.append(str(item.relative_to(PROTECTED_DIR)))
        
        return [TextContent(type="text", text="\n".join(sorted(files)) if files else "No files found")]
  • server.py:123-132 (registration)
    Registration of the 'list_files' tool in the list_tools() function, including its description and input schema.
    Tool(
        name="list_files",
        description="List all files in directory",
        inputSchema={
            "type": "object",
            "properties": {
                "path": {"type": "string", "description": "Directory path", "default": ""}
            }
        }
    )
  • Input schema for the 'list_files' tool: an object with optional 'path' string property defaulting to empty string.
    inputSchema={
        "type": "object",
        "properties": {
            "path": {"type": "string", "description": "Directory path", "default": ""}
        }
    }

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