`cam mcp search QUERY` searches the bundled registry AND GitHub for MCP servers matching a keyword — combining local and online sources.
()
| 69 | // `cam mcp search QUERY` searches the bundled registry AND GitHub for MCP |
| 70 | // servers matching a keyword — combining local and online sources. |
| 71 | func (a *App) mcpSearchCommand() *cobra.Command { |
| 72 | var ( |
| 73 | limit int |
| 74 | local bool |
| 75 | ) |
| 76 | cmd := &cobra.Command{ |
| 77 | Use: "search QUERY", |
| 78 | Short: "Search for MCP servers across registry and GitHub", |
| 79 | Long: `Search for MCP servers matching a keyword. |
| 80 | |
| 81 | Searches the bundled MCP registry first, then optionally searches |
| 82 | GitHub for MCP server repositories. |
| 83 | |
| 84 | Use --local to skip the GitHub search and only search the bundled registry.`, |
| 85 | Args: cobra.ExactArgs(1), |
| 86 | RunE: func(cmd *cobra.Command, args []string) error { |
| 87 | out := cmd.OutOrStdout() |
| 88 | query := args[0] |
| 89 | |
| 90 | // 1. Bundled registry search. |
| 91 | registry, err := mcp.LoadBundledRegistry() |
| 92 | if err != nil { |
| 93 | return err |
| 94 | } |
| 95 | matches := registry.Search(query) |
| 96 | if len(matches) > 0 { |
| 97 | fmt.Fprintf(out, "Bundled registry (%d):\n\n", len(matches)) |
| 98 | for _, s := range matches { |
| 99 | fmt.Fprintf(out, " %-40s %s\n", s.Name, s.Description) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // 2. GitHub search (unless --local). |
| 104 | if !local { |
| 105 | ghResults, err := searchGitHubMCP(query, limit) |
| 106 | if err != nil { |
| 107 | fmt.Fprintf(out, "\nGitHub search: %v\n", err) |
| 108 | } else if len(ghResults) > 0 { |
| 109 | if len(matches) > 0 { |
| 110 | fmt.Fprintln(out) |
| 111 | } |
| 112 | fmt.Fprintf(out, "GitHub (%d):\n\n", len(ghResults)) |
| 113 | for _, r := range ghResults { |
| 114 | id := r.ID |
| 115 | if id == "" { |
| 116 | id = r.Name |
| 117 | } |
| 118 | stars := formatStars(r.Stars) |
| 119 | fmt.Fprintf(out, " %-40s %-35s %s\n", id, r.Repo, stars) |
| 120 | if r.Description != "" { |
| 121 | desc := r.Description |
| 122 | if len(desc) > 120 { |
| 123 | desc = desc[:117] + "..." |
| 124 | } |
| 125 | fmt.Fprintf(out, " %s\n", desc) |
| 126 | } |
| 127 | } |
| 128 | } |
no test coverage detected