Skip to main content
Glama

parse_file_metadata

Extract AI metadata from files to enable persistent memory and project awareness for coding assistants.

Instructions

Parse AI metadata from a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file

Implementation Reference

  • src/index.ts:652-662 (registration)
    Registration of the 'parse_file_metadata' tool in the MCP server, including name, description, and input schema requiring 'filePath'.
    {
      name: 'parse_file_metadata',
      description: 'Parse AI metadata from a file',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: { type: 'string', description: 'Path to the file' }
        },
        required: ['filePath']
      }
    },
  • Tool handler in the switch statement that processes 'parse_file_metadata' calls: extracts filePath, invokes MetadataParser.parseFileMetadata, and returns JSON-formatted result.
    case 'parse_file_metadata': {
      const filePath = args.filePath as string;
      const parsedMetadata = await this.metadataParser.parseFileMetadata(filePath);
      return { content: [{ type: 'text', text: JSON.stringify(parsedMetadata, null, 2) }] };
    }
  • Core implementation of file metadata parsing: reads file content and delegates to extractMetadataFromContent, with error handling.
    async parseFileMetadata(filePath: string): Promise<AIMetadata | null> {
      try {
        const content = await fs.readFile(filePath, 'utf-8');
        return this.extractMetadataFromContent(content);
      } catch (error) {
        console.error(chalk.red(`Error reading file ${filePath}:`), error);
        return null;
      }
    }
  • Helper function that extracts and parses the @ai-metadata block from file content using regex and field-specific parsers.
    extractMetadataFromContent(content: string): AIMetadata | null {
      // Look for @ai-metadata block
      const metadataRegex = /\/\*\*[\s\S]*?@ai-metadata[\s\S]*?\*\//;
      const match = content.match(metadataRegex);
      
      if (!match) {
        return null;
      }
    
      const metadataBlock = match[0];
      const metadata: AIMetadata = {};
    
      // Parse each field
      this.parseField(metadataBlock, '@class:', (value) => metadata.class = value);
      this.parseField(metadataBlock, '@description:', (value) => metadata.description = value);
      this.parseField(metadataBlock, '@last-update:', (value) => metadata.lastUpdate = value);
      this.parseField(metadataBlock, '@last-editor:', (value) => metadata.lastEditor = value);
      this.parseField(metadataBlock, '@changelog:', (value) => metadata.changelog = value);
      this.parseField(metadataBlock, '@stability:', (value) => metadata.stability = value as any);
      this.parseField(metadataBlock, '@edit-permissions:', (value) => metadata.editPermissions = value as any);
      this.parseField(metadataBlock, '@breaking-changes-risk:', (value) => metadata.breakingChangesRisk = value as any);
      this.parseField(metadataBlock, '@review-required:', (value) => metadata.reviewRequired = value === 'true');
      this.parseField(metadataBlock, '@ai-context:', (value) => metadata.aiContext = value);
    
      // Parse arrays
      this.parseArrayField(metadataBlock, '@dependencies:', (value) => metadata.dependencies = value);
      this.parseArrayField(metadataBlock, '@tests:', (value) => metadata.tests = value);
    
      // Parse method permissions (JSON object)
      this.parseJsonField(metadataBlock, '@method-permissions:', (value) => metadata.methodPermissions = value);
    
      // Parse approvals
      metadata.approvals = this.parseApprovals(metadataBlock);
    
      return metadata;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool parses metadata, implying a read-only operation, but doesn't clarify aspects like whether it requires specific file permissions, what happens if the file doesn't exist or lacks metadata, or if there are rate limits. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior and constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Parse AI metadata from a file'. It's front-loaded with the core action and target, with zero wasted words. This makes it easy to scan and understand quickly, earning a high score for conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (parsing metadata from files), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'AI metadata' includes, the return format, error handling, or how it differs from sibling tools. For a tool that likely involves file I/O and data extraction, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 1 parameter with 100% description coverage ('filePath' is documented as 'Path to the file'), so the schema does the heavy lifting. The description adds no additional meaning about parameters, such as file format expectations or metadata parsing details. With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Parse AI metadata from a file' clearly states the action (parse) and target (AI metadata from a file), which is better than a tautology. However, it's somewhat vague about what 'AI metadata' entails and doesn't differentiate from siblings like 'find_files_with_metadata' or 'update_file_metadata', leaving ambiguity about its specific scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'find_files_with_metadata' (which likely searches for files based on metadata) and 'update_file_metadata' (which modifies metadata), there's no indication of this tool's role—e.g., whether it's for reading metadata, when it's preferred over other tools, or any prerequisites. This lack of context makes it hard for an agent to choose appropriately.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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