git-log
View recent commit history from a Git repository to track changes and review project development. Specify directory and number of commits to display.
Instructions
Get recent git commit history
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "git-log"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Directory path to check git log (defaults to current directory) | |
| count | No | Number of recent commits to show (default: 10) |
Implementation Reference
- src/index.ts:131-161 (handler)Handler for the git-log tool: executes git log command with optional directory and count parameters, returns formatted commit history or error.
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)Registration of the git-log tool in the ListToolsRequestHandler response, including 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 } } } } - src/index.ts:46-59 (schema)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 } } }