Skip to main content
Glama

ssh_cancel

Cancel a running SSH task by specifying its task ID to stop execution and free resources in the SSH Orchestrator server fleet.

Instructions

Request cancellation for a running task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idNo

Implementation Reference

  • The handler function for the 'ssh_cancel' MCP tool. Validates the task_id input, signals cancellation via TASKS.cancel(), and returns a status dictionary.
    def ssh_cancel(task_id: str = "", ctx: Context | None = None) -> ToolResult: """Request cancellation for a running task.""" try: # Input validation valid, error_msg = _validate_task_id(task_id) if not valid: return f"Error: {error_msg}" task_id = task_id.strip() ok = TASKS.cancel(task_id) response = { "task_id": task_id, "cancelled": bool(ok), "message": "Cancellation signaled" if ok else "Task not found", } _ctx_log( ctx, "info", "ssh_cancel", {"task_id": task_id, "cancelled": bool(ok)}, ) return response except Exception as e: error_str = str(e) log_json({"level": "error", "msg": "cancel_exception", "error": error_str}) _ctx_log( ctx, "debug", "ssh_cancel_error", {"task_id": task_id.strip(), "error": sanitize_error(error_str)}, ) return f"Cancel error: {sanitize_error(error_str)}"
  • The @mcp.tool() decorator registers the ssh_cancel function as an MCP tool.
    def ssh_cancel(task_id: str = "", ctx: Context | None = None) -> ToolResult:
  • The TaskManager.cancel() method, called by ssh_cancel handler to signal task cancellation by setting the threading.Event().
    def cancel(self, task_id: str) -> bool: """Signal cancellation for task id.""" with self._lock: if task_id in self._tasks: self._tasks[task_id]["cancel"].set() return True return False
  • Instantiation of the TaskManager as TASKS, used by the ssh_cancel handler.
    TASKS = TaskManager()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/samerfarida/mcp-ssh-orchestrator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server