Skip to main content
Glama

get_file_last_editor

Retrieve the most recent editor of a file by examining its Git commit history. Use this tool to identify who last modified a specific file path for tracking changes and accountability.

Instructions

Get the last editor of a file from Git history

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file

Implementation Reference

  • MCP tool handler for 'get_file_last_editor' that extracts filePath argument, calls GitUtils.getFileLastEditor, and returns formatted response.
    case 'get_file_last_editor': { const filePath = args.filePath as string; const lastEditor = await this.gitUtils.getFileLastEditor(filePath); if (lastEditor) { return { content: [{ type: 'text', text: `Last editor of ${filePath}: ${lastEditor}` }] }; } else { return { content: [{ type: 'text', text: `Could not determine last editor for: ${filePath}` }] }; } }
  • src/index.ts:766-775 (registration)
    Tool registration in listTools response, defining name, description, and input schema for get_file_last_editor.
    name: 'get_file_last_editor', description: 'Get the last editor of a file from Git history', inputSchema: { type: 'object', properties: { filePath: { type: 'string', description: 'Path to the file' } }, required: ['filePath'] } }
  • GitUtils class method getFileLastEditor that checks if git repo and delegates to getLastEditor.
    async getFileLastEditor(filePath: string): Promise<string> { if (!this.isGitRepository()) { return 'unknown'; } return await this.getLastEditor(filePath); }
  • Core implementation in GitUtils.getLastEditor that runs 'git log -1 --pretty=format:%an' to get the last author name from git history.
    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'; } }

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