find_files_with_metadata
Locate files containing AI metadata within the MCP Memory Server by specifying a search pattern. Enhances project awareness and ensures efficient management of coding sessions and metadata.
Instructions
Find all files that contain AI metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | No | File pattern to search (optional) |
Implementation Reference
- src/metadata-parser.ts:214-236 (handler)Core handler implementation that searches for files matching a glob pattern (default: common source code files), parses each file for @ai-metadata blocks using parseFileMetadata, and returns absolute paths of files containing such metadata.async findFilesWithMetadata(pattern: string = '**/*.{js,ts,jsx,tsx,py,java,cpp,c,h}'): Promise<string[]> { try { const files = await glob(pattern, { cwd: this.projectRoot, absolute: true, ignore: ['**/node_modules/**', '**/dist/**', '**/.git/**'] }); const filesWithMetadata: string[] = []; for (const file of files) { const metadata = await this.parseFileMetadata(file); if (metadata) { filesWithMetadata.push(file); } } return filesWithMetadata; } catch (error) { console.error(chalk.red('Error finding files with metadata:'), error); return []; } }
- src/index.ts:675-684 (registration)Tool registration in the MCP server's ListTools handler, defining the tool name, description, and input schema (optional 'pattern' string).{ name: 'find_files_with_metadata', description: 'Find all files that contain AI metadata', inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'File pattern to search (optional)' } } } },
- src/index.ts:861-865 (handler)MCP CallToolRequest dispatch handler that extracts the 'pattern' argument and delegates execution to MetadataParser.findFilesWithMetadata, returning JSON-stringified results.case 'find_files_with_metadata': { const pattern = args.pattern as string | undefined; const files = await this.metadataParser.findFilesWithMetadata(pattern); return { content: [{ type: 'text', text: JSON.stringify(files, null, 2) }] }; }
- src/index.ts:678-683 (schema)Input schema definition specifying an optional 'pattern' property of type string for glob pattern.inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'File pattern to search (optional)' } } }