Skip to main content
Glama
samerfarida

MCP SSH Orchestrator

ssh_cancel_async_task

Stop a running asynchronous SSH task to manage server operations and control resource usage within the MCP SSH Orchestrator environment.

Instructions

Cancel a running async task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'ssh_cancel_async_task' MCP tool. It validates the task_id input, invokes ASYNC_TASKS.cancel_task(), logs the event, and returns a JSON response indicating success or failure.
    @mcp.tool()
    def ssh_cancel_async_task(task_id: str = "", ctx: Context | None = None) -> ToolResult:
        """Cancel a running async 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()
            success = ASYNC_TASKS.cancel_task(task_id)
            response = {
                "task_id": task_id,
                "cancelled": bool(success),
                "message": (
                    "Cancellation signaled"
                    if success
                    else "Task not found or not cancellable"
                ),
            }
            _ctx_log(
                ctx,
                "info",
                "ssh_cancel_async_task",
                {"task_id": task_id, "cancelled": bool(success)},
            )
            return response
    
        except Exception as e:
            error_str = str(e)
            log_json(
                {"level": "error", "msg": "cancel_async_exception", "error": error_str}
            )
            _ctx_log(
                ctx,
                "debug",
                "ssh_cancel_async_task_error",
                {"task_id": task_id.strip(), "error": sanitize_error(error_str)},
            )
            return f"Cancel error: {sanitize_error(error_str)}"
  • Core cancellation logic in AsyncTaskManager.cancel_task(). Sets the task's cancel event, updates status to 'cancelled', sends a notification, and returns True if the task was cancellable.
    def cancel_task(self, task_id: str) -> bool:
        """Cancel a running task."""
        with self._lock:
            task_info = self._tasks.get(task_id)
            if task_info and task_info["status"] in ["pending", "running"]:
                task_info["cancel"].set()
                task_info["status"] = "cancelled"
    
                # Send cancellation notification
                self._send_notification(
                    "cancelled",
                    task_id,
                    {
                        "reason": "user_requested",
                        "max_seconds": int(
                            task_info.get("limits", {}).get("max_seconds", 60)
                        ),
                    },
                )
                return True
            return False
  • The @mcp.tool() decorator registers the function as an MCP tool named 'ssh_cancel_async_task'.
    @mcp.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Cancel' implies a mutation, it doesn't specify whether this requires specific permissions, if cancellation is reversible, what happens to task outputs, or potential side effects. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and target, making it easy to parse quickly. Every word earns its place by conveying essential purpose without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with one parameter) and the presence of an output schema (which should cover return values), the description is minimally adequate but incomplete. It states what the tool does but lacks usage context, parameter details, and behavioral traits, leaving gaps for an agent to infer correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, with one parameter ('task_id') undocumented in the schema. The description doesn't add any parameter semantics—it doesn't explain what 'task_id' is, where to get it, its format, or validation rules. The description fails to compensate for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Cancel') and target ('a running async task'), providing a specific verb+resource combination. It doesn't explicitly differentiate from sibling tools like 'ssh_cancel' (which might cancel something else), but the purpose is unambiguous within the SSH task management context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing a valid task_id from an async operation), exclusions, or relationships to siblings like 'ssh_get_task_status' (to check if cancellation is needed) or 'ssh_cancel' (for non-async tasks).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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