search
Find files quickly using advanced search options like regex, case sensitivity, and sorting. Specify scope, path, and max results for precise file retrieval.
Instructions
Search for files using Everything Search
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ascending | No | Sort in ascending order | |
| caseSensitive | No | Match case | |
| maxResults | No | Maximum number of results (1-1000, default: 100) | |
| path | No | Search in paths | |
| query | No | Search query | |
| regex | No | Use regular expressions | |
| scope | No | Search scope (default: C:) | |
| sortBy | No | Sort results by | |
| wholeWord | No | Match whole words only |
Implementation Reference
- src/server.js:163-183 (handler)MCP callTool request handler specifically for the 'search' tool: validates arguments using SearchSchema, calls searchFiles, formats the results with helper functions, and returns a text content response.if (name === "search") { const validatedArgs = SearchSchema.parse(args); const results = await searchFiles(validatedArgs); const formattedResults = results.results.length > 0 ? results.results.map((result) => { const size = result.type === "folder" ? "(folder)" : formatFileSize(result.size); const date = formatFileTime(result.date_modified); return `Name: ${result.name}\nPath: ${result.path}\nSize: ${size}\nModified: ${date}\n`; }).join("\n") : "No results found"; const summary = `Found ${results.totalResults} results:\n\n`; return { content: [{ type: "text", text: summary + formattedResults }] }; }
- src/server.js:65-132 (handler)Core handler function that executes the file search by making an HTTP request to the local Everything Search API server with the specified parameters, handles errors, and returns the raw search results.const searchFiles = async (params) => { try { // Add rate limiting await new Promise(resolve => setTimeout(resolve, 100)); // Properly handle scope concatenation const searchQuery = params.scope ? params.scope.endsWith('\\') ? `${params.scope}${params.query}` : `${params.scope}\\${params.query}` : params.query; const response = await axios.get("http://localhost:8011/", { params: { search: searchQuery, json: 1, path_column: 1, size_column: 1, date_modified_column: 1, case: params.caseSensitive ? 1 : 0, wholeword: params.wholeWord ? 1 : 0, regex: params.regex ? 1 : 0, path: params.path ? 1 : 0, count: params.maxResults, offset: params.offset, sort: params.sortBy, ascending: params.ascending ? 1 : 0 }, timeout: 10000 // 10 second timeout }); // Validate response structure if (!response.data || typeof response.data.totalResults === 'undefined') { throw new Error('Invalid response from Everything Search API'); } // Handle empty results according to API documentation if (!response.data.results) { response.data.results = []; response.data.totalResults = 0; } return response.data; } catch (error) { if (axios.isAxiosError(error)) { console.error('Axios error details:', { code: error.code, message: error.message, response: error.response?.data, config: { url: error.config?.url, params: error.config?.params } }); if (error.code === 'ECONNREFUSED') { throw new Error( "Could not connect to Everything Search. Make sure the HTTP server is enabled in Everything's settings (Tools > Options > HTTP Server)." ); } if (error.code === 'ETIMEDOUT') { throw new Error("Everything Search API request timed out. The server might be busy or unresponsive."); } throw new Error(`Everything Search API error: ${error.message}`); } console.error('Non-Axios error:', error); throw error; } };
- src/server.js:7-18 (schema)Zod schema defining the input parameters and validation rules for the 'search' tool.const SearchSchema = z.object({ query: z.string().describe("Search query"), scope: z.string().default("C:").describe("Search scope (default: C:)"), caseSensitive: z.boolean().default(false).describe("Match case"), wholeWord: z.boolean().default(false).describe("Match whole words only"), regex: z.boolean().default(false).describe("Use regular expressions"), path: z.boolean().default(false).describe("Search in paths"), maxResults: z.number().min(1).max(1000).default(32).describe("Maximum number of results (1-1000, default: 32 for HTML, 4294967295 for JSON)"), sortBy: z.enum(['name', 'path', 'size', 'date_modified']).default('name').describe("Sort results by"), ascending: z.boolean().default(true).describe("Sort in ascending order"), offset: z.number().min(0).default(0).describe("Display results from the nth result") });
- src/server.js:144-146 (registration)Registration of the 'search' tool in the MCP server's capabilities declaration, including description and input schema.description: "Search for files using Everything Search", inputSchema: zodToJsonSchema(SearchSchema) }
- src/server.js:152-158 (registration)Registration of the 'listTools' request handler that returns the specification for the 'search' tool.server.setRequestHandler("listTools", async () => ({ tools: [{ name: "search", description: "Search for files using Everything Search", inputSchema: zodToJsonSchema(SearchSchema) }] }));