Skip to main content
Glama

list_roots

Discover accessible file system directories to prepare for reading files in architectural decision record analysis.

Instructions

List available file system roots that can be accessed. Use this to discover what directories are available before reading files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler logic for the list_roots tool. This method returns all configured filesystem roots as Root objects, implementing MCP best practices for file access control.
    listRoots(): Root[] {
      return Array.from(this.roots.values());
    }
  • Tool schema and metadata registration in the central TOOL_CATALOG. Defines input schema (no parameters), description, and properties for dynamic tool discovery.
    TOOL_CATALOG.set('list_roots', {
      name: 'list_roots',
      shortDescription: 'List root directories',
      fullDescription: 'Lists configured root directories.',
      category: 'file-system',
      complexity: 'simple',
      tokenCost: { min: 50, max: 200 },
      hasCEMCPDirective: true, // Phase 4.3: Simple tool - root listing
      relatedTools: ['read_directory', 'list_directory'],
      keywords: ['roots', 'list', 'directories'],
      requiresAI: false,
      inputSchema: {
        type: 'object',
        properties: {},
      },
    });
  • RootManager class that manages the filesystem roots. The list_roots tool uses this class's listRoots() method and roots are predefined in the constructor.
    export class RootManager {
      private roots: Map<string, Root> = new Map();
    
      /**
       * Initialize root manager with project and ADR paths
       *
       * @param projectPath - Path to the project root directory
       * @param adrDirectory - Path to the ADR directory
       */
      constructor(projectPath: string, adrDirectory: string) {
        // Root 1: Project directory (entire codebase)
        this.roots.set('project', {
          name: 'project',
          path: resolve(projectPath),
          description: 'Project source code, configuration, and documentation',
        });
    
        // Root 2: ADR directory (may be inside project, but worth explicit access)
        const resolvedAdrPath = resolve(adrDirectory);
        this.roots.set('adrs', {
          name: 'adrs',
          path: resolvedAdrPath,
          description: 'Architectural Decision Records',
        });
      }
    
      /**
       * Check if a path is within accessible roots
       *
       * @param targetPath - Path to check (can be relative or absolute)
       * @returns true if path is within any root, false otherwise
       *
       * @example
       * ```typescript
       * if (!rootManager.isPathAllowed(userPath)) {
       *   throw new Error('Access denied: Path is outside accessible roots');
       * }
       * ```
       */
      isPathAllowed(targetPath: string): boolean {
        const resolved = resolve(targetPath);
        for (const root of this.roots.values()) {
          if (resolved.startsWith(root.path)) {
            return true;
          }
        }
        return false;
      }
    
      /**
       * List all accessible roots
       *
       * @returns Array of root definitions
       *
       * @example
       * ```typescript
       * const roots = rootManager.listRoots();
       * roots.forEach(root => {
       *   console.log(`${root.name}: ${root.path}`);
       * });
       * ```
       */
      listRoots(): Root[] {
        return Array.from(this.roots.values());
      }
    
      /**
       * Get which root a path belongs to
       *
       * @param targetPath - Path to check
       * @returns Root that contains this path, or null if outside all roots
       *
       * @example
       * ```typescript
       * const root = rootManager.getRootForPath('/path/to/project/src/index.ts');
       * if (root) {
       *   console.log(`File is in ${root.name} root`);
       * }
       * ```
       */
      getRootForPath(targetPath: string): Root | null {
        const resolved = resolve(targetPath);
        for (const root of this.roots.values()) {
          if (resolved.startsWith(root.path)) {
            return root;
          }
        }
        return null;
      }
    
      /**
       * Get the relative path from root
       *
       * @param targetPath - Path to get relative path for
       * @returns Relative path from root, or null if outside all roots
       *
       * @example
       * ```typescript
       * const relPath = rootManager.getRelativePathFromRoot('/path/to/project/src/index.ts');
       * // Returns: 'src/index.ts'
       * ```
       */
      getRelativePathFromRoot(targetPath: string): string | null {
        const root = this.getRootForPath(targetPath);
        if (!root) {
          return null;
        }
        return relative(root.path, resolve(targetPath));
      }
    
      /**
       * Add a custom root (useful for testing or dynamic root management)
       *
       * @param name - Unique identifier for the root
       * @param path - Absolute path to the root directory
       * @param description - Human-readable description
       */
      addRoot(name: string, path: string, description: string): void {
        this.roots.set(name, {
          name,
          path: resolve(path),
          description,
        });
      }
    
      /**
       * Remove a root by name
       *
       * @param name - Name of the root to remove
       * @returns true if root was removed, false if not found
       */
      removeRoot(name: string): boolean {
        return this.roots.delete(name);
      }
    }
  • Tool listed in server context generator for LLM awareness of available tools.
    { name: 'list_roots', description: 'List available filesystem roots for operations' },
    { name: 'read_directory', description: 'Read directory contents and metadata' },
    { name: 'read_file', description: 'Read file contents from filesystem' },
    { name: 'write_file', description: 'Write content to filesystem' },
    { name: 'list_directory', description: 'List directory contents with filtering' },
  • Categorization logic includes 'list_roots' in File System Operations category.
    name.includes('list_roots') ||
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. It mentions the tool lists 'available' roots, implying a read-only operation, but doesn't disclose behavioral traits like whether it requires permissions, returns structured data, has rate limits, or what format the output takes. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 two sentences that are front-loaded with the core purpose and followed by practical usage guidance. Every word earns its place, with no redundancy or fluff, making it highly efficient and well-structured.

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 (0 parameters, no output schema, no annotations), the description is adequate but incomplete. It explains the purpose and usage context but lacks details on output format, permissions, or error handling. For a discovery tool, this is minimally viable but leaves room for improvement in behavioral transparency.

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 tool has 0 parameters, and the input schema has 100% description coverage (though empty). The description doesn't need to add parameter semantics, so it meets the baseline of 4 for tools with no parameters, as there's nothing to compensate for.

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 with a specific verb ('List') and resource ('available file system roots'), and explains the outcome ('discover what directories are available'). It distinguishes itself from siblings like 'list_directory' or 'read_directory' by focusing on roots rather than directory contents. However, it doesn't explicitly differentiate from all siblings, keeping it at 4 instead of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('before reading files'), which implicitly suggests it's for discovery purposes. It doesn't explicitly state when not to use it or name specific alternatives, but the guidance is practical and helpful for an agent understanding the workflow.

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/tosin2013/mcp-adr-analysis-server'

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