Skip to main content
Glama

revert_commit

Revert a specific commit to a target branch in a GitLab project by specifying the commit SHA and branch.

Instructions

Revert a commit.

Args:
    project_id: GitLab project ID
    commit_sha: Commit SHA to revert
    branch: Target branch for revert
    token: GitLab Personal Access Token (optional)
    ctx: MCP context (automatically injected)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
commit_shaYes
branchYes
tokenNo
ctxNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `revert_commit` tool implementation - an MCP tool function decorated with @mcp.tool() that reverts a given commit via the GitLab API endpoint /projects/{project_id}/repository/commits/{commit_sha}/revert. It accepts project_id, commit_sha, branch, optional token, and ctx parameters, sends a POST request with the branch data, and returns a success or error message.
    @mcp.tool()
    async def revert_commit(project_id: int, commit_sha: str, branch: str, token: str = None, ctx=None) -> str:
        """Revert a commit.
        
        Args:
            project_id: GitLab project ID
            commit_sha: Commit SHA to revert
            branch: Target branch for revert
            token: GitLab Personal Access Token (optional)
            ctx: MCP context (automatically injected)
        """
        data = {"branch": branch}
        result = await make_gitlab_request(f"/projects/{project_id}/repository/commits/{commit_sha}/revert", "POST", data, ctx=ctx, token=token)
        
        if isinstance(result, dict) and "error" in result:
            return f"Error reverting commit: {result['error']}"
        
        return f"Commit {commit_sha} reverted successfully: {result['short_id']}"
  • The tool is registered via the @mcp.tool() decorator on line 893, which registers `revert_commit` as an MCP tool with the FastMCP server instance.
    @mcp.tool()
    async def revert_commit(project_id: int, commit_sha: str, branch: str, token: str = None, ctx=None) -> str:
Behavior2/5

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

With no annotations, the description must fully disclose behavior. It only states 'Revert a commit' without explaining side effects (e.g., creation of a new revert commit), error conditions, or required permissions. This is minimal for a mutation tool.

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 concise with a one-line summary followed by parameter details. It is front-loaded with the purpose and uses a standard docstring format. The inclusion of 'automatically injected' for ctx is helpful, but the parameter list adds some verbosity.

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?

The description lacks crucial context such as return value, conflict resolution behavior, permission requirements, and failure scenarios. Given the tool's complexity and the presence of an output schema, more explanation is needed for an agent to use it safely.

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

Parameters4/5

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

Schema coverage is 0%, so the description carries the burden. It provides clear semantics for all 5 parameters (e.g., 'GitLab project ID', 'Commit SHA to revert', 'Target branch for revert', token optionality, and context auto-injection). This adds significant value beyond the bare schema names.

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 reverts a commit, using a specific verb and resource. It distinguishes from siblings like cherry_pick_commit or create_commit, which perform different operations.

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?

No guidance is provided on when to use this tool versus alternatives, nor any conditions or prerequisites (e.g., need for push permissions, conflict handling). The description only states the action without usage context.

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/skmprb/gitlab-clone-mcp-server'

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