Skip to main content
Glama

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
NameRequiredDescriptionDefault
patternNoFile pattern to search (optional)

Implementation Reference

  • 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)' } } } },
  • 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) }] }; }
  • 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)' } } }

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/keleshteri/mcp-memory'

If you have feedback or need assistance with the MCP directory API, please join our Discord server