Handle tasks/cancel — terminate the background job. Same underlying mechanism as the renderer's cancelJob query param.
(task_id: str)
| 172 | |
| 173 | |
| 174 | def cancel_task(task_id: str) -> Any: |
| 175 | """Handle tasks/cancel — terminate the background job. |
| 176 | |
| 177 | Same underlying mechanism as the renderer's cancelJob query param. |
| 178 | """ |
| 179 | tool_name, job_id, _cache_key, created_at = parse_task_id(task_id) |
| 180 | |
| 181 | manager = _get_callback_manager(tool_name) |
| 182 | if manager is None: |
| 183 | raise MCPError("No background callback manager configured.") |
| 184 | |
| 185 | manager.terminate_job(job_id) |
| 186 | |
| 187 | return CancelTaskResult( |
| 188 | taskId=task_id, |
| 189 | status="cancelled", |
| 190 | createdAt=created_at, |
| 191 | lastUpdatedAt=datetime.now(timezone.utc), |
| 192 | ttl=manager.expire * 1000 if manager.expire else None, |
| 193 | ) |
no test coverage detected
searching dependent graphs…