Skip to main content
Glama

browse_repo

Explore Git repository files and folders to view directory structure, find specific files, or navigate project organization. Use this tool to browse repository contents by path and branch.

Instructions

Browse files and folders in a Git repository — like a directory listing.

USE THIS TOOL when the user wants to see what files are in a repo, explore folder structure, or find a specific file path.

Args: repo_name: Repository name (from list_repos). path: Folder path to browse (default '/' for root). Use forward slashes. branch: Branch name (default: repo's default branch). project: Project name (default from config).

Returns a directory listing with file/folder names and paths. Use read_repo_file(repo_name='...', path='...') to read a file's content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_nameYes
pathNo/
branchNo
projectNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main browse_repo handler function that browses files and folders in a Git repository by making an API call to Azure DevOps and returning a formatted directory listing with folders and files separated, including example commands to drill down further.
    def browse_repo(
        repo_name: str,
        path: str = "/",
        branch: str | None = None,
        project: str | None = None,
    ) -> str:
        """
        Browse files and folders in a Git repository — like a directory listing.
    
        USE THIS TOOL when the user wants to see what files are in a repo,
        explore folder structure, or find a specific file path.
    
        Args:
            repo_name: Repository name (from list_repos).
            path: Folder path to browse (default '/' for root). Use forward slashes.
            branch: Branch name (default: repo's default branch).
            project: Project name (default from config).
    
        Returns a directory listing with file/folder names and paths.
        Use read_repo_file(repo_name='...', path='...') to read a file's content.
        """
        url = f"{_project_url(project)}/_apis/git/repositories/{repo_name}/items"
        params: dict[str, str] = {
            "scopePath": path,
            "recursionLevel": "oneLevel",
        }
        if branch:
            params["versionDescriptor.version"] = branch
            params["versionDescriptor.versionType"] = "branch"
    
        data = _api_get(url, params=params)
    
        if isinstance(data, dict) and "error" in data:
            return data["error"]
    
        items = data.get("value", []) if isinstance(data, dict) else []
        if not items:
            return f"No items found at path '{path}' in repo '{repo_name}'."
    
        # Separate folders and files, skip the root entry itself
        folders = []
        files = []
        for item in items:
            item_path = item.get("path", "?")
            if item_path == path and item.get("isFolder", False):
                continue  # skip the directory entry itself
            if item.get("isFolder", False):
                folders.append(item)
            else:
                files.append(item)
    
        lines = [f"\U0001f4c2 **{repo_name}** \u2014 `{path}`\n"]
    
        if folders:
            lines.append(f"**Folders ({len(folders)}):**")
            for f in sorted(folders, key=lambda x: x.get("path", "")):
                folder_path = f.get("path", "?")
                folder_name = folder_path.rsplit("/", 1)[-1]
                lines.append(f"  \U0001f4c1 {folder_name}/")
                lines.append(f"     \u2192 `browse_repo(repo_name='{repo_name}', path='{folder_path}')`")
            lines.append("")
    
        if files:
            lines.append(f"**Files ({len(files)}):**")
            for f in sorted(files, key=lambda x: x.get("path", "")):
                file_path = f.get("path", "?")
                file_name = file_path.rsplit("/", 1)[-1]
                lines.append(f"  \U0001f4c4 {file_name}")
                lines.append(f"     \u2192 `read_repo_file(repo_name='{repo_name}', path='{file_path}')`")
            lines.append("")
    
        return "\n".join(lines)
  • Import statement that imports browse_repo from the azdo_tools module into the main server file.
    from mcp_server.tools.azdo_tools import (              # noqa: E402
        list_repos,
        browse_repo,
        browse_repo_recursive,
        read_repo_file,
        get_current_sprint,
        get_sprint_work_items,
        get_work_item_details,
        get_backlog,
    )
  • Tool registration with MCP - registers browse_repo as an available tool in the MCP server.
    # ── Register Azure DevOps tools (8) ─────────────────────────────────────────
    
    mcp.tool()(list_repos)
    mcp.tool()(browse_repo)
    mcp.tool()(browse_repo_recursive)
    mcp.tool()(read_repo_file)
    mcp.tool()(get_current_sprint)
    mcp.tool()(get_sprint_work_items)
  • Helper function _project_url that constructs the base URL for a project using the configured AZDO_BASE_URL and project name.
    def _project_url(project: str | None = None) -> str:
        """Build base URL for a project: {base}/{project}"""
        proj = project or AZDO_PROJECT
        return f"{AZDO_BASE_URL.rstrip('/')}/{proj}"
  • Helper function _api_get that makes authenticated GET requests to the Azure DevOps REST API, handling errors and connection issues automatically.
    def _api_get(url: str, params: dict | None = None) -> dict[str, Any] | list:
        """GET request to Azure DevOps REST API. api-version is injected automatically."""
        err = validate_azuredevops()
        if err:
            return {"error": err}
    
        session = _get_session()
        params = dict(params or {})
        params.setdefault("api-version", API_VERSION)
    
        try:
            resp = session.get(url, params=params, timeout=30)
            if resp.status_code >= 400:
                return {"error": f"Azure DevOps API returned HTTP {resp.status_code}: {resp.text[:500]}"}
            return resp.json()
        except requests.exceptions.ConnectionError as exc:
            return {"error": f"Cannot connect to Azure DevOps at {AZDO_BASE_URL}. Is VPN connected? Error: {exc}"}
        except Exception as exc:
            return {"error": f"Azure DevOps API error: {exc}"}
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it returns a directory listing (not file contents), uses forward slashes for paths, and has default values for path, branch, and project. It doesn't mention error conditions, rate limits, or authentication requirements, but covers the core operational behavior well.

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

Conciseness5/5

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

The description is well-structured with clear sections (purpose, usage guidelines, parameters, returns) and every sentence earns its place. It's appropriately sized for a tool with 4 parameters and no annotations, with no redundant or unnecessary information.

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

Completeness5/5

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

Given the tool's moderate complexity (4 parameters, no annotations, but with output schema), the description is complete. It covers purpose, usage scenarios, parameter semantics, and return behavior. The presence of an output schema means the description doesn't need to detail return values, and it appropriately references related tools for context.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by providing detailed parameter information in the 'Args' section. It explains what each parameter represents, provides default values, format guidance (forward slashes), and references other tools ('list_repos' for repo_name). This adds significant value beyond the bare schema.

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

Purpose5/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 specific verbs ('browse files and folders') and resources ('Git repository'), explicitly distinguishing it from sibling tools like 'read_repo_file' (for reading file content) and 'list_repos' (for listing repositories). The phrase 'like a directory listing' provides a helpful analogy.

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

Usage Guidelines5/5

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

The description includes an explicit 'USE THIS TOOL when' section that lists three specific scenarios (see what files are in a repo, explore folder structure, find a specific file path) and names an alternative tool ('read_repo_file') for reading file content, providing clear guidance on when to use this tool versus alternatives.

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/SrujanReddyKallu2024/MCP'

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