sync Command¶
Synchronize standards from the configured GitHub repository.
Synopsis¶
Description¶
The sync
command downloads standards files from a GitHub repository and caches them locally. It supports incremental updates, force synchronization, and checking for updates without downloading.
Options¶
-f, --force
¶
Force synchronization of all files, ignoring cache TTL.
--check
¶
Check for updates without downloading files.
--include <pattern>
¶
Include only files matching the pattern (glob syntax).
--exclude <pattern>
¶
Exclude files matching the pattern.
--parallel <n>
¶
Number of parallel downloads (default: 5).
--retry <n>
¶
Number of retry attempts for failed downloads (default: 3).
--timeout <seconds>
¶
Timeout for each file download (default: 30).
Examples¶
Basic Sync¶
Output:
Starting standards synchronization...
Fetching file list from williamzujkowski/standards...
Files to sync: 25
Downloading: web-development-standards.yaml... [OK]
Downloading: api-design-standards.yaml... [OK]
...
Sync completed with status: success
Duration: 12.34 seconds
Files synced: 25/25
Check for Updates¶
Output:
Checking for updates...
Outdated files (3):
- web-development-standards.yaml (last synced 48.2 hours ago)
- testing-standards.yaml (last synced 72.5 hours ago)
- security-standards.yaml (last synced 96.1 hours ago)
Total cached files: 25
Cache TTL: 24 hours
Force Sync Specific Files¶
Sync with Custom Configuration¶
Configuration¶
The sync command uses the following configuration section:
# .mcp-standards.yaml
repository:
owner: williamzujkowski
repo: standards
branch: main
path: standards
sync:
cache_ttl_hours: 24
parallel_downloads: 5
retry_attempts: 3
timeout_seconds: 30
include_patterns:
- "*.yaml"
- "*.md"
exclude_patterns:
- "*.draft.*"
- ".git*"
cache:
directory: ~/.cache/mcp-standards
max_size_mb: 500
Error Handling¶
The sync command handles various error scenarios:
Network Errors¶
mcp-standards sync
# Error: Failed to connect to GitHub API
# Suggestion: Check internet connection and GitHub status
Rate Limiting¶
mcp-standards sync
# Warning: GitHub API rate limit reached (60/60)
# Suggestion: Wait until 2025-07-08 15:30:00 or configure authentication
Permission Errors¶
mcp-standards sync
# Error: Permission denied writing to cache directory
# Suggestion: Check directory permissions or use --cache-dir
Performance Considerations¶
- Parallel Downloads: Increase
--parallel
for faster syncs on good connections - Caching: Files are cached based on TTL to minimize API calls
- Incremental Sync: Only outdated files are downloaded by default
- Compression: Files are compressed in cache to save disk space
Integration Examples¶
CI/CD Pipeline¶
#!/bin/bash
# ci-sync-standards.sh
# Check if sync is needed
if mcp-standards sync --check | grep -q "Outdated files"; then
echo "Syncing outdated standards..."
mcp-standards sync --retry 5 --timeout 60
else
echo "Standards are up to date"
fi
Pre-commit Hook¶
#!/bin/bash
# .git/hooks/pre-commit
# Ensure standards are synced before commit
mcp-standards sync --check || {
echo "Standards are outdated. Run 'mcp-standards sync' first."
exit 1
}
Scheduled Sync¶
# Crontab entry - sync standards daily at 2 AM
0 2 * * * /usr/local/bin/mcp-standards sync >> /var/log/mcp-standards-sync.log 2>&1