git-sync
Synchronize Git repositories between local and remote providers. Perform sync operations or check status across GitHub and Gitea with configurable merge strategies and branch management.
Instructions
Advanced Git synchronization tool for intelligent sync and status operations. Supports both local Git synchronization and remote provider synchronization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | The Git sync operation to perform | |
| branch | No | Branch to sync (default: current branch) | |
| checkAhead | No | Check commits ahead/behind (default: true for status operation) | |
| detailed | No | Show detailed sync status (for status operation) | |
| dryRun | No | Show what would be done without executing (for sync operation) | |
| force | No | Force sync (use with caution, may override uncommitted changes) | |
| includeRemote | No | Include remote status information (for status operation) | |
| owner | No | Repository owner (auto-detected if not provided, for remote operations) | |
| projectPath | Yes | Absolute path to the project directory | |
| provider | No | Provider for remote operations (optional for local-only operations) | |
| remote | No | Remote to sync with (default: origin) | |
| repo | No | Repository name (auto-detected if not provided, for remote operations) | |
| strategy | No | Sync strategy (default: merge) |
Implementation Reference
- src/tools/git-sync.ts:74-126 (handler)Main execution handler for git-sync tool. Validates parameters, routes to sync/status handlers, and handles errors.async execute(params: GitSyncParams): Promise<ToolResult> { const startTime = Date.now(); try { // Validate basic parameters const validation = ParameterValidator.validateToolParams('git-sync', 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 = this.validateOperationParams(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 switch (params.action) { case 'sync': return await this.handleSync(params, startTime); case 'status': return await this.handleStatus(params, startTime); default: return OperationErrorHandler.createToolError( 'UNSUPPORTED_OPERATION', `Unsupported operation: ${params.action}`, params.action, { supportedOperations: ['sync', 'status'] }, ['Use one of the supported operations: sync, status'] ); } } catch (error) { const errorMessage = error instanceof Error ? error.message : 'Unknown error'; return OperationErrorHandler.createToolError( 'EXECUTION_ERROR', `Failed to execute git-sync operation: ${errorMessage}`, params.action, { error: errorMessage } ); } }
- src/tools/git-sync.ts:559-621 (schema)Tool schema definition for MCP registration, including input parameters like action (sync/status), projectPath, provider, remote, branch, etc.static getToolSchema() { return { name: 'git-sync', description: 'Advanced Git synchronization tool for intelligent sync and status operations. Supports both local Git synchronization and remote provider synchronization.', inputSchema: { type: 'object', properties: { action: { type: 'string', enum: ['sync', 'status'], description: 'The Git sync operation to perform' }, projectPath: { type: 'string', description: 'Absolute path to the project directory' }, provider: { type: 'string', enum: ['github', 'gitea', 'both'], description: 'Provider for remote operations (optional for local-only operations)' }, remote: { type: 'string', description: 'Remote to sync with (default: origin)' }, branch: { type: 'string', description: 'Branch to sync (default: current branch)' }, strategy: { type: 'string', enum: ['merge', 'rebase', 'fast-forward'], description: 'Sync strategy (default: merge)' }, force: { type: 'boolean', description: 'Force sync (use with caution, may override uncommitted changes)' }, dryRun: { type: 'boolean', description: 'Show what would be done without executing (for sync operation)' }, detailed: { type: 'boolean', description: 'Show detailed sync status (for status operation)' }, includeRemote: { type: 'boolean', description: 'Include remote status information (for status operation)' }, checkAhead: { type: 'boolean', description: 'Check commits ahead/behind (default: true for status operation)' }, repo: { type: 'string', description: 'Repository name (auto-detected if not provided, for remote operations)' } }, required: ['action', 'projectPath'] } }; }
- src/server.ts:498-499 (registration)Registration and dispatch: server routes 'git-sync' calls to GitSyncTool.execute()case 'git-sync': return await this.gitSyncTool.execute(args);
- src/server.ts:104-105 (registration)Tool instance initialization with provider config in server setup// Initialize git-sync with provider configuration (for remote sync) this.gitSyncTool = new GitSyncTool(providerConfig);
- Parameter validation schema defining supported operations for git-sync: sync, status'git-sync': ['sync', 'status'],