Commit dee7660
cmd/gitlab/main.go
@@ -12,9 +12,8 @@ import (
func main() {
var (
- gitlabURL = flag.String("gitlab-url", "https://gitlab.com", "GitLab instance URL")
- gitlabToken = flag.String("gitlab-token", "", "GitLab Personal Access Token (overrides GITLAB_TOKEN env var)")
- help = flag.Bool("help", false, "Show help information")
+ gitlabURL = flag.String("gitlab-url", "https://gitlab.com", "GitLab instance URL")
+ help = flag.Bool("help", false, "Show help information")
)
flag.Parse()
@@ -47,11 +46,6 @@ Tools:
- gitlab_find_similar_issues: Cross-project similarity search using AI
- gitlab_get_my_activity: Recent activity summary and triage assistance
-Cache Management Tools:
- - gitlab_cache_stats: View cache performance and storage statistics
- - gitlab_cache_clear: Clear specific cache types or all cached data (requires confirmation)
- - gitlab_offline_query: Query cached data when network is unavailable
-
Environment Variables:
- GITLAB_TOKEN: Personal Access Token (use with export-access-token script)
- GITLAB_URL: GitLab instance URL (default: https://gitlab.com)
@@ -73,17 +67,11 @@ For more information, visit: https://github.com/xlgmokha/mcp
return
}
- // Get GitLab token from flag or environment variable
- token := *gitlabToken
+ token := os.Getenv("GITLAB_TOKEN")
if token == "" {
- token = os.Getenv("GITLAB_TOKEN")
- if token == "" {
- log.Fatal("GitLab token required. Set GITLAB_TOKEN environment variable or use --gitlab-token flag.\n" +
- "For GitLab employees: run 'export-access-token' first, then start the server.")
- }
+ log.Fatal("GitLab token required. Set GITLAB_TOKEN environment variable.\n")
}
- // Get GitLab URL from flag or environment variable
url := *gitlabURL
if envURL := os.Getenv("GITLAB_URL"); envURL != "" {
url = envURL
pkg/time/server.go
@@ -120,8 +120,6 @@ func New() *mcp.Server {
return builder.Build()
}
-// Helper methods for TimeOperations
-
func (timeOps *TimeOperations) getCurrentTime(timezone string) (*TimeResult, error) {
loc, err := time.LoadLocation(timezone)
if err != nil {
@@ -148,7 +146,6 @@ func (timeOps *TimeOperations) convertTime(sourceTimezone, timeStr, targetTimezo
return nil, fmt.Errorf("Invalid target timezone: %v", err)
}
- // Parse time in HH:MM format
parts := strings.Split(timeStr, ":")
if len(parts) != 2 {
return nil, fmt.Errorf("Invalid time format. Expected HH:MM [24-hour format]")
@@ -164,14 +161,10 @@ func (timeOps *TimeOperations) convertTime(sourceTimezone, timeStr, targetTimezo
return nil, fmt.Errorf("Invalid time format. Expected HH:MM [24-hour format]")
}
- // Use current date in source timezone
now := time.Now().In(sourceLoc)
sourceTime := time.Date(now.Year(), now.Month(), now.Day(), hour, minute, 0, 0, sourceLoc)
- // Convert to target timezone
targetTime := sourceTime.In(targetLoc)
-
- // Calculate time difference
sourceOffset := getTimezoneOffset(sourceTime)
targetOffset := getTimezoneOffset(targetTime)
hoursDifference := float64(targetOffset-sourceOffset) / 3600
@@ -194,38 +187,30 @@ func (timeOps *TimeOperations) convertTime(sourceTimezone, timeStr, targetTimezo
}
func getLocalTimezone() string {
- // Get local timezone from the system
now := time.Now()
zone, _ := now.Zone()
if zone == "" {
return "UTC"
}
- // Try to get the IANA timezone name
loc := now.Location()
if loc != nil && loc.String() != "" && loc.String() != "Local" {
return loc.String()
}
- // Fallback to UTC if we can't determine the timezone
return "UTC"
}
func isDST(t time.Time) bool {
- // Check if time is in daylight saving time
_, offset := t.Zone()
- // Create time in January (standard time) and July (potentially DST)
jan := time.Date(t.Year(), 1, 1, 12, 0, 0, 0, t.Location())
jul := time.Date(t.Year(), 7, 1, 12, 0, 0, 0, t.Location())
_, janOffset := jan.Zone()
_, julOffset := jul.Zone()
- // If offsets are different, the timezone observes DST
if janOffset != julOffset {
- // We're in DST if current offset matches the "more positive" offset
- // (which is typically summer time)
if janOffset < julOffset {
return offset == julOffset
} else {
@@ -233,7 +218,6 @@ func isDST(t time.Time) bool {
}
}
- // No DST observed in this timezone
return false
}
@@ -244,12 +228,9 @@ func getTimezoneOffset(t time.Time) int {
func formatTimeDifference(hours float64) string {
if hours == float64(int(hours)) {
- // Whole hours
return fmt.Sprintf("%+.1fh", hours)
} else {
- // Fractional hours (like Nepal's UTC+5:45)
formatted := fmt.Sprintf("%+.2f", hours)
- // Remove trailing zeros
formatted = strings.TrimRight(formatted, "0")
formatted = strings.TrimRight(formatted, ".")
return formatted + "h"