Skip to main content
Glama
eva-wanxin-git

Windows Automation MCP Server

search_files

Find files on Windows systems using wildcard patterns to locate documents, media, or data in specified directories.

Instructions

搜索文件(支持通配符)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directoryYes搜索目录
patternYes搜索模式(如 *.txt)

Implementation Reference

  • The handler function that executes the file search using Windows 'dir' command via child_process.execAsync to list files matching the pattern.
    async searchFiles(directory, pattern) { try { const { stdout } = await execAsync( `dir /s /b "${path.join(directory, pattern)}"`, { shell: 'cmd.exe' } ); const files = stdout.trim().split('\n').filter(f => f); return { success: true, files, count: files.length }; } catch (error) { return { success: false, error: error.message, files: [] }; } }
  • Input schema definition for the 'search_files' tool, specifying required 'directory' and 'pattern' parameters.
    { name: 'search_files', description: '搜索文件(支持通配符)', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: '搜索目录' }, pattern: { type: 'string', description: '搜索模式(如 *.txt)' }, }, required: ['directory', 'pattern'], }, },
  • The executeTool method dispatches 'search_files' calls to the searchFiles handler via switch case.
    async executeTool(name, args) { switch (name) { case 'read_file': return await this.readFile(args.path); case 'write_file': return await this.writeFile(args.path, args.content); case 'list_directory': return await this.listDirectory(args.path); case 'create_directory': return await this.createDirectory(args.path); case 'delete_file': return await this.deleteFile(args.path); case 'copy_file': return await this.copyFile(args.source, args.destination); case 'move_file': return await this.moveFile(args.source, args.destination); case 'search_files': return await this.searchFiles(args.directory, args.pattern); default: throw new Error(`未知工具: ${name}`); } }
  • The canHandle method checks if the tool module handles 'search_files' by including it in the tools array.
    canHandle(toolName) { const tools = ['read_file', 'write_file', 'list_directory', 'create_directory', 'delete_file', 'copy_file', 'move_file', 'search_files']; return tools.includes(toolName); }

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