bulk_action
Perform multiple Git operations in sequence on a repository using a single command. Stages files, commits changes, and pushes updates efficiently.
Instructions
Execute multiple Git operations in sequence. This is the preferred way to execute multiple operations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actions | Yes | Array of Git operations to execute in sequence | |
| path | No | Path to repository. MUST be an absolute path (e.g., /Users/username/projects/my-repo) |
Implementation Reference
- src/git-operations.ts:288-342 (handler)Core handler function that executes the bulk_action tool logic by iterating over the actions array and calling individual git operations (add/stage, commit, push) sequentially, collecting results or errors.static async executeBulkActions(options: BulkActionOptions, context: GitToolContext): Promise<GitToolResult> { const resolvedPath = this.getPath(options); return await this.executeOperation( context.operation, resolvedPath, async () => { const { path: repoPath } = PathValidator.validateGitRepo(resolvedPath); const results: string[] = []; for (const action of options.actions) { try { switch (action.type) { case 'stage': { const files = action.files || ['.']; const addResult = await this.add({ path: repoPath, files }, context); results.push(addResult.content[0].text); break; } case 'commit': { const commitResult = await this.commit({ path: repoPath, message: action.message }, context); results.push(commitResult.content[0].text); break; } case 'push': { const pushResult = await this.push({ path: repoPath, remote: action.remote, branch: action.branch }, context); results.push(pushResult.content[0].text); break; } } } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; results.push(`Failed to execute ${action.type}: ${errorMessage}`); if (error instanceof Error) { logger.error(context.operation, `Bulk action ${action.type} failed`, repoPath, error); } } } return { content: [{ type: 'text', text: results.join('\n\n') }] }; }, { command: 'bulk_action', invalidateCache: true // Invalidate all caches } ); }
- src/tool-handler.ts:490-555 (registration)MCP tool registration for 'bulk_action', including name, description, and detailed input schema defining the actions array with stage, commit, push variants.{ name: 'bulk_action', description: 'Execute multiple Git operations in sequence. This is the preferred way to execute multiple operations.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: `Path to repository. ${PATH_DESCRIPTION}`, }, actions: { type: 'array', description: 'Array of Git operations to execute in sequence', items: { type: 'object', oneOf: [ { type: 'object', properties: { type: { const: 'stage' }, files: { type: 'array', items: { type: 'string', description: FILE_PATH_DESCRIPTION, }, description: 'Files to stage. If not provided, stages all changes.', }, }, required: ['type'], }, { type: 'object', properties: { type: { const: 'commit' }, message: { type: 'string', description: 'Commit message', }, }, required: ['type', 'message'], }, { type: 'object', properties: { type: { const: 'push' }, remote: { type: 'string', description: 'Remote name', default: 'origin', }, branch: { type: 'string', description: 'Branch name', }, }, required: ['type', 'branch'], }, ], }, minItems: 1, }, }, required: ['actions'], }, },
- src/types.ts:110-131 (schema)TypeScript interfaces defining the structure of individual bulk actions (stage, commit, push) and the overall BulkActionOptions used by the tool.export interface BulkActionStage { type: 'stage'; files?: string[]; // If not provided, stages all files } export interface BulkActionCommit { type: 'commit'; message: string; } export interface BulkActionPush { type: 'push'; remote?: string; branch: string; } export type BulkAction = BulkActionStage | BulkActionCommit | BulkActionPush; export interface BulkActionOptions extends GitOptions, BasePathOptions { actions: BulkAction[]; }
- src/types.ts:202-224 (schema)Type guard function for validating BulkActionOptions inputs, ensuring path validity and correct structure for each action type.export function isBulkActionOptions(obj: any): obj is BulkActionOptions { if (!obj || !validatePath(obj.path) || !Array.isArray(obj.actions)) { return false; } return obj.actions.every((action: any) => { if (!action || typeof action.type !== 'string') { return false; } switch (action.type) { case 'stage': return !action.files || (Array.isArray(action.files) && action.files.every((f: any) => typeof f === 'string' && isAbsolutePath(f))); case 'commit': return typeof action.message === 'string'; case 'push': return typeof action.branch === 'string'; default: return false; } }); }
- src/tool-handler.ts:668-671 (registration)Tool executor switch case that validates arguments using isBulkActionOptions and delegates to GitOperations.executeBulkActions.case 'bulk_action': { const validArgs = this.validateArguments(operation, args, isBulkActionOptions); return await GitOperations.executeBulkActions(validArgs, context); }