Skip to main content
Glama

git-log

Retrieve recent git commit history for a specified directory, allowing users to define the number of commits to display. Supports error handling for non-git directories and provides a default limit of 10 commits.

Instructions

Get recent git commit history

Input Schema

NameRequiredDescriptionDefault
countNoNumber of recent commits to show (default: 10)
directoryNoDirectory path to check git log (defaults to current directory)

Input Schema (JSON Schema)

{ "properties": { "count": { "default": 10, "description": "Number of recent commits to show (default: 10)", "type": "number" }, "directory": { "description": "Directory path to check git log (defaults to current directory)", "type": "string" } }, "type": "object" }

Implementation Reference

  • Handler for the git-log tool within the CallToolRequestSchema handler. Destructures input arguments, executes the git log command using execSync, formats the response, and handles errors.
    if (name === "git-log") { const { directory, count = 10 }: { directory?: string; count?: number } = args || {}; try { const cwd = directory || process.cwd(); const gitLog = execSync(`git log --oneline -n ${count}`, { cwd: cwd, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }); return { content: [{ type: "text", text: `Recent Git Commits (${count} most recent):\n\n${gitLog}` }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error running git log: ${errorMessage}` }], isError: true }; } }
  • src/index.ts:43-60 (registration)
    Tool registration for git-log in the ListToolsRequestSchema handler, defining name, description, and input schema.
    { name: "git-log", description: "Get recent git commit history", inputSchema: { type: "object", properties: { directory: { type: "string", description: "Directory path to check git log (defaults to current directory)" }, count: { type: "number", description: "Number of recent commits to show (default: 10)", default: 10 } } } }
  • Input schema definition for the git-log tool, specifying directory and count parameters.
    inputSchema: { type: "object", properties: { directory: { type: "string", description: "Directory path to check git log (defaults to current directory)" }, count: { type: "number", description: "Number of recent commits to show (default: 10)", default: 10 } } }

Other Tools

Related 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/narayana-reddy-circles/mcp-git-status'

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