Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

list_directory

Retrieve and display the contents of a specified directory path to view files and folders within Windows systems.

Instructions

列出目录内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes目录路径

Implementation Reference

  • The handler function that implements the list_directory tool logic. It reads the directory using fs.readdir with file types, maps files to objects with name, type (directory/file), and full path, and returns success with items or error.
    async listDirectory(dirPath) {
      try {
        const files = await fs.readdir(dirPath, { withFileTypes: true });
        const items = files.map(file => ({
          name: file.name,
          type: file.isDirectory() ? 'directory' : 'file',
          path: path.join(dirPath, file.name),
        }));
        return { success: true, items, path: dirPath };
      } catch (error) {
        return { success: false, error: error.message };
      }
    }
  • The schema definition for the list_directory tool, including name, description, and inputSchema requiring a 'path' string.
    {
      name: 'list_directory',
      description: '列出目录内容',
      inputSchema: {
        type: 'object',
        properties: {
          path: { type: 'string', description: '目录路径' },
        },
        required: ['path'],
      },
    },
  • Registration/dispatch in the executeTool method switch statement, which calls the listDirectory handler for the 'list_directory' tool.
    case 'list_directory':
      return await this.listDirectory(args.path);
  • Tool name listed in the canHandle method's tools array for checking if the class can handle 'list_directory'.
    const tools = ['read_file', 'write_file', 'list_directory', 'create_directory', 
                   'delete_file', 'copy_file', 'move_file', 'search_files'];

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/eva-wanxin-git/windows-automation-mcp'

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