github-mcp-server icon indicating copy to clipboard operation
github-mcp-server copied to clipboard

feat: add sync_local_repository tool for syncing local directories to GitHub

Open Calvin-Francis opened this issue 4 weeks ago • 0 comments

Summary

This PR adds a new sync_local_repository tool that enables MCP clients to sync local directories directly to GitHub repositories without requiring the git CLI.

Motivation

Currently, MCP clients can push individual files via push_files, but there's no convenient way to sync an entire local directory. This is particularly useful for AI assistants that need to help users:

  • Initialize new projects on GitHub
  • Push local codebases without git setup
  • Sync workspace changes in a single operation

Changes

New Tool: sync_local_repository

Parameter Type Required Description
local_path string Absolute path to the local directory
owner string Repository owner
repo string Repository name
message string Commit message
branch string Branch to push to (default: main)
create_repo boolean Auto-create repository if missing
private boolean Make new repo private (default: true)
max_files number Max files to sync (default: 100, max: 500)

Features:

  • Respects .gitignore patterns
  • Skips binary files automatically
  • Can optionally create the repository if it doesn't exist
  • Single atomic commit for all files

Files Changed

  • pkg/github/local_sync.go - New tool implementation
  • pkg/github/tools.go - Register tool in repos toolset

Testing

Tested locally with Windsurf MCP client:

  • ✅ Successfully synced 246 files to a new repository
  • ✅ Correctly skipped binary files and ignored patterns
  • ✅ Auto-created repository when create_repo=true

Limitations

  • Maximum 500 files per sync (GitHub API constraint)
  • Binary files are skipped (text files only)
  • Simplified gitignore matching (no negation patterns)

Calvin-Francis avatar Dec 01 '25 11:12 Calvin-Francis