Skip to main content
Glama

filesystem

Perform file system operations on Windows including directory browsing, file reading, searching, and basic file management tasks.

Instructions

Comprehensive file system operations including directory browsing, file reading, searching, and basic file operations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe file system action to perform
pathNoFile or directory path (required for most actions)
patternNoSearch pattern for file searching (supports wildcards)
recursiveNoWhether to search recursively (default: false)
max_depthNoMaximum depth for recursive operations (default: 3)
size_thresholdNoSize threshold in MB for finding large files (default: 100)

Implementation Reference

  • The main execution handler for the 'filesystem' tool. It processes the input arguments, dispatches to specific sub-methods based on the 'action' parameter, and handles errors.
    async run(args: {
      action: string;
      path?: string;
      pattern?: string;
      recursive?: boolean;
      max_depth?: number;
      size_threshold?: number;
    }) {
      try {
        switch (args.action) {
          case "list_directory":
            return await this.listDirectory(args.path || "C:\\", args.recursive, args.max_depth);
          case "read_file":
            return await this.readFile(args.path!);
          case "search_files":
            return await this.searchFiles(args.pattern!, args.path, args.recursive);
          case "get_file_info":
            return await this.getFileInfo(args.path!);
          case "find_large_files":
            return await this.findLargeFiles(args.path || "C:\\", args.size_threshold!);
          case "get_disk_usage":
            return await this.getDiskUsage();
          default:
            throw new Error(`Unknown action: ${args.action}`);
        }
      } catch (error: any) {
        return {
          content: [{
            type: "text",
            text: `❌ File system operation failed: ${error.message}`
          }],
          isError: true
        };
      }
    },
  • The input schema defining the parameters accepted by the 'filesystem' tool, including action types and optional parameters.
    parameters: {
      type: "object",
      properties: {
        action: {
          type: "string",
          enum: ["list_directory", "read_file", "search_files", "get_file_info", "find_large_files", "get_disk_usage"],
          description: "The file system action to perform"
        },
        path: {
          type: "string",
          description: "File or directory path (required for most actions)"
        },
        pattern: {
          type: "string",
          description: "Search pattern for file searching (supports wildcards)"
        },
        recursive: {
          type: "boolean",
          description: "Whether to search recursively (default: false)",
          default: false
        },
        max_depth: {
          type: "number",
          description: "Maximum depth for recursive operations (default: 3)",
          default: 3
        },
        size_threshold: {
          type: "number",
          description: "Size threshold in MB for finding large files (default: 100)",
          default: 100
        }
      },
      required: ["action"]
    },
  • src/index.ts:27-31 (registration)
    Registration of the 'filesystem' tool in the MCP server's list of available tools.
    {
      name: fileSystemTool.name,
      description: fileSystemTool.description,
      inputSchema: fileSystemTool.parameters
    },
  • src/index.ts:71-72 (registration)
    Dispatch handler in the MCP server that routes calls to the 'filesystem' tool to its run method.
    case "filesystem":
      return await fileSystemTool.run(args as any);
  • Helper method for listing directory contents, used by the 'list_directory' action.
    async listDirectory(dirPath: string, recursive = false, maxDepth = 3) {
      try {
        const items = await fs.readdir(dirPath, { withFileTypes: true });
        let result = `# Directory Listing: ${dirPath}\n\n`;
        
        const directories: string[] = [];
        const files: string[] = [];
        
        for (const item of items) {
          const fullPath = path.join(dirPath, item.name);
          try {
            const stats = await fs.stat(fullPath);
            const size = item.isFile() ? this.formatFileSize(stats.size) : "";
            const modified = stats.mtime.toISOString().split('T')[0];
            
            if (item.isDirectory()) {
              directories.push(`📁 ${item.name}/ (${modified})`);
            } else {
              files.push(`📄 ${item.name} (${size}, ${modified})`);
            }
          } catch {
            if (item.isDirectory()) {
              directories.push(`📁 ${item.name}/ (access denied)`);
            } else {
              files.push(`📄 ${item.name} (access denied)`);
            }
          }
        }
        
        result += "## Directories:\n" + directories.join("\n") + "\n\n";
        result += "## Files:\n" + files.join("\n");
        
        if (recursive && maxDepth > 0) {
          result += "\n\n## Subdirectories (recursive):\n";
          for (const item of items) {
            if (item.isDirectory()) {
              try {
                const subPath = path.join(dirPath, item.name);
                const subResult = await this.listDirectory(subPath, true, maxDepth - 1);
                result += `\n### ${item.name}/\n${subResult.content[0].text}\n`;
              } catch {
                result += `\n### ${item.name}/ (access denied)\n`;
              }
            }
          }
        }
        
        return {
          content: [{ type: "text", text: result }]
        };
      } catch (error: any) {
        throw new Error(`Cannot list directory ${dirPath}: ${error.message}`);
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. While it mentions 'basic file operations,' it doesn't specify what these include (create, delete, modify?), permissions required, rate limits, or error conditions. The description is too vague about behavioral traits beyond the high-level categorization.

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, efficient sentence that front-loads the main purpose. It could be slightly more structured by separating operation categories, but it avoids redundancy and wastes no words.

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 complexity (6 parameters, multiple actions) and lack of annotations/output schema, the description is inadequate. It doesn't explain return values, error handling, or the scope of 'basic file operations.' For a multi-action tool with no structured behavioral hints, more completeness 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%, so the schema already documents all parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. It mentions 'searching' which aligns with the 'search_files' action and 'pattern' parameter, but provides no additional semantic context.

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 as 'comprehensive file system operations' and lists specific operations (directory browsing, file reading, searching, basic file operations). It distinguishes from siblings like 'network' or 'process_manager' by focusing on filesystem functionality, though it doesn't explicitly differentiate from potential overlapping tools.

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 prerequisites, limitations, or when specific actions within the tool should be used. With siblings like 'system_info' that might overlap with disk usage reporting, there's no contextual differentiation.

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/guangxiangdebizi/windows-system-mcp'

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