get_repository_details
Retrieve repository details and latest commit information from Bitbucket Cloud to access project metadata and development status.
Instructions
Get detailed information about a specific repository including latest commit info
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| repository_name | Yes | Name of the repository (repo slug) |
Implementation Reference
- The main handler function that fetches repository details and latest commit information from the Bitbucket API using axios, formats it as markdown text, and returns it in the expected MCP format. Handles errors gracefully.export async function getRepositoryDetails( axiosInstance: AxiosInstance, config: Config, args: any ): Promise<{ content: Array<{ type: string; text: string }> }> { try { const repositoryName = args?.repository_name; if (!repositoryName) { throw new Error('Repository name is required'); } console.error(`Fetching details for repository: ${repositoryName}`); // Fetch repository info and latest commit in parallel const [repoResponse, commitResponse] = await Promise.all([ axiosInstance.get<BitbucketRepository>( `/repositories/${config.BITBUCKET_WORKSPACE}/${repositoryName}` ), axiosInstance.get<BitbucketPaginatedResponse<BitbucketCommit>>( `/repositories/${config.BITBUCKET_WORKSPACE}/${repositoryName}/commits`, { params: { pagelen: 1, }, } ), ]); const repo = repoResponse.data; const latestCommit = commitResponse.data.values[0]; const totalCommits = commitResponse.data.size || 0; const details = `**Repository Details: ${repo.name}** **Basic Information:** - Full Name: ${repo.full_name} - Description: ${repo.description || 'No description'} - Language: ${repo.language || 'Not specified'} - Size: ${(repo.size / 1024).toFixed(2)} KB - Private: ${repo.is_private ? 'Yes' : 'No'} - Created: ${new Date(repo.created_on).toLocaleString()} - Last Updated: ${new Date(repo.updated_on).toLocaleString()} - URL: ${repo.links.html.href} **Commit Information:** - Total Commits: ${totalCommits} - Latest Commit Date: ${ latestCommit ? new Date(latestCommit.date).toLocaleString() : 'No commits' } - Latest Commit Hash: ${latestCommit?.hash || 'N/A'} - Latest Commit Author: ${ latestCommit?.author?.user?.display_name || latestCommit?.author?.raw || 'N/A' } - Latest Commit Message: ${latestCommit?.message || 'N/A'}`; return { content: [ { type: 'text', text: details, }, ], }; } catch (error) { console.error('Error fetching repository details:', error); return { content: [ { type: 'text', text: `Error fetching repository details: ${ error instanceof Error ? error.message : 'Unknown error' }`, }, ], }; } }
- Tool schema definition including name, description, and input schema requiring a 'repository_name' string parameter.export const getRepositoryDetailsTool = { name: 'get_repository_details', description: 'Get detailed information about a specific repository including latest commit info', inputSchema: { type: 'object', properties: { repository_name: { type: 'string', description: 'Name of the repository (repo slug)', }, }, required: ['repository_name'], }, };
- src/index.ts:152-152 (registration)Mapping of tool name 'get_repository_details' to its handler function in the CallToolRequest handler's dispatch object.get_repository_details: getRepositoryDetails,
- src/index.ts:115-115 (registration)Inclusion of getRepositoryDetailsTool in the array returned by ListToolsRequest handler.getRepositoryDetailsTool,
- src/index.ts:19-21 (registration)Import statement bringing in the handler and tool schema from the implementation file.getRepositoryDetails, getRepositoryDetailsTool, } from './tools/repositories/getRepositoryDetails.js';