Skip to main content
Glama

update_last_editor

Updates the last editor field in files using Git author data to maintain accurate contributor records for project tracking.

Instructions

Update @last-editor field in a file with Git author information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file to update

Implementation Reference

  • MCP server tool handler for 'update_last_editor' that delegates to GitUtils.updateLastEditorInFile and returns success/error response
    case 'update_last_editor': {
      const filePath = args.filePath as string;
      const result = await this.gitUtils.updateLastEditorInFile(filePath);
      if (result.success) {
        return { content: [{ type: 'text', text: `Last editor updated successfully for: ${filePath}. New editor: ${result.newEditor}` }] };
      } else {
        return { content: [{ type: 'text', text: `Failed to update last editor for: ${filePath}. Reason: ${result.reason}` }] };
      }
    }
  • Core implementation of updateLastEditorInFile: gets last editor from Git, updates @last-editor metadata comment in file, writes if changed
    async updateLastEditorInFile(filePath: string): Promise<{success: boolean, newEditor?: string, reason?: string}> {
      try {
        const relativePath = path.relative(this.projectRoot, filePath);
        const lastEditor = await this.getFileLastEditor(relativePath);
        
        if (lastEditor === 'unknown') {
          return { success: false, reason: 'Could not determine last editor from Git' };
        }
        
        const content = await fs.readFile(filePath, 'utf8');
        const updatedContent = content.replace(
          /^(\s*\*\s*@last-editor:\s*).*$/m,
          `$1${lastEditor}`
        );
        
        if (content !== updatedContent) {
          await fs.writeFile(filePath, updatedContent, 'utf8');
          return { success: true, newEditor: lastEditor };
        }
        
        return { success: false, reason: 'File already up to date' };
      } catch (error) {
        console.error(`Error updating last editor in ${filePath}:`, error);
        return { success: false, reason: `Error: ${error}` };
      }
    }
  • src/index.ts:746-756 (registration)
    Tool registration in ListTools response, including name, description, and input schema
    {
      name: 'update_last_editor',
      description: 'Update @last-editor field in a file with Git author information',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: { type: 'string', description: 'Path to the file to update' }
        },
        required: ['filePath']
      }
    },
  • Helper method getLastEditor that runs 'git log -1 --pretty=format:%an' to get the last commit author name for a file
    async getLastEditor(filePath: string): Promise<string> {
      try {
        const absolutePath = path.resolve(this.projectRoot, filePath);
        const relativePath = path.relative(this.projectRoot, absolutePath);
        
        // Use git log to get the last author who modified the file
        const command = `git log -1 --pretty=format:"%an" -- "${relativePath}"`;
        const result = execSync(command, { 
          cwd: this.projectRoot, 
          encoding: 'utf8',
          stdio: ['pipe', 'pipe', 'pipe']
        }).trim();
        
        return result || 'unknown';
      } catch (error) {
        console.warn(`Could not get git information for ${filePath}:`, error);
        return 'unknown';
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool updates a field, implying a mutation, but doesn't disclose behavioral traits such as required permissions, whether changes are reversible, potential side effects (e.g., file modification), or error handling. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 front-loads the core action and resource. It wastes no words and is appropriately sized for a simple tool with one parameter. Every part of the sentence earns its place by conveying essential information.

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 tool's mutation nature, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the update entails (e.g., overwriting vs. appending), what Git author information is used, or what the response might be. For a tool that modifies files, more context is needed to ensure safe and correct usage.

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?

Schema description coverage is 100%, so the schema fully documents the 'filePath' parameter. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't specify file format constraints or Git context requirements). With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to.

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 action ('Update'), the target resource ('@last-editor field in a file'), and the source of information ('with Git author information'). It distinguishes itself from siblings like 'get_file_last_editor' (which reads) and 'update_file_metadata' (which updates broader metadata), though it doesn't explicitly name these alternatives. The purpose is specific but could be slightly more differentiated.

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. It doesn't mention prerequisites (e.g., Git repository context), when not to use it, or compare it to siblings like 'update_all_last_editors' (for bulk updates) or 'update_file_metadata' (for other metadata changes). Usage is implied by the action but lacks explicit context.

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