get_repository
Retrieve specific repository details from Azure DevOps by providing the project and repository IDs. This tool enables precise access to repository information through the Azure DevOps MCP Server.
Instructions
Get details of a specific repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID or name of the project | |
| repositoryId | Yes | The ID or name of the repository |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"projectId": {
"description": "The ID or name of the project",
"type": "string"
},
"repositoryId": {
"description": "The ID or name of the repository",
"type": "string"
}
},
"required": [
"projectId",
"repositoryId"
],
"type": "object"
}
Implementation Reference
- Core handler function that fetches the Git repository details from Azure DevOps using the Git API, with error handling for not found and other errors.export async function getRepository( connection: WebApi, projectId: string, repositoryId: string, ): Promise<GitRepository> { try { const gitApi = await connection.getGitApi(); const repository = await gitApi.getRepository(repositoryId, projectId); if (!repository) { throw new AzureDevOpsResourceNotFoundError( `Repository '${repositoryId}' not found in project '${projectId}'`, ); } return repository; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to get repository: ${error instanceof Error ? error.message : String(error)}`, ); } }
- Zod schema defining the input parameters for the get_repository tool: optional projectId, optional organizationId, required repositoryId.export const GetRepositorySchema = 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'), });
- src/features/repositories/tool-definitions.ts:20-23 (registration)MCP tool definition registration including name, description, and input schema for 'get_repository'.name: 'get_repository', description: 'Get details of a specific repository', inputSchema: zodToJsonSchema(GetRepositorySchema), },
- src/features/repositories/index.ts:78-88 (handler)Tool dispatch handler case that parses arguments, calls the core getRepository function, and formats the JSON response.case 'get_repository': { const args = GetRepositorySchema.parse(request.params.arguments); const result = await getRepository( connection, args.projectId ?? defaultProject, args.repositoryId, ); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/features/repositories/index.ts:58-58 (registration)Registration of 'get_repository' tool name in the repositories request identifier function.'get_repository',