git-workflow
Manage Git repositories locally and remotely with operations including init, commit, sync, backup, and repository management for GitHub and Gitea platforms.
Instructions
Core Git workflow tool for local and remote Git operations. Supports init, status, commit, sync, backup, create, list, get, update, delete, fork, and search operations. Provides comprehensive Git repository management with both local and remote provider support (GitHub/Gitea).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The Git operation to perform. Local operations: init, status, commit, sync, backup. Remote operations: create, list, get, update, delete, fork, search (require provider parameter). | |
| backupPath | No | Path for backup file (for backup action) | |
| bare | No | Initialize as bare repository (for init action) | |
| branch | No | Branch name for sync | |
| description | No | Repository description (for create/update actions) | |
| files | No | Specific files to commit (default: all changes) | |
| force | No | Force operation (for sync action) | |
| message | No | Commit message (required for commit action) | |
| name | No | Repository name (for create action) | |
| owner | No | Repository owner (for get/update/delete/fork actions) | |
| private | No | Create private repository (for create action) | |
| projectPath | Yes | Absolute path to the project directory | |
| provider | No | Provider for remote operations (required for remote operations) | |
| query | No | Search query (for search action) | |
| remote | No | Remote name for sync (default: origin) | |
| repo | No | Repository name (for get/update/delete/fork actions) |
Implementation Reference
- src/tools/git-workflow.ts:60-107 (handler)Main execute handler for git-workflow tool: validates parameters, routes local Git operations (init, commit, sync, push, pull, status, backup) or remote repository operations (create, list, get, update, delete, fork, search) via providers.async execute(params: GitWorkflowParams): Promise<ToolResult> { const startTime = Date.now(); try { // Validate basic parameters const validation = ParameterValidator.validateToolParams('git-workflow', params); if (!validation.isValid) { return OperationErrorHandler.createToolError( 'VALIDATION_ERROR', `Parameter validation failed: ${validation.errors.join(', ')}`, params.action, { validationErrors: validation.errors }, validation.suggestions ); } // Validate operation-specific parameters const operationValidation = ParameterValidator.validateOperationParams('git-workflow', params.action, params); if (!operationValidation.isValid) { return OperationErrorHandler.createToolError( 'VALIDATION_ERROR', `Operation validation failed: ${operationValidation.errors.join(', ')}`, params.action, { validationErrors: operationValidation.errors }, operationValidation.suggestions ); } // Route to appropriate handler const isRemoteOperation = this.isRemoteOperation(params.action); if (isRemoteOperation) { return await this.executeRemoteOperation(params, startTime); } else { return await this.executeLocalOperation(params, startTime); } } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return OperationErrorHandler.createToolError( 'EXECUTION_ERROR', `Failed to execute ${params.action}: ${errorMessage}`, params.action, { error: errorMessage }, ['Check the error details and try again'] ); } }
- src/tools/git-workflow.ts:611-701 (schema)Tool schema definition for MCP registration, including name, description, and detailed inputSchema with all parameters for git-workflow.static getToolSchema() { return { name: 'git-workflow', description: 'Core Git workflow tool for local and remote Git operations. Supports init, status, commit, sync, backup, create, list, get, update, delete, fork, and search operations. Provides comprehensive Git repository management with both local and remote provider support (GitHub/Gitea). In universal mode (GIT_MCP_MODE=universal), automatically executes on both GitHub and Gitea providers.', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['init', 'status', 'commit', 'sync', 'backup', 'push', 'pull', 'create', 'list', 'get', 'update', 'delete', 'fork', 'search'], description: 'The Git operation to perform. Local operations: init, status, commit, sync, backup. Remote operations: create, list, get, update, delete, fork, search (require provider parameter).' }, projectPath: { type: 'string', description: 'Absolute path to the project directory' }, provider: { type: 'string', enum: ['github', 'gitea', 'both'], description: 'Provider for remote operations (required for remote operations)' }, message: { type: 'string', description: 'Commit message (required for commit action)' }, files: { type: 'array', items: { type: 'string' }, description: 'Specific files to commit (default: all changes)' }, bare: { type: 'boolean', description: 'Initialize as bare repository (for init action)' }, backupPath: { type: 'string', description: 'Path for backup file (for backup action)' }, name: { type: 'string', description: 'Repository name (for create action)' }, description: { type: 'string', description: 'Repository description (for create/update actions)' }, private: { type: 'boolean', description: 'Create private repository (for create action)' }, query: { type: 'string', description: 'Search query (for search action)' }, repo: { type: 'string', description: 'Repository name (for get/update/delete/fork actions)' }, remote: { type: 'string', description: 'Remote name for sync (default: origin)' }, branch: { type: 'string', description: 'Branch name for sync' }, force: { type: 'boolean', description: 'Force operation (for sync action)' }, pushRemote: { type: 'string', description: 'Remote name for push (default: origin)' }, pushBranch: { type: 'string', description: 'Branch name for push (default: current branch)' }, pullRemote: { type: 'string', description: 'Remote name for pull (default: origin)' }, pullBranch: { type: 'string', description: 'Branch name for pull (default: current branch)' } }, required: ['action', 'projectPath'] } }; }
- src/server.ts:122-146 (registration)Registration of git-workflow schema in MCP listTools handler via GitWorkflowTool.getToolSchema().this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ GitWorkflowTool.getToolSchema(), GitFilesTool.getToolSchema(), GitBranchesTool.getToolSchema(), GitIssuesTool.getToolSchema(), GitPullsTool.getToolSchema(), GitTagsTool.getToolSchema(), GitReleaseTool.getToolSchema(), GitRemoteTool.getToolSchema(), GitResetTool.getToolSchema(), GitStashTool.getToolSchema(), GitConfigTool.getToolSchema(), GitMonitorTool.getToolSchema(), GitBackupTool.getToolSchema(), GitArchiveTool.getToolSchema(), GitSyncTool.getToolSchema(), GitPackagesTool.getToolSchema(), GitAnalyticsTool.getToolSchema(), GitUpdateTool.getToolSchema(), GitHistoryTool.getToolSchema() ] }; });
- src/server.ts:468-511 (registration)Tool execution dispatch for git-workflow in server switch statement calling this.gitWorkflowTool.execute().private async executeTool(name: string, args: any): Promise<any> { switch (name) { case 'git-workflow': return await this.gitWorkflowTool.execute(args); case 'git-files': return await this.gitFilesTool.execute(args); case 'git-branches': return await this.gitBranchesTool.execute(args); case 'git-issues': return await this.gitIssuesTool.execute(args); case 'git-pulls': return await this.gitPullsTool.execute(args); case 'git-tags': return await this.gitTagsTool.execute(args); case 'git-release': return await this.gitReleaseTool.execute(args); case 'git-remote': return await this.gitRemoteTool.execute(args); case 'git-reset': return await this.gitResetTool.execute(args); case 'git-stash': return await this.gitStashTool.execute(args); case 'git-config': return await this.gitConfigTool.execute(args); case 'git-monitor': return await this.gitMonitorTool.execute(args); case 'git-backup': return await this.gitBackupTool.execute(args); case 'git-archive': return await this.gitArchiveTool.execute(args); case 'git-sync': return await this.gitSyncTool.execute(args); case 'git-packages': return await this.gitPackagesTool.execute(args); case 'git-analytics': return await this.gitAnalyticsTool.execute(args); case 'git-update': return await this.gitUpdateTool.execute(args); case 'git-history': return await this.gitHistoryTool.execute(args); default: throw new Error(`Tool execution not implemented: ${name}`); } }
- src/server.ts:87-87 (registration)Instantiation of GitWorkflowTool instance in server initialization with provider config.this.gitWorkflowTool = new GitWorkflowTool(providerConfig);
- TOOL_OPERATIONS constant defining supported actions for git-workflow used in validation.private static readonly TOOL_OPERATIONS: Record<string, string[]> = { 'git-workflow': ['init', 'commit', 'sync', 'status', 'backup', 'push', 'pull', 'create', 'list', 'get', 'update', 'delete', 'fork', 'search'], 'git-files': ['read', 'search', 'backup', 'list'], 'git-branches': ['create', 'list', 'get', 'delete', 'merge', 'compare'], 'git-issues': ['create', 'list', 'get', 'update', 'close', 'comment', 'search'], 'git-pulls': ['create', 'list', 'get', 'update', 'merge', 'close', 'review', 'search'], 'git-tags': ['create', 'list', 'get', 'delete', 'search'], 'git-release': ['create', 'list', 'get', 'update', 'delete', 'publish', 'download'], 'git-remote': ['add', 'remove', 'rename', 'show', 'set-url', 'prune', 'list'], 'git-reset': ['soft', 'mixed', 'hard', 'reset-to-commit', 'reset-branch'], 'git-stash': ['stash', 'pop', 'apply', 'list', 'show', 'drop', 'clear'], 'git-config': ['get', 'set', 'unset', 'list', 'edit', 'show'], 'git-monitor': ['log', 'status', 'commits', 'contributors'], 'git-backup': ['backup', 'restore', 'list', 'verify'], 'git-archive': ['create', 'extract', 'list', 'verify'], 'git-packages': ['list', 'get', 'create', 'update', 'delete', 'publish', 'download'], 'git-analytics': ['stats', 'commits', 'contributors'], 'git-sync': ['sync', 'status'], 'git-update': ['update', 'history', 'changelog', 'track', 'sync-providers', 'status', 'rollback', 'compare'], 'git-history': ['log', 'track', 'sync', 'export', 'auto'] };
- Operation-specific parameter validation for git-workflow actions.private static validateWorkflowParams(action: string, params: ToolParams): ValidationResult { const result: ValidationResult = { isValid: true, errors: [], warnings: [], suggestions: [] }; switch (action) { case 'commit': if (!params.message) { result.errors.push('message is required for commit operation'); result.suggestions.push('Provide a commit message describing your changes'); result.isValid = false; } break; case 'create': if (!params.name) { result.errors.push('name is required for repository creation'); result.suggestions.push('Provide a repository name'); result.isValid = false; } break; case 'get': case 'update': case 'delete': case 'fork': if (!params.repo) { result.errors.push('repo is required for repository operations'); result.suggestions.push('Provide repository name'); result.isValid = false; } break; case 'search': if (!params.query) { result.errors.push('query is required for search operation'); result.suggestions.push('Provide a search query string'); result.isValid = false; } break; case 'push': // Validate push parameters if (params.force) { result.warnings.push('Force push will override remote changes. Use with caution.'); } break; case 'pull': // Validate pull parameters if (params.strategy && !['merge', 'rebase', 'fast-forward'].includes(params.strategy)) { result.errors.push('Invalid pull strategy. Must be one of: merge, rebase, fast-forward'); result.suggestions.push('Use strategy: "merge", "rebase", or "fast-forward"'); result.isValid = false; } break; case 'backup': if (params.backupPath && typeof params.backupPath !== 'string') { result.errors.push('backupPath must be a string'); result.isValid = false; } break; case 'sync': if (params.remote && typeof params.remote !== 'string') { result.errors.push('remote must be a string'); result.isValid = false; } if (params.branch && typeof params.branch !== 'string') { result.errors.push('branch must be a string'); result.isValid = false; } break; } return result; }