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

Method Tools

pkg/tools/builtin/api/api.go:146–192  ·  view source on GitHub ↗
(context.Context)

Source from the content-addressed store, hash-verified

144}
145
146func (t *ToolSet) Tools(context.Context) ([]tools.Tool, error) {
147 inputSchema, err := tools.SchemaToMap(map[string]any{
148 "type": "object",
149 "properties": t.config.Args,
150 "required": t.config.Required,
151 })
152 if err != nil {
153 return nil, fmt.Errorf("invalid schema: %w", err)
154 }
155
156 parsedURL, err := url.Parse(t.config.Endpoint)
157 if err != nil {
158 return nil, fmt.Errorf("invalid URL: %w", err)
159 }
160
161 if parsedURL.Scheme == "" || parsedURL.Host == "" {
162 return nil, errors.New("invalid URL: missing scheme or host")
163 }
164
165 if parsedURL.Scheme != "http" && parsedURL.Scheme != "https" {
166 return nil, errors.New("only HTTP and HTTPS URLs are supported")
167 }
168
169 outputSchema := tools.MustSchemaFor[string]()
170 if t.config.OutputSchema != nil {
171 var err error
172 outputSchema, err = tools.SchemaToMap(t.config.OutputSchema)
173 if err != nil {
174 return nil, fmt.Errorf("invalid output_schema: %w", err)
175 }
176 }
177
178 return []tools.Tool{
179 {
180 Name: t.config.Name,
181 Category: "api",
182 Description: t.config.Instruction,
183 Parameters: inputSchema,
184 OutputSchema: outputSchema,
185 Handler: t.callTool,
186 Annotations: tools.ToolAnnotations{
187 ReadOnlyHint: true,
188 Title: cmp.Or(t.config.Name, "Query API"),
189 },
190 },
191 }, nil
192}
193
194func setHeaders(req *http.Request, headers map[string]string) {
195 useragent.SetIdentity(req)

Callers

nothing calls this directly

Implementers 15

StartableToolSetpkg/tools/startable.go
fakeToolSetpkg/tools/named_test.go
stubDescriberpkg/tools/startable_test.go
stubToolSetpkg/tools/startable_test.go
flappyToolSetpkg/tools/startable_test.go
listFlappyToolSetpkg/tools/startable_test.go
reportingToolSetpkg/tools/startable_test.go
reportingStartOnlyToolSetpkg/tools/startable_test.go
recoveryFailingToolSetpkg/tools/startable_test.go
codeModeToolpkg/tools/codemode/codemode.go
testToolSetpkg/tools/codemode/codemode_test.go
Toolsetpkg/tools/a2a/a2a.go

Calls 3

SchemaToMapFunction · 0.92
ParseMethod · 0.80
NewMethod · 0.45

Tested by

no test coverage detected