Skip to content

Conversation

@Calvin-Francis
Copy link

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)

… GitHub

This new tool allows MCP clients to:
- Sync a local directory to a GitHub repository in a single commit
- Automatically create the repository if it doesn't exist
- Respect .gitignore patterns and skip binary files
- Configure max file count (default 100, max 500)

Use case: Enable AI assistants to push local codebases to GitHub without requiring git CLI.
@Calvin-Francis Calvin-Francis requested a review from a team as a code owner December 1, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant