Tai-DT/mcp-go-gemini
If you are the rightful owner of mcp-go-gemini and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Go Gemini Server is a robust Model Context Protocol server built using Go, integrating with Google Gemini API to deliver advanced AI features.
MCP Go Gemini Server
🚀 Một MCP (Model Context Protocol) server được xây dựng bằng Go, tích hợp với Google Gemini API để cung cấp các tính năng AI tiên tiến.
✨ Tính năng
- 🤖 Text Generation: Tạo văn bản thông minh với Gemini
- 🔍 Code Analysis: Phân tích, giải thích và review mã nguồn
- ✍️ Text Improvement: Cải thiện văn bản và nâng cao chất lượng
- 🌐 Translation: Dịch thuật đa ngôn ngữ chính xác
- ❓ Question Answering: Trả lời câu hỏi với độ chính xác cao
- ⚡ Code Generation: Tạo mã nguồn từ mô tả tự nhiên
- 📄 Document Summarization: Tóm tắt tài liệu thông minh
🚀 Cài đặt nhanh
Yêu cầu hệ thống
- Go 1.21 trở lên
- API key của Gemini (miễn phí tại Google AI Studio)
Cài đặt
# Clone repository
git clone <repository-url>
cd mcp-go-gemini
# Cài đặt dependencies
go mod tidy
# Thiết lập API key
export GEMINI_API_KEY="your-api-key-here"
# Build và chạy
go build -o mcp-go-gemini .
./mcp-go-gemini
Hoặc sử dụng script nhanh:
./start.sh
🛠 Sử dụng với MCP Clients
Claude Desktop
Thêm cấu hình vào claude_desktop_config.json
:
{
"mcpServers": {
"mcp-go-gemini": {
"command": "/path/to/mcp-go-gemini",
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
VS Code + Cline Extension
- Cài đặt Cline extension
- Cấu hình MCP server trong settings
- Sử dụng trực tiếp trong VS Code
📚 API Documentation
Các công cụ có sẵn
Công cụ | Mô tả | Tham số |
---|---|---|
generate_text | Tạo văn bản | prompt , temperature , max_tokens |
analyze_code | Phân tích mã nguồn | code , language , task |
improve_text | Cải thiện văn bản | text , task |
translate_text | Dịch thuật | text , source_language , target_language |
answer_question | Trả lời câu hỏi | question , context |
generate_code | Tạo mã nguồn | description , language , framework |
summarize_document | Tóm tắt tài liệu | content , length |
Ví dụ sử dụng
Tạo văn bản
{
"name": "generate_text",
"arguments": {
"prompt": "Viết một bài thơ về ngôn ngữ lập trình Go",
"temperature": 0.8
}
}
Phân tích mã nguồn
{
"name": "analyze_code",
"arguments": {
"code": "func main() { fmt.Println(\"Hello, World!\") }",
"language": "go",
"task": "explain"
}
}
Dịch thuật
{
"name": "translate_text",
"arguments": {
"text": "Hello, world!",
"source_language": "English",
"target_language": "Vietnamese"
}
}
Xem thêm tại
📁 Cấu trúc dự án
mcp-go-gemini/
├── main.go # Entry point
├── internal/
│ ├── gemini/ # Gemini API integration
│ │ └── client.go
│ ├── handlers/ # Tool handlers
│ │ └── handlers.go
│ └── config/ # Configuration
│ └── config.go
├── examples/ # Usage examples
├── docs/ # Documentation
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose
├── Makefile # Build automation
└── README.md
🧪 Testing
Chạy test để kiểm tra functionality:
# Unit tests
go test ./...
# Integration test với API thật
go run test_client.go
# Build test
make test
🐳 Docker Support
# Build image
docker build -t mcp-go-gemini .
# Run với docker-compose
docker-compose up -d
🔧 Development
Build commands
make build # Build binary
make run # Build và chạy
make clean # Clean artifacts
make test # Run tests
make lint # Code linting
Code structure
internal/gemini/
: Gemini API client và wrapperinternal/handlers/
: MCP tool handlersinternal/config/
: Configuration managementmain.go
: Server initialization và tool registration
🚦 Performance
- Response time: ~1-3 giây cho most operations
- Concurrency: Thread-safe, hỗ trợ multiple clients
- Memory: ~10-50MB runtime usage
- Rate limiting: Tuân thủ Gemini API limits
🔐 Security
- ✅ API key qua environment variables
- ✅ Input validation và sanitization
- ✅ Error handling secure
- ✅ No sensitive data logging
- ✅ HTTPS cho tất cả API calls
📋 Troubleshooting
Lỗi thường gặp
-
"GEMINI_API_KEY not set"
- Đảm bảo đã set environment variable
- Kiểm tra API key hợp lệ
-
"Failed to create client"
- Kiểm tra internet connection
- Verify API key tại Google AI Studio
-
Build errors
- Đảm bảo Go 1.21+
- Chạy
go mod tidy
Xem thêm tại
🤝 Contributing
- Fork the project
- Create feature branch (
git checkout -b feature/amazing-feature
) - Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open Pull Request
📄 License
Distributed under the MIT License. See LICENSE
for more information.
🙏 Acknowledgments
- Google Gemini API - Powerful AI capabilities
- MCP Go - Excellent MCP implementation
- Model Context Protocol - Open standard
📞 Support
- 📧 Email: [your-email]
- 🐛 Issues: [GitHub Issues]
- 💬 Discussions: [GitHub Discussions]
- 📖 Docs: [Full Documentation]
Made with ❤️ and Go • Powered by Gemini AI • MCP Compatible