get_repository_details
Retrieve comprehensive repository details from Azure DevOps, including branch statistics and refs, by specifying project and repository IDs. Enable or disable statistical data and ref inclusion as needed.
Instructions
Get detailed information about a repository including statistics and refs
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branchName | No | Name of specific branch to get statistics for (if includeStatistics is true) | |
| includeRefs | No | Whether to include repository refs | |
| includeStatistics | No | Whether to include branch statistics | |
| projectId | Yes | The ID or name of the project | |
| refFilter | No | Optional filter for refs (e.g., "heads/" or "tags/") | |
| repositoryId | Yes | The ID or name of the repository |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"branchName": {
"description": "Name of specific branch to get statistics for (if includeStatistics is true)",
"type": "string"
},
"includeRefs": {
"default": false,
"description": "Whether to include repository refs",
"type": "boolean"
},
"includeStatistics": {
"default": false,
"description": "Whether to include branch statistics",
"type": "boolean"
},
"projectId": {
"description": "The ID or name of the project",
"type": "string"
},
"refFilter": {
"description": "Optional filter for refs (e.g., \"heads/\" or \"tags/\")",
"type": "string"
},
"repositoryId": {
"description": "The ID or name of the repository",
"type": "string"
}
},
"required": [
"projectId",
"repositoryId"
],
"type": "object"
}
Implementation Reference
- The main handler function that implements the core logic for fetching repository details using the Azure DevOps Git API, including optional branch statistics and refs.export async function getRepositoryDetails( connection: WebApi, options: GetRepositoryDetailsOptions, ): Promise<RepositoryDetails> { try { const gitApi = await connection.getGitApi(); // Get the basic repository information const repository = await gitApi.getRepository( options.repositoryId, options.projectId, ); if (!repository) { throw new AzureDevOpsResourceNotFoundError( `Repository '${options.repositoryId}' not found in project '${options.projectId}'`, ); } // Initialize the response object const response: RepositoryDetails = { repository, }; // Get branch statistics if requested if (options.includeStatistics) { let baseVersionDescriptor = undefined; // If a specific branch name is provided, create a version descriptor for it if (options.branchName) { baseVersionDescriptor = { version: options.branchName, versionType: GitVersionType.Branch, }; } const branchStats = await gitApi.getBranches( repository.id || '', options.projectId, baseVersionDescriptor, ); response.statistics = { branches: branchStats || [], }; } // Get repository refs if requested if (options.includeRefs) { const filter = options.refFilter || undefined; const refs = await gitApi.getRefs( repository.id || '', options.projectId, filter, ); if (refs) { response.refs = { value: refs, count: refs.length, }; } else { response.refs = { value: [], count: 0, }; } } return response; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to get repository details: ${error instanceof Error ? error.message : String(error)}`, ); } }
- Zod schema defining the input validation for the get_repository_details tool parameters.export const GetRepositoryDetailsSchema = z.object({ projectId: z .string() .optional() .describe(`The ID or name of the project (Default: ${defaultProject})`), organizationId: z .string() .optional() .describe(`The ID or name of the organization (Default: ${defaultOrg})`), repositoryId: z.string().describe('The ID or name of the repository'), includeStatistics: z .boolean() .optional() .default(false) .describe('Whether to include branch statistics'), includeRefs: z .boolean() .optional() .default(false) .describe('Whether to include repository refs'), refFilter: z .string() .optional() .describe('Optional filter for refs (e.g., "heads/" or "tags/")'), branchName: z .string() .optional() .describe( 'Name of specific branch to get statistics for (if includeStatistics is true)', ), });
- src/features/repositories/tool-definitions.ts:24-29 (registration)ToolDefinition object registering the 'get_repository_details' tool with its name, description, and input schema.{ name: 'get_repository_details', description: 'Get detailed information about a repository including statistics and refs', inputSchema: zodToJsonSchema(GetRepositoryDetailsSchema), },
- src/features/repositories/index.ts:89-102 (registration)Switch case in the repositories request handler that dispatches calls to get_repository_details, parses arguments, invokes the handler, and formats the response.case 'get_repository_details': { const args = GetRepositoryDetailsSchema.parse(request.params.arguments); const result = await getRepositoryDetails(connection, { projectId: args.projectId ?? defaultProject, repositoryId: args.repositoryId, includeStatistics: args.includeStatistics, includeRefs: args.includeRefs, refFilter: args.refFilter, branchName: args.branchName, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- TypeScript interfaces defining GetRepositoryDetailsOptions input and RepositoryDetails output for the tool.export interface GetRepositoryDetailsOptions { projectId: string; repositoryId: string; includeStatistics?: boolean; includeRefs?: boolean; refFilter?: string; branchName?: string; } /** * Repository details response */ export interface RepositoryDetails { repository: GitRepository; statistics?: { branches: GitBranchStats[]; }; refs?: { value: GitRef[]; count: number; }; }