Skip to main content
Glama

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
NameRequiredDescriptionDefault
actionYesThe Git sync operation to perform
branchNoBranch to sync (default: current branch)
checkAheadNoCheck commits ahead/behind (default: true for status operation)
detailedNoShow detailed sync status (for status operation)
dryRunNoShow what would be done without executing (for sync operation)
forceNoForce sync (use with caution, may override uncommitted changes)
includeRemoteNoInclude remote status information (for status operation)
ownerNoRepository owner (auto-detected if not provided, for remote operations)
projectPathYesAbsolute path to the project directory
providerNoProvider for remote operations (optional for local-only operations)
remoteNoRemote to sync with (default: origin)
repoNoRepository name (auto-detected if not provided, for remote operations)
strategyNoSync strategy (default: merge)

Implementation Reference

  • 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 } ); } }
  • 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'],

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/Andre-Buzeli/git-mcp'

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