Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

get_repository_tree

View hierarchical file and directory structure within an Azure DevOps repository starting from a specified path.

Instructions

Displays a hierarchical tree view of files and directories within a single repository starting from an optional path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
repositoryIdYesThe ID or name of the repository
pathNoPath within the repository to start from/
depthNoMaximum depth to traverse (0 = unlimited)

Implementation Reference

  • Primary handler function implementing the get_repository_tree tool logic: fetches repository details, retrieves git items recursively, filters by depth, and constructs a tree structure with stats.
    export async function getRepositoryTree(
      connection: WebApi,
      options: GetRepositoryTreeOptions,
    ): Promise<RepositoryTreeResponse> {
      try {
        const gitApi = await connection.getGitApi();
    
        const repository = await gitApi.getRepository(
          options.repositoryId,
          options.projectId,
        );
        if (!repository || !repository.id) {
          throw new AzureDevOpsError(
            `Repository '${options.repositoryId}' not found in project '${options.projectId}'`,
          );
        }
    
        const defaultBranch = repository.defaultBranch;
        if (!defaultBranch) {
          throw new AzureDevOpsError('Default branch not found');
        }
        const branchRef = defaultBranch.replace('refs/heads/', '');
    
        const rootPath = options.path ?? '/';
        const items = await gitApi.getItems(
          repository.id,
          options.projectId,
          rootPath,
          VersionControlRecursionType.Full,
          true,
          false,
          false,
          false,
          {
            version: branchRef,
            versionType: GitVersionType.Branch,
          },
        );
    
        const treeItems: RepositoryTreeItem[] = [];
        const stats = { directories: 0, files: 0 };
    
        for (const item of items) {
          const path = item.path || '';
          if (path === rootPath || item.gitObjectType === GitObjectType.Bad) {
            continue;
          }
          const relative =
            rootPath === '/'
              ? path.replace(/^\//, '')
              : path.slice(rootPath.length + 1);
          const level = relative.split('/').length;
          if (options.depth && options.depth > 0 && level > options.depth) {
            continue;
          }
          const isFolder = !!item.isFolder;
          treeItems.push({
            name: relative.split('/').pop() || '',
            path,
            isFolder,
            level,
          });
          if (isFolder) stats.directories++;
          else stats.files++;
        }
    
        return {
          name: repository.name || options.repositoryId,
          tree: treeItems,
          stats,
        };
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to get repository tree: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Zod input schema for validating arguments to the get_repository_tree tool.
    export const GetRepositoryTreeSchema = 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'),
      path: z
        .string()
        .optional()
        .default('/')
        .describe('Path within the repository to start from'),
      depth: z
        .number()
        .int()
        .min(0)
        .max(10)
        .optional()
        .default(0)
        .describe('Maximum depth to traverse (0 = unlimited)'),
    });
  • MCP tool registration definition including name, description, and JSON schema derived from Zod schema.
    {
      name: 'get_repository_tree',
      description:
        'Displays a hierarchical tree view of files and directories within a single repository starting from an optional path',
      inputSchema: zodToJsonSchema(GetRepositoryTreeSchema),
    },
  • Dispatcher handler case in handleRepositoriesRequest that validates input with schema and invokes the specific getRepositoryTree handler.
    case 'get_repository_tree': {
      const args = GetRepositoryTreeSchema.parse(request.params.arguments);
      const result = await getRepositoryTree(connection, {
        ...args,
        projectId: args.projectId ?? defaultProject,
      });
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • TypeScript interface defining input options for the getRepositoryTree handler function.
    export interface GetRepositoryTreeOptions {
      projectId: string;
      repositoryId: string;
      /**
       * Path within the repository to start from. Defaults to '/'
       */
      path?: string;
      /**
       * Maximum depth to traverse (0 = unlimited)
       */
      depth?: number;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions the tool 'displays' a tree view but doesn't disclose behavioral traits like whether it's read-only (implied but not stated), authentication needs, rate limits, pagination, or output format. For a tool with 5 parameters and no output schema, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Displays a hierarchical tree view...') and includes key details ('within a single repository', 'starting from an optional path'). There's no wasted verbiage, though it could be slightly more structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, no annotations, no output schema), the description is insufficient. It doesn't explain the return format (e.g., tree structure, file metadata), error conditions, or how parameters like 'depth' affect the output. Without annotations or output schema, the agent lacks critical context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'starting from an optional path' (implied by the 'path' parameter) and the hierarchical nature (implied by 'tree view'). It doesn't provide additional semantics like examples or edge cases, meeting the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Displays') and resource ('hierarchical tree view of files and directories within a single repository'). It distinguishes from siblings like 'get_file_content' (file content) and 'get_all_repositories_tree' (multiple repositories). However, it doesn't explicitly differentiate from 'list_repositories' or 'get_repository_details' beyond the tree view aspect.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'get_all_repositories_tree' (for multiple repositories) or 'list_repositories' (for repository metadata), nor does it specify prerequisites or exclusions. The agent must infer usage from the description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Tiberriver256/mcp-server-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server