MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / mcpSearchCommand

Method mcpSearchCommand

internal/cli/mcp.go:71–141  ·  view source on GitHub ↗

`cam mcp search QUERY` searches the bundled registry AND GitHub for MCP servers matching a keyword — combining local and online sources.

()

Source from the content-addressed store, hash-verified

69// `cam mcp search QUERY` searches the bundled registry AND GitHub for MCP
70// servers matching a keyword — combining local and online sources.
71func (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
81Searches the bundled MCP registry first, then optionally searches
82GitHub for MCP server repositories.
83
84Use --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 }

Callers 1

mcpCommandMethod · 0.95

Calls 4

LoadBundledRegistryFunction · 0.92
searchGitHubMCPFunction · 0.85
formatStarsFunction · 0.85
SearchMethod · 0.45

Tested by

no test coverage detected