MCPcopy Index your code
hub / github.com/docker/docker-agent / Tools

Method Tools

pkg/tools/builtin/shell/script_shell.go:171–207  ·  view source on GitHub ↗
(context.Context)

Source from the content-addressed store, hash-verified

169}
170
171func (t *ScriptToolSet) Tools(context.Context) ([]tools.Tool, error) {
172 var toolsList []tools.Tool
173
174 names := make([]string, 0, len(t.shellTools))
175 for name := range t.shellTools {
176 names = append(names, name)
177 }
178 slices.Sort(names)
179
180 for _, name := range names {
181 cfg := t.shellTools[name]
182
183 description := cmp.Or(cfg.Description, "Execute shell command: "+cfg.Cmd)
184
185 inputSchema, err := tools.SchemaToMap(map[string]any{
186 "type": "object",
187 "properties": defaultPropertyTypes(cfg.Args, "string"),
188 "required": cfg.Required,
189 })
190 if err != nil {
191 return nil, fmt.Errorf("invalid schema for tool %s: %w", name, err)
192 }
193
194 toolsList = append(toolsList, tools.Tool{
195 Name: name,
196 Category: "shell",
197 Description: description,
198 Parameters: inputSchema,
199 OutputSchema: tools.MustSchemaFor[string](),
200 Handler: func(ctx context.Context, toolCall tools.ToolCall) (*tools.ToolCallResult, error) {
201 return t.execute(ctx, &cfg, toolCall)
202 },
203 })
204 }
205
206 return toolsList, nil
207}
208
209func (t *ScriptToolSet) execute(ctx context.Context, toolConfig *latest.ScriptShellToolConfig, toolCall tools.ToolCall) (*tools.ToolCallResult, error) {
210 var params map[string]any

Callers

nothing calls this directly

Calls 3

executeMethod · 0.95
SchemaToMapFunction · 0.92
defaultPropertyTypesFunction · 0.85

Tested by

no test coverage detected