Skip to main content
Glama
samerfarida

MCP SSH Orchestrator

ssh_get_task_result

Retrieve final execution results, output, and metadata for completed SSH tasks to verify command outcomes and audit infrastructure operations.

Instructions

Get final result of completed task (SEP-1686 compliant).

Returns complete output, exit code, and execution metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary handler for the 'ssh_get_task_result' MCP tool. Performs input validation on task_id, retrieves the final task result from the ASYNC_TASKS manager, logs activity, and returns the result or an appropriate error message.
    @mcp.tool()
    def ssh_get_task_result(task_id: str = "", ctx: Context | None = None) -> ToolResult:
        """Get final result of completed task (SEP-1686 compliant).
    
        Returns complete output, exit code, and execution metadata.
        """
        try:
            # Input validation
            valid, error_msg = _validate_task_id(task_id)
            if not valid:
                return f"Error: {error_msg}"
    
            task_id = task_id.strip()
            result = ASYNC_TASKS.get_task_result(task_id)
            if not result:
                return f"Error: Task not found or expired: {task_id}"
    
            _ctx_log(ctx, "debug", "ssh_get_task_result", {"task_id": task_id})
            return result
    
        except Exception as e:
            error_str = str(e)
            log_json({"level": "error", "msg": "result_exception", "error": error_str})
            _ctx_log(
                ctx,
                "debug",
                "ssh_get_task_result_error",
                {"task_id": task_id.strip(), "error": sanitize_error(error_str)},
            )
            return f"Result error: {sanitize_error(error_str)}"
  • Core helper method in AsyncTaskManager.get_task_result() that fetches and formats the stored task result from _results dict if not expired by TTL, providing the complete execution metadata and output.
    def get_task_result(self, task_id: str) -> dict[str, Any] | None:
        """Get final result if completed."""
        with self._lock:
            result = self._results.get(task_id)
            if result and result["expires"] > time.time():
                return {
                    "task_id": task_id,
                    "status": result["status"],
                    "exit_code": result["exit_code"],
                    "duration_ms": result["duration_ms"],
                    "output": result["output"],
                    "cancelled": result["cancelled"],
                    "timeout": result["timeout"],
                    "target_ip": result["target_ip"],
                    "max_seconds": result.get("max_seconds"),
                }
            return None
  • The @mcp.tool() decorator registers the ssh_get_task_result function as an MCP tool with the FastMCP server instance.
    @mcp.tool()
  • Global ASYNC_TASKS instance of AsyncTaskManager used by the tool handler to manage and retrieve async task results.
    ASYNC_TASKS = AsyncTaskManager()
Behavior2/5

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

With no annotations provided, the description carries full burden. It discloses that the tool returns 'complete output, exit code, and execution metadata' which is valuable behavioral information. However, it doesn't mention important traits like whether this is a read-only operation, potential error conditions, authentication requirements, or rate limits. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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 extremely concise with just two sentences. The first sentence states the core purpose with compliance context, the second describes the return values. Every word earns its place with zero waste or redundancy. The information is front-loaded appropriately.

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

Completeness4/5

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

Given the tool has an output schema (which will document return values), the description doesn't need to explain return format details. It appropriately focuses on what the tool does and its scope. The mention of 'completed task' provides important context about when to use it. For a single-parameter tool with output schema, this is reasonably complete, though could benefit from more behavioral context.

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

Parameters3/5

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

With 0% schema description coverage (task_id parameter has no description in schema), the description doesn't add any parameter-specific information. It doesn't explain what task_id represents, its format, or how to obtain it. Since there's only one parameter, the baseline is 4, but the description fails to compensate for the complete lack of schema documentation, dropping it to 3.

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 tool's purpose: 'Get final result of completed task' with specific resource (task result) and verb (get). It distinguishes from siblings like ssh_get_task_output (which likely gets partial output) and ssh_get_task_status (which likely gets status only), though not explicitly named. The SEP-1686 compliance mention adds specificity but doesn't fully differentiate from all alternatives.

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

Usage Guidelines3/5

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

The description implies usage context through 'completed task' - suggesting this should be used only after a task finishes. However, it doesn't explicitly state when NOT to use it (e.g., for running/incomplete tasks) or name specific alternatives like ssh_get_task_output for partial results. The guidance is present but incomplete.

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