list_repositories
Retrieve all Git repositories within a specified Azure DevOps project and organization, with an option to include reference links.
Instructions
List repositories in a project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The ID or name of the project (Default: MyProject) | |
| organizationId | No | The ID or name of the organization (Default: mycompany) | |
| includeLinks | No | Whether to include reference links |
Implementation Reference
- The main handler function that executes the 'list_repositories' tool logic. It uses the Azure DevOps WebApi Git API to call getRepositories with the provided projectId and includeLinks options.
export async function listRepositories( connection: WebApi, options: ListRepositoriesOptions, ): Promise<GitRepository[]> { try { const gitApi = await connection.getGitApi(); const repositories = await gitApi.getRepositories( options.projectId, options.includeLinks, ); return repositories; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to list repositories: ${error instanceof Error ? error.message : String(error)}`, ); } } - Zod schema for the 'list_repositories' tool input. Defines optional projectId, organizationId, and includeLinks fields with default values from environment config.
export const ListRepositoriesSchema = 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})`), includeLinks: z .boolean() .optional() .describe('Whether to include reference links'), }); - TypeScript interface for ListRepositoriesOptions, used as the options parameter type in the handler function.
export interface ListRepositoriesOptions { projectId: string; includeLinks?: boolean; } - src/features/repositories/tool-definitions.ts:30-34 (registration)Registration of 'list_repositories' as a ToolDefinition with name, description, and inputSchema. Part of the repositoriesTools array.
{ name: 'list_repositories', description: 'List repositories in a project', inputSchema: zodToJsonSchema(ListRepositoriesSchema), }, - src/features/repositories/index.ts:103-112 (registration)The request handler case for 'list_repositories' which parses input with ListRepositoriesSchema, defaults projectId, calls listRepositories, and returns JSON-serialized result.
case 'list_repositories': { const args = ListRepositoriesSchema.parse(request.params.arguments); const result = await listRepositories(connection, { ...args, projectId: args.projectId ?? defaultProject, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }