* 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)
| 312 | * listing visible to the client changed. |
| 313 | */ |
| 314 | update(tool: AnyToolDefinition): boolean { |
| 315 | const previousTool = this.#tool; |
| 316 | const previousDisabled = this.#disabled; |
| 317 | const previousInputSchema = this.#registeredInputSchema; |
| 318 | const nextInputSchema = zod.object(tool.schema).strict(); |
| 319 | |
| 320 | this.#tool = tool; |
| 321 | this.#registeredInputSchema = nextInputSchema; |
| 322 | this.#updateStatus(tool); |
| 323 | |
| 324 | if (previousDisabled !== this.#disabled) { |
| 325 | return true; |
| 326 | } |
| 327 | if (this.#disabled) { |
| 328 | return false; |
| 329 | } |
| 330 | |
| 331 | return ( |
| 332 | previousTool.description !== tool.description || |
| 333 | !isDeepStrictEqual(previousTool.annotations, tool.annotations) || |
| 334 | !isDeepStrictEqual( |
| 335 | toInputJsonSchema(previousInputSchema), |
| 336 | toInputJsonSchema(nextInputSchema), |
| 337 | ) |
| 338 | ); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * Races a promise against TOOL_CALL_TIMEOUT_MS and signal abort, calling |
no test coverage detected