Skip to main content
Glama

gitlab_safe_preview_commit

Validate and preview GitLab commit changes without applying them. Checks affected files, permissions, file paths, and potential errors. Use to ensure accuracy and safety before committing.

Instructions

Preview commit without creating Returns: What would change, validation results Use when: Validating before actual commit Shows: Affected files, potential errors

Safety features:

  • No actual changes made

  • Validates file paths

  • Checks permissions

Related tools:

  • gitlab_create_commit: Actual commit

  • gitlab_list_repository_tree: Check files exist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionsYesFile operations for commit Type: array of objects Required: Yes Max items: 100 per commit Structure: { "action": "create" | "update" | "delete" | "move", "file_path": "string (required)", "content": "string (required for create/update)", "encoding": "text" | "base64" (optional, default: text)", "previous_path": "string (required for move)" } Examples: [ { "action": "create", "file_path": "src/config.json", "content": "{"debug": true}" }, { "action": "update", "file_path": "README.md", "content": "# Updated README\n\nNew content here" }, { "action": "delete", "file_path": "old-file.txt" }, { "action": "move", "file_path": "new-location/file.txt", "previous_path": "old-location/file.txt" } ] Use cases: - create: Add new files - update: Modify existing files - delete: Remove files - move: Rename or relocate files
branchYesTarget branch for commits Type: string Required: Yes Format: Existing branch name Examples: - 'main' (commit to main) - 'feature/add-login' (feature branch) - 'hotfix/security-patch' (hotfix branch) Note: Branch must exist before committing
commit_messageYesCommit message Type: string Required: Yes Format: Conventional commits recommended Structure: - First line: Summary (50-72 chars) - Blank line - Body: Detailed description - Footer: References, breaking changes Examples: 'feat: Add user authentication Implement JWT-based authentication with refresh tokens. Store tokens securely in httpOnly cookies. Closes #123'
project_idNoProject identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted

Implementation Reference

  • The main handler function that implements the core logic for the 'gitlab_safe_preview_commit' tool. It validates required inputs, detects the project if needed, and calls the underlying GitLabClient.safe_preview_commit method to perform the preview operation.
    def handle_safe_preview_commit(client: GitLabClient, arguments: Optional[Dict[str, Any]]) -> Dict[str, Any]: """Handle previewing a commit""" project_id = require_project_id(client, arguments) branch = require_argument(arguments, "branch") commit_message = require_argument(arguments, "commit_message") actions = require_argument(arguments, "actions") return client.safe_preview_commit(project_id, branch, commit_message, actions)
  • Registration of the tool handler in the TOOL_HANDLERS dictionary, mapping the tool name 'gitlab_safe_preview_commit' to its handler function. This dict is imported and used by server.py.handle_call_tool().
    TOOL_SAFE_PREVIEW_COMMIT: handle_safe_preview_commit,
  • Pydantic/MCP schema definition for the gitlab_safe_preview_commit tool, including input validation schema with required fields and structure for file actions.
    types.Tool( name=TOOL_SAFE_PREVIEW_COMMIT, description=desc.DESC_SAFE_PREVIEW_COMMIT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "branch": {"type": "string", "description": desc.DESC_BRANCH}, "commit_message": {"type": "string", "description": desc.DESC_COMMIT_MESSAGE}, "actions": { "type": "array", "description": desc.DESC_ACTIONS, "items": { "type": "object", "properties": { "action": {"type": "string", "enum": ["create", "update", "delete", "move"]}, "file_path": {"type": "string"}, "content": {"type": "string"}, "previous_path": {"type": "string"}, "encoding": {"type": "string", "enum": ["text", "base64"], "default": "text"} }, "required": ["action", "file_path"] } } }, "required": ["branch", "commit_message", "actions"] } ),
  • Tool registration and schema definition within the server.list_tools() method, which exposes the tool to MCP clients.
    name="gitlab_safe_preview_commit", description=desc.DESC_SAFE_PREVIEW_COMMIT, inputSchema={ "type": "object", "properties": { "project_id": {"type": "string", "description": desc.DESC_PROJECT_ID}, "branch": {"type": "string", "description": desc.DESC_BRANCH}, "commit_message": {"type": "string", "description": desc.DESC_COMMIT_MESSAGE}, "actions": { "type": "array", "description": desc.DESC_ACTIONS, "items": { "type": "object", "properties": { "action": {"type": "string", "enum": ["create", "update", "delete", "move"]}, "file_path": {"type": "string"}, "content": {"type": "string"}, "previous_path": {"type": "string"}, "encoding": {"type": "string", "enum": ["text", "base64"], "default": "text"} }, "required": ["action", "file_path"] } } }, "required": ["branch", "commit_message", "actions"] } ),
  • Constant definition for the tool name string, used across handler registration, schema definitions, and tool mappings.
    TOOL_SAFE_PREVIEW_COMMIT = "gitlab_safe_preview_commit"

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/Vijay-Duke/mcp-gitlab'

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