Skip to main content
Glama
Korfu
by Korfu

get_commit

Retrieve specific commit details from a Bitbucket repository using its unique hash to examine changes, review code history, or verify modifications.

Instructions

Get a single commit by its hash.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repository_nameYesName of the repository (repo slug)
commit_hashYesThe hash of the commit.

Implementation Reference

  • The main handler function that executes the 'get_commit' tool logic, fetching detailed commit information from the Bitbucket API using the provided repository name and commit hash.
    export async function getCommit(
      axiosInstance: AxiosInstance,
      config: Config,
      args: any
    ): Promise<{ content: Array<{ type: string; text: string }> }> {
      try {
        const { repository_name, commit_hash } = args;
    
        if (!repository_name) {
          throw new Error('Repository name is required');
        }
        if (!commit_hash) {
          throw new Error('Commit hash is required');
        }
    
        console.error(
          `Fetching commit ${commit_hash} for repository: ${repository_name}`
        );
    
        const response = await axiosInstance.get<BitbucketDetailedCommit>(
          `/repositories/${config.BITBUCKET_WORKSPACE}/${repository_name}/commit/${commit_hash}`
        );
    
        const commit = response.data;
        const commitDetails = `**Commit Details: ${commit.hash}**
    - Author: ${commit.author.user?.display_name || commit.author.raw}
    - Date: ${new Date(commit.date).toLocaleString()}
    - Message: ${commit.message}
    - Parents: ${commit.parents.map(p => p.hash).join(', ')}`;
    
        return {
          content: [
            {
              type: 'text',
              text: commitDetails,
            },
          ],
        };
      } catch (error) {
        console.error('Error fetching commit:', error);
        return {
          content: [
            {
              type: 'text',
              text: `Error fetching commit: ${
                error instanceof Error ? error.message : 'Unknown error'
              }`,
            },
          ],
        };
      }
    } 
  • The tool definition object including name 'get_commit', description, and input schema specifying required parameters: repository_name and commit_hash.
    export const getCommitTool = {
      name: 'get_commit',
      description: 'Get a single commit by its hash.',
      inputSchema: {
        type: 'object',
        properties: {
          repository_name: {
            type: 'string',
            description: 'Name of the repository (repo slug)',
          },
          commit_hash: {
            type: 'string',
            description: 'The hash of the commit.',
          },
        },
        required: ['repository_name', 'commit_hash'],
      },
    };
  • src/index.ts:111-136 (registration)
    Registers getCommitTool in the list of tools returned by ListToolsRequestHandler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        // Repositories
        listRepositoriesTool,
        getRepositoryDetailsTool,
        // Commits
        listCommitsTool,
        getCommitTool,
        // Branching Model
        updateRepositoryBranchingModelSettingsTool,
        updateProjectBranchingModelSettingsTool,
        listBranchRestrictionsTool,
        getBranchRestrictionTool,
        // Projects
        getProjectTool,
        listDefaultReviewersTool,
        // Pull Requests
        listPullRequestsTool,
        getPullRequestTool,
        createPullRequestTool,
        updatePullRequestTool,
        // Workspaces
        listWorkspacesTool,
      ],
    }));
  • src/index.ts:155-155 (registration)
    Maps the tool name 'get_commit' to its handler function getCommit in the CallToolRequestHandler's handlers object.
    get_commit: getCommit,

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/Korfu/mcp-bitbucket'

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