operationToTool converts a single OpenAPI operation to a tool.
(baseURL, path, method string, op *v3.Operation)
| 238 | |
| 239 | // operationToTool converts a single OpenAPI operation to a tool. |
| 240 | func (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. |
| 269 | func operationToolName(path, method string, op *v3.Operation) string { |
no test coverage detected