Skip to main content
Glama
safurrier

MCP Filesystem Server

list_allowed_directories

Retrieve accessible directories for secure file operations in the MCP Filesystem Server.

Instructions

Returns the list of directories that this server is allowed to access.

Args:
    ctx: MCP context

Returns:
    List of allowed directories

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function decorated with @mcp.tool(), which implements the tool logic by retrieving allowed directories from shared components and formatting them for output. This also serves as the registration point.
    @mcp.tool()
    async def list_allowed_directories(ctx: Context) -> str:
        """Returns the list of directories that this server is allowed to access.
    
        Args:
            ctx: MCP context
    
        Returns:
            List of allowed directories
        """
        components = get_components()
        allowed_dirs = components["allowed_dirs"]
        return f"Allowed directories:\n{os.linesep.join(allowed_dirs)}"
  • Helper function that initializes and caches shared components, including the 'allowed_dirs' list used by the tool handler.
    def get_components() -> Dict[str, Any]:
        """Initialize and return shared components.
    
        Returns cached components if already initialized.
    
        Returns:
            Dictionary with initialized components
        """
        # Return cached components if available
        if _components_cache:
            return _components_cache
    
        # Initialize components
        allowed_dirs_typed: List[Union[str, Path]] = get_allowed_dirs()
        validator = PathValidator(allowed_dirs_typed)
        operations = FileOperations(validator)
        advanced = AdvancedFileOperations(validator, operations)
        grep = GrepTools(validator)
    
        # Store in cache
        _components = {
            "validator": validator,
            "operations": operations,
            "advanced": advanced,
            "grep": grep,
            "allowed_dirs": validator.get_allowed_dirs(),
        }
    
        # Update cache
        _components_cache.update(_components)
    
        logger.info(
            f"Initialized filesystem components with allowed directories: {validator.get_allowed_dirs()}"
        )
    
        return _components
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns a list but doesn't describe the format (e.g., array of strings, objects), any permissions or authentication needs, rate limits, or error conditions. This is a read-only operation implied by 'Returns,' but without annotations, the description lacks critical behavioral details for safe invocation.

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

Conciseness3/5

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

The description is structured with sections for 'Args' and 'Returns,' but it's somewhat verbose for a simple tool. The first sentence clearly states the purpose, but the additional sections could be more streamlined. It earns its place by providing basic info, but there's room for improvement in efficiency.

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 (0 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain the return value format (e.g., what 'List of allowed directories' entails—structure, data types) or any behavioral aspects like error handling. For a tool that interacts with server permissions, more context on output and usage constraints is needed.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description includes an 'Args' section mentioning 'ctx: MCP context,' which adds minimal context beyond the empty schema, but this is redundant since the schema already fully defines the parameters. Baseline is 4 for zero parameters, as the description doesn't need to compensate for gaps.

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's purpose: 'Returns the list of directories that this server is allowed to access.' It specifies the verb ('Returns') and resource ('list of directories'), making the function unambiguous. However, it doesn't differentiate from sibling tools like 'list_directory' or 'directory_tree', which also list directories but with different scopes or formats.

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 any prerequisites, context for usage, or exclusions. With sibling tools like 'list_directory' that list directory contents, there's no indication of how this tool differs in application, leaving the agent to infer usage.

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/safurrier/mcp-filesystem'

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