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": ""}
        }
    }
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.

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