Skip to main content
Glama

refresh_repository

Update local Git repositories by checking out the main branch and pulling all remote changes. Use this tool to ensure your repository is current and synchronized with the latest updates.

Instructions

Refresh repository by checking out main branch and pulling all remotes

Args:
    repo_name: Name of the git repository

Returns:
    Dictionary containing status and information about the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the refresh_repository tool, registered via @mcp.tool(). It validates the repository, checks out the main or master branch, fetches and pulls the latest changes from all configured remotes, and returns the status and results.
    @mcp.tool()
    async def refresh_repository(ctx: Context, repo_name: str) -> Dict:
        """Refresh repository by checking out main branch and pulling all remotes
    
        Args:
            repo_name: Name of the git repository
    
        Returns:
            Dictionary containing status and information about the operation
        """
        git_ctx = ctx.get_context(GitContext)
        repo_path = os.path.join(git_ctx.git_repos_path, repo_name)
    
        # Validate repository exists
        if not os.path.exists(repo_path) or not os.path.exists(
            os.path.join(repo_path, ".git")
        ):
            raise ValueError(f"Repository not found: {repo_name}")
    
        try:
            # Get all remotes
            remotes = _run_git_command(repo_path, ["remote"]).strip().split("\n")
            if not remotes or remotes[0] == "":
                return {
                    "status": "error",
                    "error": f"No remotes configured for repository {repo_name}",
                }
    
            # Checkout main branch
            try:
                _run_git_command(repo_path, ["checkout", "main"])
            except ValueError as e:
                # Try master if main doesn't exist
                try:
                    _run_git_command(repo_path, ["checkout", "master"])
                except ValueError:
                    return {
                        "status": "error",
                        "error": f"Failed to checkout main or master branch: {str(e)}",
                    }
    
            # Pull from all remotes
            pull_results = {}
            for remote in remotes:
                if remote:  # Skip empty remote names
                    try:
                        result = _run_git_command(repo_path, ["pull", remote, "main"])
                        pull_results[remote] = "success"
                    except ValueError as e:
                        # Try master if main doesn't exist
                        try:
                            result = _run_git_command(repo_path, ["pull", remote, "master"])
                            pull_results[remote] = "success"
                        except ValueError as e:
                            pull_results[remote] = f"error: {str(e)}"
    
            return {
                "status": "success",
                "repository": repo_name,
                "branch": "main",
                "pull_results": pull_results,
            }
    
        except Exception as e:
            return {"status": "error", "error": f"Failed to refresh repository: {str(e)}"}
Behavior3/5

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

No annotations are provided, so the description carries full burden. It discloses the core behavior (checkout main, pull remotes) and return format (dictionary with status/info), which is helpful. However, it lacks details on error handling (e.g., if repo doesn't exist), side effects (e.g., overwrites local changes), or operational constraints (e.g., network dependencies). The description adds basic context but misses key behavioral traits.

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 appropriately sized and front-loaded: the first sentence states the core action, followed by structured Args/Returns sections. Every sentence earns its place, though the Args section is redundant with the schema. It's efficient but could be more streamlined by integrating param details into the prose.

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

Completeness3/5

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

Given 1 parameter with 0% schema coverage, no annotations, and an output schema (implied by Returns statement), the description is moderately complete. It covers the basic operation and return format, but lacks context on errors, prerequisites, or sibling tool relationships. For a mutation tool with no annotation support, it should provide more safety and usage guidance to be fully adequate.

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 0%, so the schema provides no param details. The description adds minimal semantics by naming 'repo_name' and stating it's the 'Name of the git repository', but doesn't clarify format (e.g., path, URL, alias) or constraints. It compensates slightly over the bare schema but doesn't fully address the coverage gap for this single parameter.

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 specific verbs ('checking out main branch and pulling all remotes') and identifies the resource ('git repository'). It distinguishes from siblings like 'list_repositories' (listing) and 'create_git_tag' (tagging), though it doesn't explicitly contrast with them. The purpose is unambiguous but lacks explicit sibling differentiation.

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 prerequisites (e.g., repository must exist locally), exclusions (e.g., not for repositories with uncommitted changes), or compare to siblings like 'list_repositories' for discovery. Usage is implied by the action described but not explicitly framed.

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

Related 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/kjozsa/git-mcp'

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