Skip to main content
Glama

push_files

Push multiple files to a GitLab project in a single commit, enabling batch file updates with specified paths, content, and commit message.

Instructions

Push multiple files to a GitLab project in a single commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
branchYesBranch to push to
filesYesArray of files to push
commit_messageYesCommit message

Implementation Reference

  • The request handler for "push_files" in src/server.ts. It parses the request arguments and calls the API function "createCommit".
    case "push_files": {
      const args = PushFilesSchema.parse(request.params.arguments);
      const result = await api.createCommit(
        args.project_id,
        args.commit_message,
        args.branch,
        args.files.map((f) => ({ path: f.file_path, content: f.content }))
      );
      return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
    }
  • The implementation of the API function `createCommit` that actually interacts with GitLab to push the files.
    export async function createCommit(
      projectId: string,
      message: string,
      branch: string,
      actions: FileOperation[]
    ): Promise<GitLabCommit> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!message?.trim()) {
        throw new Error("Commit message is required");
      }
      if (!branch?.trim()) {
        throw new Error("Branch is required");
      }
      if (!actions || actions.length === 0) {
        throw new Error("At least one file action is required");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/repository/commits`;
    
      const commit = await gitlabPost<GitLabCommit>(endpoint, {
        branch,
        commit_message: message,
        actions: actions.map((action) => ({
          action: "create",
          file_path: action.path,
          content: action.content
        }))
      });
    
      return GitLabCommitSchema.parse(commit);
    }

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

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