Skip to main content
Glama

create_commit

Create a commit in a GitLab project on a specified branch, supporting file create, update, or delete actions with custom content.

Instructions

Create a commit with file changes.

Args:
    project_id: GitLab project ID
    branch: Target branch
    commit_message: Commit message
    file_path: Path to the file
    file_content: File content
    action: Action (create, update, delete)
    token: GitLab Personal Access Token (optional)
    ctx: MCP context (automatically injected)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
branchYes
commit_messageYes
file_pathYes
file_contentYes
actionNocreate
tokenNo
ctxNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async function `create_commit` is the handler for the 'create_commit' tool. It accepts project_id, branch, commit_message, file_path, file_content, and action parameters, then makes a POST request to the GitLab API's /projects/{project_id}/repository/commits endpoint to create a commit with the specified file changes.
    @mcp.tool()
    async def create_commit(project_id: int, branch: str, commit_message: str, file_path: str, file_content: str, action: str = "create", token: str = None, ctx=None) -> str:
        """Create a commit with file changes.
        
        Args:
            project_id: GitLab project ID
            branch: Target branch
            commit_message: Commit message
            file_path: Path to the file
            file_content: File content
            action: Action (create, update, delete)
            token: GitLab Personal Access Token (optional)
            ctx: MCP context (automatically injected)
        """
        data = {
            "branch": branch,
            "commit_message": commit_message,
            "actions": [{
                "action": action,
                "file_path": file_path,
                "content": file_content if action != "delete" else None
            }]
        }
        
        result = await make_gitlab_request(f"/projects/{project_id}/repository/commits", "POST", data, ctx=ctx, token=token)
        
        if isinstance(result, dict) and "error" in result:
            return f"Error creating commit: {result['error']}"
        
        return f"Commit created: {result['short_id']} - {result['title']}"
  • The `@mcp.tool()` decorator on line 365 registers the `create_commit` function as an MCP tool named 'create_commit' (Python function name is used as the tool name by FastMCP).
    @mcp.tool()
    async def create_commit(project_id: int, branch: str, commit_message: str, file_path: str, file_content: str, action: str = "create", token: str = None, ctx=None) -> str:
  • The function signature defines the input schema for create_commit: project_id (int), branch (str), commit_message (str), file_path (str), file_content (str), action (str with default 'create'), token (optional str), ctx (injected context). The docstring describes each parameter.
    async def create_commit(project_id: int, branch: str, commit_message: str, file_path: str, file_content: str, action: str = "create", token: str = None, ctx=None) -> str:
        """Create a commit with file changes.
        
        Args:
            project_id: GitLab project ID
            branch: Target branch
            commit_message: Commit message
            file_path: Path to the file
            file_content: File content
            action: Action (create, update, delete)
            token: GitLab Personal Access Token (optional)
            ctx: MCP context (automatically injected)
Behavior3/5

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

The description implies mutation by mentioning 'create a commit' and the action parameter, but does not disclose side effects, permissions needed, or whether changes are reversible. Since no annotations exist, the description carries the full burden but falls short of being thorough.

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

Conciseness3/5

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

The description is relatively concise but the parameter list format is repetitive. The main purpose is front-loaded, but some lines could be streamlined.

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?

Output schema exists, so return value explanation is not needed. However, the description lacks usage context compared to siblings, and does not fully detail the commit behavior (e.g., single file per commit). Overall adequate but not complete.

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?

With 0% schema description coverage, the description adds value by explaining each parameter, including optional token and auto-injected ctx. The action parameter options (create, update, delete) are clarified, though format details for file_path and file_content are not elaborated.

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 'Create a commit with file changes', using a specific verb and resource. It distinguishes from sibling tools like create_file or update_file by explicitly targeting commit creation.

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 like create_file or update_file. The description lacks explicit when-to-use or when-not-to-use advice.

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