Skip to main content
Glama
penguinszp001

mcp-server-demo

list_directories

Lists all directories within a specified folder under the configured root path.

Instructions

List directories directly inside a folder within MCP_FILE_OPS_ROOT.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the list_directories MCP tool. Resolves the path via _resolve_file_ops_path (which enforces the FILE_OPS_ROOT sandbox), validates it's a directory, then returns a sorted JSON list of subdirectory names.
    @mcp.tool()
    def list_directories(path: str = ".") -> str:
        """List directories 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}")
    
        directories = sorted(p.name for p in target.iterdir() if p.is_dir())
        return json.dumps(directories, indent=2)
  • server.py:181-181 (registration)
    The tool is registered via the @mcp.tool() decorator on FastMCP instance, which automatically registers list_directories as an MCP tool.
    @mcp.tool()
  • Helper function used by list_directories to resolve and sandbox paths within the configured MCP_FILE_OPS_ROOT directory.
    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
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It states it lists directories directly inside a folder (non-recursive) and within MCP_FILE_OPS_ROOT. However, it omits details like handling of hidden directories, symlinks, error cases, permissions, or return structure.

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 concise sentence with no wasted words. It is front-loaded and direct, though it could be slightly expanded to include key behavioral details without losing brevity.

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 the tool's simplicity and available output schema, the description lacks completeness. It does not mention edge cases, path interpretation (relative/absolute), error handling, or how the tool integrates with sibling tools like list_files. The scope is noted but additional context is missing.

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?

Input schema has one parameter (path) with 0% description coverage. The description adds no additional meaning about the parameter's format, constraints, or default behavior, leaving the agent to infer from the schema alone.

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 tool lists directories directly inside a folder, and scopes it to MCP_FILE_OPS_ROOT. The verb 'List' and resource 'directories' are specific, but it does not distinguish from sibling list_files, though the naming implies the difference.

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 on when to use this tool versus alternatives like list_files or inspect_file. No mention of prerequisites, context, or when not to use it.

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