git_get_item
Retrieve files or folders from Azure DevOps Git repositories with version control, content options, and metadata for efficient repository management.
Instructions
Gets a file or folder from a Git repository with optional content and version control
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization | Yes | The name of the Azure DevOps organization | |
| project | Yes | Project ID or name | |
| repositoryId | Yes | The repository ID or name | |
| path | Yes | Path to the file or folder | |
| scopePath | No | Scope path to filter items | |
| recursionLevel | No | Recursion level (None, OneLevel, Full, OneLevelPlusNestedEmptyFolders) | |
| includeContentMetadata | No | Include content metadata | |
| latestProcessedChange | No | Include latest commit that changed this item | |
| download | No | Set Content-Disposition header for download | |
| versionDescriptor | No | Version descriptor | |
| includeContent | No | Include file content (text only) | |
| resolveLfs | No | Resolve LFS pointer files to actual content | |
| sanitize | No | Sanitize HTML content |
Implementation Reference
- src/tools/repositories.ts:168-198 (handler)The handler function that executes the git_get_item tool logic by calling the Azure DevOps Git API's getItem method with the provided parameters, handling version descriptors and returning the item as JSON.async ({ organization, project, repositoryId, path, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor, includeContent, resolveLfs, sanitize }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); let azVersionDescriptor: any = undefined; if (versionDescriptor) { azVersionDescriptor = { version: versionDescriptor.version, versionType: safeEnumConvert<GitVersionType>(GitVersionType, versionDescriptor.versionType) }; } const item = await gitApi.getItem( repositoryId, path, project, scopePath, recursionLevel as any, includeContentMetadata, latestProcessedChange, download, azVersionDescriptor, includeContent, resolveLfs, sanitize ); return { content: [{ type: "text", text: JSON.stringify(item, null, 2) }], }; }
- src/tools/repositories.ts:150-167 (schema)Zod schema defining the input parameters for the git_get_item tool, including organization, project, repository, path, and various optional flags.{ organization: z.string().describe("The name of the Azure DevOps organization"), project: z.string().describe("Project ID or name"), repositoryId: z.string().describe("The repository ID or name"), path: z.string().describe("Path to the file or folder"), scopePath: z.string().optional().describe("Scope path to filter items"), recursionLevel: z.string().optional().describe("Recursion level (None, OneLevel, Full, OneLevelPlusNestedEmptyFolders)"), includeContentMetadata: z.boolean().optional().describe("Include content metadata"), latestProcessedChange: z.boolean().optional().describe("Include latest commit that changed this item"), download: z.boolean().optional().describe("Set Content-Disposition header for download"), versionDescriptor: z.object({ version: z.string().describe("Version string (branch name, commit SHA, tag)"), versionType: z.enum(getEnumKeys(GitVersionType)).describe("Type of version (Branch, Commit, Tag)"), }).optional().describe("Version descriptor"), includeContent: z.boolean().optional().describe("Include file content (text only)"), resolveLfs: z.boolean().optional().describe("Resolve LFS pointer files to actual content"), sanitize: z.boolean().optional().describe("Sanitize HTML content"), },
- src/tools/repositories.ts:147-199 (registration)The server.tool call that registers the git_get_item tool with its name, description, input schema, and handler function.server.tool( "git_get_item", "Gets a file or folder from a Git repository with optional content and version control", { organization: z.string().describe("The name of the Azure DevOps organization"), project: z.string().describe("Project ID or name"), repositoryId: z.string().describe("The repository ID or name"), path: z.string().describe("Path to the file or folder"), scopePath: z.string().optional().describe("Scope path to filter items"), recursionLevel: z.string().optional().describe("Recursion level (None, OneLevel, Full, OneLevelPlusNestedEmptyFolders)"), includeContentMetadata: z.boolean().optional().describe("Include content metadata"), latestProcessedChange: z.boolean().optional().describe("Include latest commit that changed this item"), download: z.boolean().optional().describe("Set Content-Disposition header for download"), versionDescriptor: z.object({ version: z.string().describe("Version string (branch name, commit SHA, tag)"), versionType: z.enum(getEnumKeys(GitVersionType)).describe("Type of version (Branch, Commit, Tag)"), }).optional().describe("Version descriptor"), includeContent: z.boolean().optional().describe("Include file content (text only)"), resolveLfs: z.boolean().optional().describe("Resolve LFS pointer files to actual content"), sanitize: z.boolean().optional().describe("Sanitize HTML content"), }, async ({ organization, project, repositoryId, path, scopePath, recursionLevel, includeContentMetadata, latestProcessedChange, download, versionDescriptor, includeContent, resolveLfs, sanitize }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); let azVersionDescriptor: any = undefined; if (versionDescriptor) { azVersionDescriptor = { version: versionDescriptor.version, versionType: safeEnumConvert<GitVersionType>(GitVersionType, versionDescriptor.versionType) }; } const item = await gitApi.getItem( repositoryId, path, project, scopePath, recursionLevel as any, includeContentMetadata, latestProcessedChange, download, azVersionDescriptor, includeContent, resolveLfs, sanitize ); return { content: [{ type: "text", text: JSON.stringify(item, null, 2) }], }; } );