Skip to main content
Glama
harshmaur

GitLab MCP Server

by harshmaur

create_or_update_file

Create or update files in GitLab projects by specifying content, path, and commit details to manage repository files directly.

Instructions

Create or update a single file in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or complete URL-encoded path to project
file_pathYesPath where to create/update the file
contentYesContent of the file
commit_messageYesCommit message
branchYesBranch to create/update the file in
previous_pathNoPath of the file to move/rename
last_commit_idNoLast known file commit ID
commit_idNoCurrent file commit ID (for update operations)

Implementation Reference

  • Zod input schema definition for the 'create_or_update_file' tool, extending ProjectParamsSchema with file-specific parameters.
    export const CreateOrUpdateFileSchema = ProjectParamsSchema.extend({
      file_path: z.string().describe("Path where to create/update the file"),
      content: z.string().describe("Content of the file"),
      commit_message: z.string().describe("Commit message"),
      branch: z.string().describe("Branch to create/update the file in"),
      previous_path: z.string().optional().describe("Path of the file to move/rename"),
      last_commit_id: z.string().optional().describe("Last known file commit ID"),
      commit_id: z.string().optional().describe("Current file commit ID (for update operations)"),
    });
  • Response schema for the create_or_update_file tool operation.
    export const GitLabCreateUpdateFileResponseSchema = z.object({
      file_path: z.string(),
      branch: z.string(),
      commit_id: z.string().optional(), // Optional since it's not always returned by the API
      content: GitLabFileContentSchema.optional(),
    });
  • Base schema extended by CreateOrUpdateFileSchema for project_id parameter.
    const ProjectParamsSchema = z.object({
      project_id: z.string().describe("Project ID or complete URL-encoded path to project"), // Changed from owner/repo to match GitLab API
    });

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

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