This document describes the tools available for working with Azure DevOps Git repositories.
Lists all Git repositories in a specific project.
The list_repositories
tool retrieves all Git repositories within a specified Azure DevOps project. This is useful for discovering which repositories are available for cloning, accessing files, or creating branches and pull requests.
This tool uses the Azure DevOps WebApi client to interact with the Git API.
{
"projectId": "MyProject", // Required: The ID or name of the project
"includeLinks": true // Optional: Whether to include reference links
}
Parameter | Type | Required | Description |
---|---|---|---|
projectId |
string | Yes | The ID or name of the project containing the repositories |
includeLinks |
boolean | No | Whether to include reference links in the repository objects |
The tool returns an array of GitRepository
objects, each containing:
id
: The unique identifier of the repositoryname
: The name of the repositoryurl
: The URL of the repositoryproject
: Object containing basic project informationdefaultBranch
: The default branch of the repository (e.g., "refs/heads/main")size
: The size of the repositoryremoteUrl
: The remote URL for cloning the repositorysshUrl
: The SSH URL for cloning the repositorywebUrl
: The web URL for browsing the repository in browser- ... and potentially other repository properties
Example response:
[
{
"id": "repo-guid-1",
"name": "FirstRepository",
"url": "https://dev.azure.com/organization/MyProject/_apis/git/repositories/FirstRepository",
"project": {
"id": "project-guid",
"name": "MyProject",
"url": "https://dev.azure.com/organization/_apis/projects/project-guid"
},
"defaultBranch": "refs/heads/main",
"size": 25478,
"remoteUrl": "https://dev.azure.com/organization/MyProject/_git/FirstRepository",
"sshUrl": "[email protected]:v3/organization/MyProject/FirstRepository",
"webUrl": "https://dev.azure.com/organization/MyProject/_git/FirstRepository"
},
{
"id": "repo-guid-2",
"name": "SecondRepository",
"url": "https://dev.azure.com/organization/MyProject/_apis/git/repositories/SecondRepository",
"project": {
"id": "project-guid",
"name": "MyProject",
"url": "https://dev.azure.com/organization/_apis/projects/project-guid"
},
"defaultBranch": "refs/heads/main",
"size": 15789,
"remoteUrl": "https://dev.azure.com/organization/MyProject/_git/SecondRepository",
"sshUrl": "[email protected]:v3/organization/MyProject/SecondRepository",
"webUrl": "https://dev.azure.com/organization/MyProject/_git/SecondRepository"
}
]
The tool may throw the following errors:
- General errors: If the API call fails or other unexpected errors occur
- Authentication errors: If the authentication credentials are invalid or expired
- Permission errors: If the authenticated user doesn't have permission to list repositories
- ResourceNotFound errors: If the specified project doesn't exist
Error messages will be formatted as text and provide details about what went wrong.
// Basic example
const repositories = await mcpClient.callTool('list_repositories', {
projectId: 'MyProject',
});
console.log(repositories);
// Example with includeLinks parameter
const repositoriesWithLinks = await mcpClient.callTool('list_repositories', {
projectId: 'MyProject',
includeLinks: true,
});
console.log(repositoriesWithLinks);
This tool uses the Azure DevOps Node API's Git API to retrieve repositories:
- It gets a connection to the Azure DevOps WebApi client
- It calls the
getGitApi()
method to get a handle to the Git API - It then calls
getRepositories()
with the specified project ID and optional include links parameter - The results are returned directly to the caller
get_repository
: Get details of a specific repositorylist_projects
: List all projects in the organization (to find project IDs)