package main import ( "context" "flag" "fmt" "log" "os" "github.com/xlgmokha/mcp/pkg/gitlab" ) func main() { var ( gitlabURL = flag.String("gitlab-url", "https://gitlab.com", "GitLab instance URL") help = flag.Bool("help", false, "Show help information") ) flag.Parse() if *help { fmt.Printf(`GitLab MCP Server This server provides access to GitLab APIs for issue management, project tracking, and workflow automation designed for GitLab software engineers. Usage: %s [options] Options: `, os.Args[0]) flag.PrintDefaults() fmt.Print(` Examples: # Use GITLAB_TOKEN environment variable (recommended) export-access-token && mcp-gitlab # Specify token directly mcp-gitlab --gitlab-token your_token_here # Use with self-hosted GitLab instance mcp-gitlab --gitlab-url https://gitlab.company.com Tools: - gitlab_list_my_projects: List projects you have access to with activity info - gitlab_list_my_issues: Issues assigned/authored/mentioned, prioritized by activity - gitlab_get_issue_conversations: Full conversation threads with participants - gitlab_find_similar_issues: Cross-project similarity search using AI - gitlab_get_my_activity: Recent activity summary and triage assistance Environment Variables: - GITLAB_TOKEN: Personal Access Token (use with export-access-token script) - GITLAB_URL: GitLab instance URL (default: https://gitlab.com) Caching Features: - Automatic local caching in ~/.mcp/gitlab/ for faster responses - 5-minute TTL (configurable) with intelligent cache invalidation - Offline mode: returns cached data when network is unavailable - Reduces API calls and improves performance for repeated queries - Sharded file storage with statistics tracking For GitLab software engineers: This server integrates with your existing export-access-token workflow and provides AI-assisted organization of your GitLab work across multiple projects. Local caching ensures fast responses and offline capability for improved productivity. For more information, visit: https://github.com/xlgmokha/mcp `) return } token := os.Getenv("GITLAB_TOKEN") if token == "" { log.Fatal("GitLab token required. Set GITLAB_TOKEN environment variable.\n") } url := *gitlabURL if envURL := os.Getenv("GITLAB_URL"); envURL != "" { url = envURL } server, err := gitlab.New(url, token) if err != nil { log.Fatalf("Failed to create GitLab server: %v", err) } ctx := context.Background() if err := server.Run(ctx); err != nil { log.Fatalf("Server error: %v", err) } }