Skip to main content
Glama

check_before_modification

Verify if a file can be modified by checking AI metadata rules before making changes to ensure compliance and prevent unauthorized alterations.

Instructions

Check if a file can be modified according to AI metadata rules

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file to check

Implementation Reference

  • MCP server tool handler for 'check_before_modification' that parses file metadata, retrieves approval status, calls RuleEngine for validation, and returns the result.
    case 'check_before_modification': {
      const filePath = args.filePath as string;
      const metadata = await this.metadataParser.parseFileMetadata(filePath);
      const approvals = await this.memoryManager.getFileApprovalStatus(filePath);
      const checkResult = await this.ruleEngine.checkBeforeModification(filePath, metadata, approvals);
      return { content: [{ type: 'text', text: JSON.stringify(checkResult, null, 2) }] };
    }
  • src/index.ts:628-638 (registration)
    Registration of the 'check_before_modification' tool in the MCP server's tool list, including name, description, and input schema.
    {
      name: 'check_before_modification',
      description: 'Check if a file can be modified according to AI metadata rules',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: { type: 'string', description: 'Path to the file to check' }
        },
        required: ['filePath']
      }
    },
  • Input schema definition for the 'check_before_modification' tool, specifying the required 'filePath' parameter.
      inputSchema: {
        type: 'object',
        properties: {
          filePath: { type: 'string', description: 'Path to the file to check' }
        },
        required: ['filePath']
      }
    },
  • Core logic implementation in RuleEngine that performs the actual checks for file modification permissions, approvals, risks, stability, and applies enabled rules.
    async checkBeforeModification(filePath: string, metadata: AIMetadata | null, approvals: ApprovalStatus | null): Promise<{
      allowed: boolean;
      reasons: string[];
      warnings: string[];
    }> {
      const result = {
        allowed: true,
        reasons: [] as string[],
        warnings: [] as string[]
      };
    
      if (!metadata) {
        result.warnings.push('No @ai-metadata found in file');
        return result;
      }
    
      // Check edit permissions
      if (metadata.editPermissions === 'read-only') {
        result.allowed = false;
        result.reasons.push('File is marked as read-only');
      }
    
      // Check if file requires dev approval
      if (metadata.breakingChangesRisk === 'high' && (!approvals?.devApproved)) {
        result.allowed = false;
        result.reasons.push('High-risk file requires dev approval before modification');
      }
    
      // Check if review is required
      if (metadata.reviewRequired && (!approvals?.codeReviewApproved)) {
        result.allowed = false;
        result.reasons.push('File requires code review approval before modification');
      }
    
      // Check stability
      if (metadata.stability === 'deprecated') {
        result.warnings.push('This file is deprecated - consider if modification is necessary');
      }
    
      // Apply custom rules
      for (const rule of this.rules.filter(r => r.enabled)) {
        const ruleResult = this.evaluateRule(rule, metadata, approvals, filePath);
        if (!ruleResult.passed) {
          if (rule.priority > 8) {
            result.allowed = false;
            result.reasons.push(ruleResult.message);
          } else {
            result.warnings.push(ruleResult.message);
          }
        }
      }
    
      return result;
    }
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 checks modification permissions based on 'AI metadata rules,' but doesn't explain what these rules entail, whether the check is read-only, if it requires specific permissions, or what the output might be (e.g., a boolean, detailed status). This leaves significant gaps in understanding the tool's behavior and implications.

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 that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action ('Check') and resource ('file'), making it easy to parse. Every part of the sentence contributes to understanding, earning its place with no waste.

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 of checking modification permissions based on 'AI metadata rules,' the description is incomplete. With no annotations and no output schema, it fails to explain behavioral aspects like what the check entails, potential outcomes, or error conditions. The description alone is insufficient for an agent to fully understand how to use this tool effectively in context.

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 100% description coverage, with 'filePath' clearly documented as 'Path to the file to check.' The description adds no additional parameter semantics beyond this, as it doesn't elaborate on format constraints or examples. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract from the schema's information.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Check if a file can be modified according to AI metadata rules.' It specifies the verb ('check') and resource ('file'), and while it doesn't explicitly differentiate from all siblings, it implies a distinct function related to modification permissions based on metadata rules, which is more specific than generic file operations like 'get_file_approval_status' or 'update_file_metadata'.

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 explicit guidance on when to use this tool versus alternatives. It mentions 'AI metadata rules' but doesn't clarify prerequisites, context, or exclusions. For example, it doesn't specify if this should be used before attempting modifications or how it differs from sibling tools like 'get_file_approval_status', leaving the agent to infer usage scenarios without clear direction.

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