|
2 | 2 |
|
3 | 3 | This document describes the tools available for working with Azure DevOps Git repositories.
|
4 | 4 |
|
| 5 | +## get_repository_details |
| 6 | + |
| 7 | +Gets detailed information about a specific Git repository, including optional branch statistics and refs. |
| 8 | + |
| 9 | +### Description |
| 10 | + |
| 11 | +The `get_repository_details` tool retrieves comprehensive information about a specific Git repository in Azure DevOps. It can optionally include branch statistics (ahead/behind counts, commit information) and repository refs (branches, tags). This is useful for tasks like branch management, policy configuration, and repository statistics tracking. |
| 12 | + |
| 13 | +### Parameters |
| 14 | + |
| 15 | +```json |
| 16 | +{ |
| 17 | + "projectId": "MyProject", // Required: The ID or name of the project |
| 18 | + "repositoryId": "MyRepo", // Required: The ID or name of the repository |
| 19 | + "includeStatistics": true, // Optional: Whether to include branch statistics (default: false) |
| 20 | + "includeRefs": true, // Optional: Whether to include repository refs (default: false) |
| 21 | + "refFilter": "heads/", // Optional: Filter for refs (e.g., "heads/" or "tags/") |
| 22 | + "branchName": "main" // Optional: Name of specific branch to get statistics for |
| 23 | +} |
| 24 | +``` |
| 25 | + |
| 26 | +| Parameter | Type | Required | Description | |
| 27 | +| --------- | ---- | -------- | ----------- | |
| 28 | +| `projectId` | string | Yes | The ID or name of the project containing the repository | |
| 29 | +| `repositoryId` | string | Yes | The ID or name of the repository to get details for | |
| 30 | +| `includeStatistics` | boolean | No | Whether to include branch statistics (default: false) | |
| 31 | +| `includeRefs` | boolean | No | Whether to include repository refs (default: false) | |
| 32 | +| `refFilter` | string | No | Optional filter for refs (e.g., "heads/" or "tags/") | |
| 33 | +| `branchName` | string | No | Name of specific branch to get statistics for (if includeStatistics is true) | |
| 34 | + |
| 35 | +### Response |
| 36 | + |
| 37 | +The tool returns a `RepositoryDetails` object containing: |
| 38 | + |
| 39 | +- `repository`: The basic repository information (same as returned by `get_repository`) |
| 40 | +- `statistics` (optional): Branch statistics if requested |
| 41 | +- `refs` (optional): Repository refs if requested |
| 42 | + |
| 43 | +Example response: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "repository": { |
| 48 | + "id": "repo-guid", |
| 49 | + "name": "MyRepository", |
| 50 | + "url": "https://dev.azure.com/organization/MyProject/_apis/git/repositories/MyRepository", |
| 51 | + "project": { |
| 52 | + "id": "project-guid", |
| 53 | + "name": "MyProject", |
| 54 | + "url": "https://dev.azure.com/organization/_apis/projects/project-guid" |
| 55 | + }, |
| 56 | + "defaultBranch": "refs/heads/main", |
| 57 | + "size": 25478, |
| 58 | + "remoteUrl": "https://dev.azure.com/organization/MyProject/_git/MyRepository", |
| 59 | + "sshUrl": "[email protected]:v3/organization/MyProject/MyRepository", |
| 60 | + "webUrl": "https://dev.azure.com/organization/MyProject/_git/MyRepository" |
| 61 | + }, |
| 62 | + "statistics": { |
| 63 | + "branches": [ |
| 64 | + { |
| 65 | + "name": "refs/heads/main", |
| 66 | + "aheadCount": 0, |
| 67 | + "behindCount": 0, |
| 68 | + "isBaseVersion": true, |
| 69 | + "commit": { |
| 70 | + "commitId": "commit-guid", |
| 71 | + "author": { |
| 72 | + "name": "John Doe", |
| 73 | + |
| 74 | + "date": "2023-01-01T12:00:00Z" |
| 75 | + }, |
| 76 | + "committer": { |
| 77 | + "name": "John Doe", |
| 78 | + |
| 79 | + "date": "2023-01-01T12:00:00Z" |
| 80 | + }, |
| 81 | + "comment": "Initial commit" |
| 82 | + } |
| 83 | + } |
| 84 | + ] |
| 85 | + }, |
| 86 | + "refs": { |
| 87 | + "value": [ |
| 88 | + { |
| 89 | + "name": "refs/heads/main", |
| 90 | + "objectId": "commit-guid", |
| 91 | + "creator": { |
| 92 | + "displayName": "John Doe", |
| 93 | + "id": "user-guid" |
| 94 | + }, |
| 95 | + "url": "https://dev.azure.com/organization/MyProject/_apis/git/repositories/repo-guid/refs/heads/main" |
| 96 | + } |
| 97 | + ], |
| 98 | + "count": 1 |
| 99 | + } |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +### Error Handling |
| 104 | + |
| 105 | +The tool may throw the following errors: |
| 106 | + |
| 107 | +- General errors: If the API call fails or other unexpected errors occur |
| 108 | +- Authentication errors: If the authentication credentials are invalid or expired |
| 109 | +- Permission errors: If the authenticated user doesn't have permission to access the repository |
| 110 | +- ResourceNotFound errors: If the specified project or repository doesn't exist |
| 111 | + |
| 112 | +Error messages will be formatted as text and provide details about what went wrong. |
| 113 | + |
| 114 | +### Example Usage |
| 115 | + |
| 116 | +```typescript |
| 117 | +// Basic example - just repository info |
| 118 | +const repoDetails = await mcpClient.callTool('get_repository_details', { |
| 119 | + projectId: 'MyProject', |
| 120 | + repositoryId: 'MyRepo' |
| 121 | +}); |
| 122 | +console.log(repoDetails); |
| 123 | + |
| 124 | +// Example with branch statistics |
| 125 | +const repoWithStats = await mcpClient.callTool('get_repository_details', { |
| 126 | + projectId: 'MyProject', |
| 127 | + repositoryId: 'MyRepo', |
| 128 | + includeStatistics: true |
| 129 | +}); |
| 130 | +console.log(repoWithStats); |
| 131 | + |
| 132 | +// Example with refs filtered to branches |
| 133 | +const repoWithBranches = await mcpClient.callTool('get_repository_details', { |
| 134 | + projectId: 'MyProject', |
| 135 | + repositoryId: 'MyRepo', |
| 136 | + includeRefs: true, |
| 137 | + refFilter: 'heads/' |
| 138 | +}); |
| 139 | +console.log(repoWithBranches); |
| 140 | + |
| 141 | +// Example with all options |
| 142 | +const fullRepoDetails = await mcpClient.callTool('get_repository_details', { |
| 143 | + projectId: 'MyProject', |
| 144 | + repositoryId: 'MyRepo', |
| 145 | + includeStatistics: true, |
| 146 | + includeRefs: true, |
| 147 | + refFilter: 'heads/', |
| 148 | + branchName: 'main' |
| 149 | +}); |
| 150 | +console.log(fullRepoDetails); |
| 151 | +``` |
| 152 | + |
| 153 | +### Implementation Details |
| 154 | + |
| 155 | +This tool uses the Azure DevOps Node API's Git API to retrieve repository details: |
| 156 | + |
| 157 | +1. It gets a connection to the Azure DevOps WebApi client |
| 158 | +2. It calls the `getGitApi()` method to get a handle to the Git API |
| 159 | +3. It retrieves the basic repository information using `getRepository()` |
| 160 | +4. If requested, it retrieves branch statistics using `getBranches()` |
| 161 | +5. If requested, it retrieves repository refs using `getRefs()` |
| 162 | +6. The combined results are returned to the caller |
| 163 | + |
5 | 164 | ## list_repositories
|
6 | 165 |
|
7 | 166 | Lists all Git repositories in a specific project.
|
@@ -118,4 +277,5 @@ This tool uses the Azure DevOps Node API's Git API to retrieve repositories:
|
118 | 277 | ### Related Tools
|
119 | 278 |
|
120 | 279 | - `get_repository`: Get details of a specific repository
|
| 280 | +- `get_repository_details`: Get detailed information about a repository including statistics and refs |
121 | 281 | - `list_projects`: List all projects in the organization (to find project IDs)
|
0 commit comments