repo_list_repos_by_project
Retrieve a list of repositories for a specific Azure DevOps project, with optional filters for repository names, maximum results, and skip count, using PAT authentication.
Instructions
Retrieve a list of repositories for a given project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | Yes | The name or ID of the Azure DevOps project. | |
| repoNameFilter | No | Optional filter to search for repositories by name. If provided, only repositories with names containing this string will be returned. | |
| skip | No | The number of repositories to skip. Defaults to 0. | |
| top | No | The maximum number of repositories to return. |
Implementation Reference
- src/tools/repos.ts:239-262 (handler)The core handler function that implements the logic for listing repositories in a given Azure DevOps project. It fetches repositories using the Git API, applies optional filtering by name, pagination (top/skip), sorts by name, trims to essential properties, and returns as JSON text content.async ({ project, top, skip, repoNameFilter }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const repositories = await gitApi.getRepositories(project, false, false, false); const filteredRepositories = repoNameFilter ? filterReposByName(repositories, repoNameFilter) : repositories; const paginatedRepositories = filteredRepositories?.sort((a, b) => a.name?.localeCompare(b.name ?? "") ?? 0).slice(skip, skip + top); // Filter out the irrelevant properties const trimmedRepositories = paginatedRepositories?.map((repo) => ({ id: repo.id, name: repo.name, isDisabled: repo.isDisabled, isFork: repo.isFork, isInMaintenance: repo.isInMaintenance, webUrl: repo.webUrl, size: repo.size, })); return { content: [{ type: "text", text: JSON.stringify(trimmedRepositories, null, 2) }], }; }
- src/tools/repos.ts:234-238 (schema)Zod schema defining the input parameters for the tool: project (required), top (default 100), skip (default 0), repoNameFilter (optional).project: z.string().describe("The name or ID of the Azure DevOps project."), top: z.number().default(100).describe("The maximum number of repositories to return."), skip: z.number().default(0).describe("The number of repositories to skip. Defaults to 0."), repoNameFilter: z.string().optional().describe("Optional filter to search for repositories by name. If provided, only repositories with names containing this string will be returned."), },
- src/tools/repos.ts:231-232 (registration)Tool registration call to McpServer.tool() using the mapped tool name REPO_TOOLS.list_repos_by_project which resolves to "repo_list_repos_by_project", along with the tool description.REPO_TOOLS.list_repos_by_project, "Retrieve a list of repositories for a given project",
- src/tools/repos.ts:93-98 (helper)Helper utility function used by the handler to filter the list of repositories by a substring match on the repository name (case-insensitive).function filterReposByName(repositories: GitRepository[], repoNameFilter: string): GitRepository[] { const lowerCaseFilter = repoNameFilter.toLowerCase(); const filteredByName = repositories?.filter((repo) => repo.name?.toLowerCase().includes(lowerCaseFilter)); return filteredByName; }
- src/tools/repos.ts:26-26 (registration)Mapping in REPO_TOOLS constant from internal key 'list_repos_by_project' to the actual MCP tool name 'repo_list_repos_by_project' used in server.tool registration.list_repos_by_project: "repo_list_repos_by_project",