MCPcopy Create free account
hub / github.com/docker/docker-agent / operationToTool

Method operationToTool

pkg/tools/builtin/openapi/openapi.go:240–266  ·  view source on GitHub ↗

operationToTool converts a single OpenAPI operation to a tool.

(baseURL, path, method string, op *v3.Operation)

Source from the content-addressed store, hash-verified

238
239// operationToTool converts a single OpenAPI operation to a tool.
240func (t *ToolSet) operationToTool(baseURL, path, method string, op *v3.Operation) tools.Tool {
241 name := operationToolName(path, method, op)
242 desc := operationDescription(path, method, op)
243 schema := operationSchema(op)
244
245 readOnly := method == http.MethodGet || method == http.MethodHead || method == http.MethodOptions
246
247 return tools.Tool{
248 Name: name,
249 Category: "openapi",
250 Description: desc,
251 Parameters: schema,
252 Handler: tools.NewHandler((&openAPIHandler{
253 baseURL: baseURL,
254 path: path,
255 method: method,
256 headers: t.headers,
257 timeout: t.timeout,
258 allowPrivateIPs: t.allowPrivateIPs,
259 expander: t.expander,
260 }).callTool),
261 Annotations: tools.ToolAnnotations{
262 ReadOnlyHint: readOnly,
263 Title: desc,
264 },
265 }
266}
267
268// operationToolName returns a tool name derived from the operationId or the method+path.
269func operationToolName(path, method string, op *v3.Operation) string {

Callers 1

buildToolsMethod · 0.95

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 4

NewHandlerFunction · 0.92
operationToolNameFunction · 0.85
operationDescriptionFunction · 0.85
operationSchemaFunction · 0.85

Tested by

no test coverage detected