search_files
Search for files using wildcard patterns in specified directories to locate documents, applications, or system files on Windows systems.
Instructions
搜索文件(支持通配符)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | 搜索目录 | |
| pattern | Yes | 搜索模式(如 *.txt) |
Input Schema (JSON Schema)
{
"properties": {
"directory": {
"description": "搜索目录",
"type": "string"
},
"pattern": {
"description": "搜索模式(如 *.txt)",
"type": "string"
}
},
"required": [
"directory",
"pattern"
],
"type": "object"
}
Implementation Reference
- src/tools/filesystem.js:211-222 (handler)The core handler function that executes the search_files tool by running a Windows 'dir' command to find files matching the pattern in the directory.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: [] }; } }
- src/tools/filesystem.js:94-105 (schema)The schema definition for the search_files tool, including input parameters for directory and pattern.{ name: 'search_files', description: '搜索文件(支持通配符)', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: '搜索目录' }, pattern: { type: 'string', description: '搜索模式(如 *.txt)' }, }, required: ['directory', 'pattern'], }, },
- src/tools/filesystem.js:131-132 (registration)The dispatch/registration in the executeTool method's switch statement that routes to the searchFiles handler.case 'search_files': return await this.searchFiles(args.directory, args.pattern);
- src/tools/filesystem.js:111-111 (registration)Inclusion of 'search_files' in the canHandle tools list.'delete_file', 'copy_file', 'move_file', 'search_files'];
- src/tools/filesystem.js:95-95 (registration)The name registration within the tool definitions array.name: 'search_files',