Feature Description
This skill is specifically used to automate various operations on the GitHub platform, including:
- Repository management and file operations
- Pull Request creation and review
- Issue management and tracking
- Branch management and merging
- CI/CD workflow automation
- Code search and analysis
Use Cases
- "Create a new GitHub repository"
- "Commit code and create a Pull Request"
- "Batch process GitHub Issues"
- "Automate the code review process"
- "Search for specific code in a codebase"
- "Manage GitHub Actions workflows"
⚠️ Important: Use GitHub MCP to push code
When you need to push to GitHub, prefer using mcporter call github.push_files instead of git push!
Why use GitHub MCP?
- ✅ No Personal Access Token required - Uses an authenticated GitHub Copilot token
- ✅ Avoids authentication issues - Still works when the SSH key is not configured or the HTTPS token has expired
- ✅ Batch commits - Commit multiple files at once
- ✅ More reliable - Directly through the GitHub API, unaffected by local git configuration
Code push example
Method 1: Use mcporter (recommended)
# 单个文件
mcporter call github.push_files \
owner=aAAaqwq \
repo=my-repo \
branch=master \
message="feat: add new feature" \
files='[{"path":"README.md","content":"file content"}]'
# 多个文件(使用 Python)
python3 << 'EOF'
import json
import subprocess
payload = {
"owner": "aAAaqwq",
"repo": "my-repo",
"branch": "master",
"message": "feat: update multiple files",
"files": [
{"path": "README.md", "content": "..."},
{"path": "src/main.py", "content": "..."}
]
}
result = subprocess.run([
'mcporter', 'call', 'github.push_files',
f'owner={payload["owner"]}',
f'repo={payload["repo"]}',
f'branch={payload["branch"]}',
f'message={payload["message"]}',
f'files={json.dumps(payload["files"])}'
], capture_output=True, text=True)
print(result.stdout)
EOF
Method 2: Traditional git push (requires authentication configuration)
# 仅在 MCP 不可用时使用
git push origin master
MCP Tool List
View all available tools:
mcporter list github --schema
Common tools:
github.push_files- Push multiple files to a repositorygithub.create_or_update_file- Create or update a single filegithub.get_file_contents- Get file contentsgithub.list_commits- List commit history
Core Feature Modules
1. Repository Management
- Create repository: Create a new public or private repository
- Fork repository: Fork another repository to your own account
- Search repositories: Search repositories by keyword
- File operations: Read, create, update files
- Batch commit: Commit multiple files at once
2. Pull Request Management
- Create PR: Create a Pull Request from a branch
- Review PR: Add comments and review feedback
- Merge PR: Merge a Pull Request
- View changes: Get the file changes of a PR
- Status check: View CI/CD status
3. Issue Management
- Create Issue: Create a new issue or task
- Update Issue: Modify status, labels, assignees
- Search Issues: Filter Issues by criteria
- Add comments: Add discussion in an Issue
- Batch operations: Batch process multiple Issues
4. Branch Management
- Create branch: Create a new branch from a specified branch
- View commits: List the commit history of a branch
- Branch protection: Configure branch protection rules
- Merge strategy: Choose the merge method (merge, squash, rebase)
5. Code search
- Search code: Search for code snippets in the repository
- Search Issues: Search issues and PRs
- Search users: Find GitHub users
- Advanced queries: Use GitHub search syntax
Workflow
Standard development workflow
- Create branch: Create a feature branch from main
- Develop code: Write and test code
- Commit changes: Commit files to the branch
- Create PR: Create a Pull Request
- Code review: Team reviews the code
- Merge code: Merge into the main branch
Automated release workflow
- Listen for events: Listen for push or tag events
- Run tests: Execute automated tests
- Build project: Compile and package
- Create Release: Publish a new version
- Deploy application: Automatically deploy to production
Issue management workflow
- Create Issue: Report a problem or requirement
- Assign tasks: Specify the person responsible
- Add labels: Classification and priority
- Track progress: Update status
- Close Issue: Close after completion
Best practices
Commit conventions
- Use clear commit messages
- Follow the Conventional Commits specification
- One commit solves one problem
- Include necessary tests and documentation
PR conventions
- Provide a detailed PR description
- Link related Issues
- Ensure CI checks pass
- Respond to review comments promptly
- Keep PRs a moderate size
Branch strategy
- Use Git Flow or GitHub Flow
- Protect the main branch
- Regularly sync with the upstream branch
- Delete merged branches promptly
Security practices
- Do not commit sensitive information
- Use GitHub Secrets to manage keys
- Enable two-factor authentication
- Regularly review permission settings
Common code examples
1. Create a repository and commit files
// 创建仓库
const repo = await createRepository({
name: "my-project",
description: "项目描述",
private: false,
autoInit: true
});
// 批量提交文件
await pushFiles({
owner: "username",
repo: "my-project",
branch: "main",
files: [
{
path: "README.md",
content: "# My Project\n\n项目说明"
},
{
path: "src/index.js",
content: "console.log('Hello World');"
}
],
message: "Initial commit"
});
2. Create branches and Pull Requests
// 创建新分支
await createBranch({
owner: "username",
repo: "my-project",
branch: "feature/new-feature",
from_branch: "main"
});
// 提交代码到新分支
await createOrUpdateFile({
owner: "username",
repo: "my-project",
path: "src/feature.js",
content: "// 新功能代码",
message: "Add new feature",
branch: "feature/new-feature"
});
// 创建 Pull Request
await createPullRequest({
owner: "username",
repo: "my-project",
title: "添加新功能",
head: "feature/new-feature",
base: "main",
body: "## 变更说明\n- 添加了新功能\n- 更新了文档"
});
3. Issue management
// 创建 Issue
const issue = await createIssue({
owner: "username",
repo: "my-project",
title: "修复登录问题",
body: "## 问题描述\n用户无法登录\n\n## 复现步骤\n1. 打开登录页面\n2. 输入凭证\n3. 点击登录",
labels: ["bug", "high-priority"],
assignees: ["developer1"]
});
// 添加评论
await addIssueComment({
owner: "username",
repo: "my-project",
issue_number: issue.number,
body: "正在调查此问题"
});
// 更新 Issue
await updateIssue({
owner: "username",
repo: "my-project",
issue_number: issue.number,
state: "closed",
labels: ["bug", "fixed"]
});
4. Code review
// 获取 PR 详情
const pr = await getPullRequest({
owner: "username",
repo: "my-project",
pull_number: 123
});
// 获取 PR 文件变更
const files = await getPullRequestFiles({
owner: "username",
repo: "my-project",
pull_number: 123
});
// 创建审查
await createPullRequestReview({
owner: "username",
repo: "my-project",
pull_number: 123,
body: "代码看起来不错,有几点建议",
event: "COMMENT",
comments: [
{
path: "src/index.js",
line: 10,
body: "建议添加错误处理"
}
]
});
// 合并 PR
await mergePullRequest({
owner: "username",
repo: "my-project",
pull_number: 123,
merge_method: "squash",
commit_title: "feat: 添加新功能"
});
5. Search and query
// 搜索代码
const codeResults = await searchCode({
q: "function login repo:username/my-project"
});
// 搜索 Issue
const issueResults = await searchIssues({
q: "is:open label:bug repo:username/my-project",
sort: "created",
order: "desc"
});
// 搜索仓库
const repoResults = await searchRepositories({
query: "react stars:>1000 language:javascript"
});
GitHub Actions integration
Automated testing
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: npm test
Automated deployment
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Deploy
run: ./deploy.sh
Integration scenarios
1. Automated code review
- Listen for PR creation events
- Run code quality checks
- Automatically add review comments
- Mark areas that need improvement
2. Automatic Issue Classification
- Listen for Issue creation
- Analyze Issue content
- Automatically add labels
- Assign to appropriate personnel
3. Release Management
- Listen for version tags
- Generate changelog
- Create GitHub Release
- Notify team members
4. Dependency Updates
- Regularly check for dependency updates
- Create update PR
- Run tests for verification
- Automatically merge security updates
Notes
- Comply with GitHub API rate limits
- Authenticate using Personal Access Token
- Properly handle API errors and retries
- Protect sensitive information and keys
- Follow open source project contribution guidelines