Gemini-CLI-GitHub-MCP
Gemini-CLI-GitHubは、GitHubと連携するためのコマンドラインインターフェースを提供します。ユーザーは、リポジトリの管理や操作を簡単に行うことができ、効率的なワークフローを実現します。特に、開発者にとって便利なツールであり、GitHubの機能をCLIから直接利用できる点が魅力です。
GitHubスター
2
ユーザー評価
未評価
お気に入り
0
閲覧数
18
フォーク
0
イシュー
0
Gemini CLI + MCP Documentation Generator
This repository contains a versatile GitHub Actions workflow that automatically generates documentation using Google's Gemini CLI with Model Context Protocol (MCP) integration.
Features
- Cross-platform support: Windows and Linux workflows
- Configurable paths: Customize input and output directories
- Flexible triggers: Manual dispatch or automatic on push
- Error handling: Comprehensive validation and error reporting
- MCP Integration: GitHub MCP server for enhanced context
- Automated workflow: Seamless documentation updates
Quick Start
1. Copy the Workflow
Copy the appropriate workflow file to your repository:
- Windows:
.github/workflows/update_docs_windows.yml
- Linux:
.github/workflows/update_docs_linux.yml
2. Set Up Secrets
Add these secrets to your repository (Settings → Secrets and variables → Actions):
PERSONAL_ACCESS_TOKEN
: GitHub Personal Access Token with repo permissionsGITHUB_TOKEN
: Automatically provided by GitHub Actions
3. Configure Your Repository
The workflow is designed to work out of the box with these defaults:
- Input directory:
src/
- Output directory:
docs/
- Branch:
main
How It Works
MCP Server Configuration
The workflow automatically configures a GitHub MCP server that provides:
- Repository context and file information
- Issue and pull request data
- Enhanced documentation generation capabilities
Documentation Generation Process
- Setup: Installs Node.js and Gemini CLI
- MCP Configuration: Creates
.gemini/settings.json
with GitHub MCP server - Documentation: Generates docs from your source files
- Commit & Push: Automatically commits and pushes changes
Customization Options
Repository Variables (Optional)
You can set these variables in your repository settings (Settings → Secrets and variables → Actions → Variables):
INPUT_DIR
: Source directory for documentation generation (default:src/
)OUTPUT_DIR
: Output directory for generated docs (default:docs/
)COMMIT_MESSAGE
: Custom commit message (default: "Auto-update docs with Gemini CLI + MCP")ENABLE_AUTO_PUSH
: Enable/disable automatic pushing (default:true
)CLEAN_CACHE
: Clean npm cache before running (default:true
)
Manual Trigger Options
When manually triggering the workflow, you can override:
- Input Directory: Specify custom source directory
- Output Directory: Specify custom output directory
- Branch Name: Target branch for commits
- Commit Message: Custom commit message
- Auto Push: Enable/disable automatic pushing
- Clean Cache: Enable/disable npm cache cleaning
Usage Examples
Basic Usage
# Copy the workflow file to your repository
# Set up the required secrets
# The workflow will run automatically on pushes to main
Custom Directory Structure
If your project has a different structure:
# Set repository variables:
INPUT_DIR: "source/"
OUTPUT_DIR: "documentation/"
Different Branch
# Set repository variables:
DEFAULT_BRANCH: "develop"
Manual Trigger with Custom Settings
- Go to Actions → Workflows → "Auto Update Docs with Gemini CLI + MCP"
- Click "Run workflow"
- Fill in custom parameters:
- Input directory:
lib/
- Output directory:
api-docs/
- Commit message: "Update API documentation"
- Input directory:
Workflow Features
Error Handling
- Validates input directory exists
- Verifies MCP configuration creation
- Checks documentation generation success
- Provides detailed error messages
Performance Optimizations
- NPM caching for faster installations
- Conditional cache cleaning
- Efficient file operations
Security
- Uses GitHub tokens for authentication
- Secure MCP server configuration
- No hardcoded credentials
Advanced Features
MCP Server Integration
The workflow includes a GitHub MCP server that provides:
- Repository metadata access
- File content and structure information
- Issue and PR management capabilities
- Enhanced context for documentation generation
Custom Documentation Scripts
The repository includes a sample scripts/generate_docs.js
that demonstrates:
- File system operations
- Documentation template generation
- Integration with external tools
Troubleshooting
Common Issues
"Input directory does not exist"
- Ensure your source directory exists
- Check the
INPUT_DIR
variable or workflow input
"MCP configuration failed"
- Verify
PERSONAL_ACCESS_TOKEN
secret is set - Check token permissions
- Verify
"No changes to commit"
- This is normal if documentation hasn't changed
- Check if source files were modified
"Documentation generation failed"
- Verify Gemini CLI installation
- Check source files are valid
Debug Steps
- Check workflow logs in Actions tab
- Verify secrets are properly configured
- Test with manual trigger first
- Check file permissions and paths
Advanced Configuration
Multiple Documentation Sets
Create multiple workflow files for different documentation types:
# api-docs.yml
INPUT_DIR: "api/"
OUTPUT_DIR: "api-docs/"
# user-guide.yml
INPUT_DIR: "docs/"
OUTPUT_DIR: "user-guide/"
Conditional Execution
Modify the workflow to run only on specific conditions:
on:
push:
branches: [main, develop]
paths: ['src/**', 'docs/**']
Custom MCP Servers
Extend the MCP configuration for additional servers:
mcpServers:
github:
command: "npx"
args: ["-y", "@modelcontextprotocol/server-github"]
env:
GITHUB_PERSONAL_ACCESS_TOKEN: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"
custom:
command: "npx"
args: ["-y", "your-custom-mcp-server"]
Development
Local Testing
To test the workflow locally:
- Clone the repository
- Set up your GitHub token
- Run the workflow manually
- Check the generated documentation
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test with different repository structures
- Submit a pull request
Related Files
.github/workflows/update_docs_windows.yml
: Windows workflow.github/workflows/update_docs_linux.yml
: Linux workflowscripts/generate_docs.js
: Sample documentation scriptGemini.md
: Project configuration and conventions
License
This project is licensed under the MIT License - see the LICENSE file for details.