push_files
Push multiple files to a GitLab project in one commit using branch, commit message, and file content. Simplify file updates with batch processing.
Instructions
Push multiple files to a GitLab project in a single commit
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | ||
| commit_message | No | ||
| files | No | ||
| project_id | No |
Input Schema (JSON Schema)
{
"properties": {
"branch": {
"type": "string"
},
"commit_message": {
"type": "string"
},
"files": {
"items": {
"additionalProperties": false,
"properties": {
"content": {
"type": "string"
},
"path": {
"type": "string"
}
},
"required": [
"path",
"content"
],
"type": "object"
},
"type": "array"
},
"project_id": {
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:377-399 (handler)Handler for the 'push_files' tool. Parses input arguments using PushFilesSchema, iterates over each file, and calls gitlabApi.createOrUpdateFile to push each file individually (noted as workaround for batch commit). Returns array of results.case "push_files": { const args = PushFilesSchema.parse(request.params.arguments); // Use individual file creation for each file instead of batch commit const results = []; for (const file of args.files) { try { const result = await gitlabApi.createOrUpdateFile( args.project_id, file.path, file.content, args.commit_message, args.branch ); results.push(result); } catch (error) { console.error(`Error creating/updating file ${file.path}:`, error); throw error; } } return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] }; }
- src/schemas.ts:415-420 (schema)Zod schema definition for 'push_files' tool input: requires project_id, array of files (path/content), commit_message, branch.export const PushFilesSchema = z.object({ project_id: z.string(), files: z.array(FileOperationSchema), commit_message: z.string(), branch: z.string() });
- src/index.ts:132-137 (registration)Registration of the 'push_files' tool in the ALL_TOOLS array, including name, description, input schema, and readOnly flag. Used by ListToolsRequestSchema handler.{ name: "push_files", description: "Push multiple files to a GitLab project in a single commit", inputSchema: createJsonSchema(PushFilesSchema), readOnly: false },
- src/schemas.ts:354-358 (schema)Supporting schema for file operations used in PushFilesSchema (files array). Defines path and content for each file.export const FileOperationSchema = z.object({ path: z.string(), content: z.string() });