Skip to main content
Glama

git_log

Retrieve recent Git commit history for a repository to track changes, review updates, and monitor project activity. Specify path and commit count for targeted analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNo.
maxCountNo

Implementation Reference

  • Handler function that runs the git log command, parses output with parseGitLog, and returns JSON array of 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" }); }
  • Zod input schema defining optional 'path' (git directory) and 'maxCount' (number of commits).
    { path: z.string().optional().default("."), maxCount: z.number().optional().default(DEFAULTS.MAX_COMMITS) },
  • Registers the 'git_log' tool with the MCP server, including 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" }); } ); }
  • Helper function to parse git log output into structured GitCommit objects.
    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 }; }); }

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