find_files_with_metadata
Locate files containing AI metadata to identify data sources and track AI-generated content within projects.
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 function that searches for files matching the given pattern (defaulting to common source files), parses AI metadata in each file using parseFileMetadata, and returns the absolute paths of files that contain valid AI 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:678-683 (schema)Input schema definition for the tool, specifying an optional 'pattern' parameter of type string for glob pattern matching.inputSchema: { type: 'object', properties: { pattern: { type: 'string', description: 'File pattern to search (optional)' } } }
- src/index.ts:676-684 (registration)Tool registration in the MCP server's ListTools handler, defining the tool name, description, and input schema.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)Dispatch handler in the MCP server's CallToolRequestHandler that extracts the pattern argument, calls the metadataParser's findFilesWithMetadata method, and returns the result as JSON string in the MCP response format.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) }] }; }