Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ExportCmd = &cobra.Command{ Use: "export", Hidden: true, Short: "Export servers from the registry database", Long: "Exports all MCP server entries from the local registry database into a JSON seed file compatible with arctl import.", RunE: func(cmd *cobra.Command, args []string) error { outputPath := strings.TrimSpace(exportOutput) if outputPath == "" { return errors.New("--output is required (destination seed file path)") } cfg := config.NewConfig() ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() db, err := database.NewPostgreSQL(ctx, cfg.DatabaseURL) if err != nil { return fmt.Errorf("failed to connect to database: %w", err) } defer func() { if closeErr := db.Close(); closeErr != nil { log.Printf("Warning: failed to close database: %v", closeErr) } }() registryService := service.NewRegistryService(db, cfg) exporterService := exporter.NewService(registryService) exportCtx := cmd.Context() if exportCtx == nil { exportCtx = context.Background() } exporterService.SetReadmeOutputPath(exportReadmeOutput) count, err := exporterService.ExportToPath(exportCtx, outputPath) if err != nil { return fmt.Errorf("failed to export servers: %w", err) } fmt.Printf("✓ Exported %d servers to %s\n", count, outputPath) return nil }, }
View Source
var ImportCmd = &cobra.Command{ Use: "import", Hidden: true, Short: "Import servers into the registry database", Long: "Imports MCP server entries from a JSON seed file or a registry /v0/servers endpoint into the local registry database.", RunE: func(cmd *cobra.Command, args []string) error { if strings.TrimSpace(importSource) == "" { return errors.New("--source is required (file path, HTTP URL, or /v0/servers endpoint)") } cfg := config.NewConfig() if importSkipValidation { cfg.EnableRegistryValidation = false } ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() db, err := database.NewPostgreSQL(ctx, cfg.DatabaseURL) if err != nil { return fmt.Errorf("failed to connect to database: %w", err) } defer func() { if closeErr := db.Close(); closeErr != nil { log.Printf("Warning: failed to close database: %v", closeErr) } }() registryService := service.NewRegistryService(db, cfg) httpClient := &http.Client{Timeout: importTimeout} headerMap := make(map[string]string) for _, h := range importHeaders { parts := strings.SplitN(h, "=", 2) if len(parts) != 2 { return fmt.Errorf("invalid --request-header, expected key=value: %s", h) } key := strings.TrimSpace(parts[0]) value := strings.TrimSpace(parts[1]) if key == "" { return fmt.Errorf("invalid --request-header, empty key: %s", h) } headerMap[key] = value } importerService := importer.NewService(registryService) importerService.SetHTTPClient(httpClient) importerService.SetRequestHeaders(headerMap) importerService.SetUpdateIfExists(importUpdate) importerService.SetGitHubToken(importGithubToken) importerService.SetReadmeSeedPath(importReadmeSeed) importerService.SetProgressCachePath(importProgressCache) if err := importerService.ImportFromPath(context.Background(), importSource, enrichServerData); err != nil { return err } return nil }, }
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "Show version information", Long: `Displays the version of arctl.`, Run: func(cmd *cobra.Command, args []string) { fmt.Printf("arctl version %s\n", version.Version) fmt.Printf("Git commit: %s\n", version.GitCommit) fmt.Printf("Build date: %s\n", version.BuildDate) serverVersion, err := apiClient.GetVersion() if err != nil { fmt.Printf("Error getting server version: %v\n", err) return } fmt.Printf("Server version: %s\n", serverVersion.Version) fmt.Printf("Server git commit: %s\n", serverVersion.GitCommit) fmt.Printf("Server build date: %s\n", serverVersion.BuildTime) if !semver.IsValid(serverVersion.Version) || !semver.IsValid(version.Version) { fmt.Printf("Server or local version is not a valid semantic version, not sure if update require: %s or %s\n", serverVersion.Version, version.Version) return } compare := semver.Compare("v"+version.Version, "v"+serverVersion.Version) switch compare { case 1: fmt.Println("\n-------------------------------") fmt.Printf("CLI version is newer than server version: %s > %s\n", version.Version, serverVersion.Version) fmt.Println("We recommend updating your server version") case -1: fmt.Println("\n-------------------------------") fmt.Printf("Server version is newer than local version: %s > %s\n", serverVersion.Version, version.Version) fmt.Println("We recommend updating your CLI version") case 0: } }, }
Functions ¶
func SetAPIClient ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.