Skip to main content
Glama

git_log

Retrieve commit history from a Git repository to track changes, review modifications, and understand project evolution.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo.
maxCountNo

Implementation Reference

  • Executes the git log command with specified path and maxCount, parses the output into commits, and returns JSON-formatted text content.
    async ({ path: gitPath, maxCount }) => { return wrapToolExecution(async () => { const { stdout } = await execAsync( `git log -${maxCount} --pretty=format:"%H|%an|%ad|%s" --date=iso`, { cwd: gitPath } ); const commits = parseGitLog(stdout); return { content: [{ type: "text" as const, text: JSON.stringify(commits, null, 2) }] }; }, { errorCode: ERROR_CODES.GIT_OPERATION, context: "Failed to get git log" }); }
  • Zod schema defining optional 'path' (git directory, default '.') and 'maxCount' (number of commits, default from constants).
    { path: z.string().optional().default("."), maxCount: z.number().optional().default(DEFAULTS.MAX_COMMITS) },
  • Registers the 'git_log' tool with the MCP server, providing schema and handler function.
    function registerGitLog(server: McpServer): void { server.tool("git_log", { path: z.string().optional().default("."), maxCount: z.number().optional().default(DEFAULTS.MAX_COMMITS) }, async ({ path: gitPath, maxCount }) => { return wrapToolExecution(async () => { const { stdout } = await execAsync( `git log -${maxCount} --pretty=format:"%H|%an|%ad|%s" --date=iso`, { cwd: gitPath } ); const commits = parseGitLog(stdout); return { content: [{ type: "text" as const, text: JSON.stringify(commits, null, 2) }] }; }, { errorCode: ERROR_CODES.GIT_OPERATION, context: "Failed to get git log" }); } ); }
  • Parses the stdout from 'git log --pretty=format:"%H|%an|%ad|%s"' into an array of GitCommit objects with abbreviated hash.
    function parseGitLog(stdout: string): GitCommit[] { const lines = stdout.trim().split('\n').filter(line => line); return lines.map(line => { const [hash, author, date, message] = line.split('|'); return { hash: hash.substring(0, 8), author, date, message }; }); }
  • src/index.ts:67-67 (registration)
    Calls registerDevTools which includes registerGitLog to register dev tools including git_log on the main MCP server.
    registerDevTools(server);

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/ishuru/open-mcp'

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