Skip to main content
Glama

get_commit

Fetch detailed information for a specific commit in a GitHub repository by providing owner, repository name, and SHA.

Instructions

Get details for a commit from a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner
repoYesRepository name
shaYesCommit SHA, branch name, or tag name

Implementation Reference

  • Tool 'get_commit' is registered via server.tool() with name 'get_commit'
    server.tool(
    	"get_commit",
    	"Get details for a commit from a GitHub repository",
    	{
    		owner: z.string().describe("Repository owner"),
    		repo: z.string().describe("Repository name"),
    		sha: z.string().describe("Commit SHA, branch name, or tag name"),
    	},
    	async ({ owner, repo, sha }) => {
    		try {
    			const response = await octokit.rest.repos.getCommit({
    				owner,
    				repo,
    				ref: sha,
    			})
    
    			const commit = response.data
    
    			// Format as clean markdown
    			let markdown = `# Commit ${commit.sha.substring(0, 7)}\n\n`
    			markdown += `**Message:** ${commit.commit.message}\n\n`
    			markdown += `**Author:** ${commit.commit.author?.name} <${commit.commit.author?.email}>\n`
    			markdown += `**Date:** ${new Date(commit.commit.author?.date || "").toLocaleDateString()}\n`
    
    			if (commit.commit.committer?.name !== commit.commit.author?.name) {
    				markdown += `**Committer:** ${commit.commit.committer?.name} <${commit.commit.committer?.email}>\n`
    			}
    
    			markdown += `\n## Changes\n\n`
    			markdown += `- **Files changed:** ${commit.files?.length || 0}\n`
    			markdown += `- **Additions:** ${commit.stats?.additions || 0}\n`
    			markdown += `- **Deletions:** ${commit.stats?.deletions || 0}\n`
    
    			if (commit.files && commit.files.length > 0) {
    				markdown += `\n## Files\n\n`
    				commit.files.forEach(file => {
    					const status =
    						file.status === "added"
    							? "[A]"
    							: file.status === "removed"
    								? "[D]"
    								: file.status === "modified"
    									? "[M]"
    									: file.status === "renamed"
    										? "[R]"
    										: "[?]"
    					markdown += `- ${status} ${file.filename} (+${file.additions} -${file.deletions})\n`
    				})
    			}
    
    			markdown += `\n## Links\n\n`
    			markdown += `- **Commit URL:** ${commit.html_url}\n`
    			markdown += `- **Full SHA:** ${commit.sha}\n`
    
    			return {
    				content: [{ type: "text", text: markdown }],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • Zod schema defining input parameters: owner (string), repo (string), sha (string)
    {
    	owner: z.string().describe("Repository owner"),
    	repo: z.string().describe("Repository name"),
    	sha: z.string().describe("Commit SHA, branch name, or tag name"),
    },
  • Handler function that calls octokit.rest.repos.getCommit() with owner, repo, and ref=sha, then formats commit details as markdown
    async ({ owner, repo, sha }) => {
    	try {
    		const response = await octokit.rest.repos.getCommit({
    			owner,
    			repo,
    			ref: sha,
    		})
    
    		const commit = response.data
    
    		// Format as clean markdown
    		let markdown = `# Commit ${commit.sha.substring(0, 7)}\n\n`
    		markdown += `**Message:** ${commit.commit.message}\n\n`
    		markdown += `**Author:** ${commit.commit.author?.name} <${commit.commit.author?.email}>\n`
    		markdown += `**Date:** ${new Date(commit.commit.author?.date || "").toLocaleDateString()}\n`
    
    		if (commit.commit.committer?.name !== commit.commit.author?.name) {
    			markdown += `**Committer:** ${commit.commit.committer?.name} <${commit.commit.committer?.email}>\n`
    		}
    
    		markdown += `\n## Changes\n\n`
    		markdown += `- **Files changed:** ${commit.files?.length || 0}\n`
    		markdown += `- **Additions:** ${commit.stats?.additions || 0}\n`
    		markdown += `- **Deletions:** ${commit.stats?.deletions || 0}\n`
    
    		if (commit.files && commit.files.length > 0) {
    			markdown += `\n## Files\n\n`
    			commit.files.forEach(file => {
    				const status =
    					file.status === "added"
    						? "[A]"
    						: file.status === "removed"
    							? "[D]"
    							: file.status === "modified"
    								? "[M]"
    								: file.status === "renamed"
    									? "[R]"
    									: "[?]"
    				markdown += `- ${status} ${file.filename} (+${file.additions} -${file.deletions})\n`
    			})
    		}
    
    		markdown += `\n## Links\n\n`
    		markdown += `- **Commit URL:** ${commit.html_url}\n`
    		markdown += `- **Full SHA:** ${commit.sha}\n`
    
    		return {
    			content: [{ type: "text", text: markdown }],
    		}
    	} catch (e: any) {
    		return {
    			content: [{ type: "text", text: `Error: ${e.message}` }],
    		}
    	}
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fails to disclose behavioral traits such as read-only nature, authentication requirements, or possible rate limits. It simply says 'get details' without elaboration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence that is concise and front-loaded, with no unnecessary words. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

While the tool is simple and schema covers parameters, the lack of output schema means the description should hint at returned fields (e.g., author, message). It does not, leaving the agent partially uninformed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage for all parameters, so the description adds no further meaning. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses specific verb 'Get' and resource 'commit from a GitHub repository', clearly distinguishing it from sibling tools like list_commits and get_tag.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives (e.g., list_commits for browsing commits). The description only states the action without context on prerequisites or limitations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/hithereiamaliff/mcp-github'

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