MCPcopy Create free account
hub / github.com/compozy/agh / newToolSearchCommand

Function newToolSearchCommand

internal/cli/tool_operator.go:106–146  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

104}
105
106func newToolSearchCommand(deps commandDeps) *cobra.Command {
107 var scope toolScopeFlags
108 var limit int
109 cmd := &cobra.Command{
110 Use: toolOperatorSearchQueryValue,
111 Short: "Search operator-visible registry tools",
112 Example: ` # Search tools by descriptor text
113 agh tool search skill -o json
114
115 # Limit search results for automation
116 agh tool search task --limit 5 -o json`,
117 Args: exactOneNonBlankArg(),
118 RunE: func(cmd *cobra.Command, args []string) error {
119 query := strings.TrimSpace(args[0])
120 if query == "" {
121 return writeToolCommandError(cmd, toolValidationCommandError(
122 toolspkg.ToolID(""),
123 "tool search query is required",
124 toolspkg.NewValidationError("query", toolspkg.ReasonSchemaInvalid, "query is required"),
125 ))
126 }
127 return runToolCommand(cmd, deps, func(client DaemonClient) error {
128 request := ToolSearchRequest{
129 Query: query,
130 Limit: limit,
131 WorkspaceID: strings.TrimSpace(scope.workspaceID),
132 SessionID: strings.TrimSpace(scope.sessionID),
133 AgentName: strings.TrimSpace(scope.agentName),
134 }
135 response, err := client.SearchTools(cmd.Context(), request)
136 if err != nil {
137 return err
138 }
139 return writeCommandOutput(cmd, toolListBundle(response))
140 })
141 },
142 }
143 scope.bind(cmd)
144 cmd.Flags().IntVar(&limit, "limit", 0, "Maximum number of tools to return")
145 return cmd
146}
147
148func newToolInfoCommand(deps commandDeps) *cobra.Command {
149 var scope toolScopeFlags

Callers 1

newToolCommandFunction · 0.85

Calls 8

bindMethod · 0.95
exactOneNonBlankArgFunction · 0.85
writeToolCommandErrorFunction · 0.85
runToolCommandFunction · 0.85
writeCommandOutputFunction · 0.85
toolListBundleFunction · 0.85
SearchToolsMethod · 0.65

Tested by

no test coverage detected