Skip to main content
Glama
penguinszp001

mcp-server-demo

list_files

List the contents of a directory within the configured file operations root.

Instructions

List files directly inside a folder within MCP_FILE_OPS_ROOT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The list_files tool handler: decorated with @mcp.tool(), resolves the path, validates it's a directory, lists all files (not directories) inside it, and returns them as a sorted JSON array.
    @mcp.tool()
    def list_files(path: str = ".") -> str:
        """List files directly inside a folder within MCP_FILE_OPS_ROOT."""
        target = _resolve_file_ops_path(path)
        if not target.is_dir():
            raise ValueError(f"Not a directory: {target}")
    
        files = sorted(p.name for p in target.iterdir() if p.is_file())
        return json.dumps(files, indent=2)
  • The _resolve_file_ops_path helper that list_files uses: resolves the path against MCP_FILE_OPS_ROOT, ensures it doesn't escape the root, and returns the Path object.
    def _resolve_file_ops_path(path: str | None = None) -> Path:
        if not FILE_OPS_ROOT:
            raise ValueError("MCP_FILE_OPS_ROOT is not configured in .env.")
    
        root = Path(FILE_OPS_ROOT).expanduser().resolve()
        root.mkdir(parents=True, exist_ok=True)
    
        target = root if path is None else (root / path).resolve()
        if target != root and root not in target.parents:
            raise ValueError("Path escapes the configured MCP_FILE_OPS_ROOT.")
        return target
  • server.py:170-170 (registration)
    The @mcp.tool() decorator registering list_files as an MCP tool on the FastMCP instance.
    @mcp.tool()
  • Input schema: single 'path' parameter with type str and default value '.'
    def list_files(path: str = ".") -> str:
Behavior2/5

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

With no annotations provided, the description carries full burden. It mentions 'directly inside a folder' implying non-recursive listing, but fails to disclose behavior for invalid paths, permissions, or any side effects (though none expected).

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

Conciseness4/5

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

The description is a single, front-loaded sentence with no wasted words. However, it could incorporate more detail without losing conciseness.

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?

Given the tool's simplicity (one parameter, list operation) and existence of an output schema, the description provides the core functionality but omits edge cases like listing a file path or special folder names. It is minimally adequate but not comprehensive.

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

Parameters2/5

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

The schema has one parameter 'path' with a default of '.', and 0% schema description coverage. The description adds minimal meaning beyond 'folder path', not specifying format, restrictions, or relationship to MCP_FILE_OPS_ROOT.

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

Purpose5/5

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

The description clearly states the verb 'List' and the resource 'files directly inside a folder within MCP_FILE_OPS_ROOT', distinguishing it from siblings like 'list_directories' which lists directories.

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?

No guidance is provided on when to use this tool versus alternatives like 'list_directories' or 'read_file'. There is no mention of when not to use it or prerequisites.

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/penguinszp001/mcp-server-demo'

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