* Replaces the tool definition and re-evaluates its status against the * current server config. Callers must pause the task runner, so calls that * are already waiting run with the new state. Returns true if the tool * listing visible to the client changed.
(tool: AnyToolDefinition)
| 287 | * listing visible to the client changed. |
| 288 | */ |
| 289 | update(tool: AnyToolDefinition): boolean { |
| 290 | const previousTool = this.#tool; |
| 291 | const previousDisabled = this.#disabled; |
| 292 | const previousInputSchema = this.#registeredInputSchema; |
| 293 | const nextInputSchema = zod.object(tool.schema).strict(); |
| 294 | |
| 295 | this.#tool = tool; |
| 296 | this.#registeredInputSchema = nextInputSchema; |
| 297 | this.#updateStatus(tool); |
| 298 | |
| 299 | if (previousDisabled !== this.#disabled) { |
| 300 | return true; |
| 301 | } |
| 302 | if (this.#disabled) { |
| 303 | return false; |
| 304 | } |
| 305 | |
| 306 | return ( |
| 307 | previousTool.description !== tool.description || |
| 308 | !isDeepStrictEqual(previousTool.annotations, tool.annotations) || |
| 309 | !isDeepStrictEqual( |
| 310 | toInputJsonSchema(previousInputSchema), |
| 311 | toInputJsonSchema(nextInputSchema), |
| 312 | ) |
| 313 | ); |
| 314 | } |
| 315 | |
| 316 | /** |
| 317 | * Races a promise against TOOL_CALL_TIMEOUT_MS and signal abort, calling |
no test coverage detected