Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_get_attempt_tasks

Debug workflow failures by retrieving task breakdowns to identify failed or slow steps, their status, timing, and dependencies.

Instructions

Get task breakdown to find which step failed or is slow in workflow.

Shows all individual tasks (steps) within a workflow execution with their
status, timing, and dependencies. Essential for debugging failed workflows.

Common scenarios:
- Find exactly which task/query failed in a complex workflow
- Identify slow-running tasks causing delays
- Understand task execution order and dependencies
- Debug data processing issues at task level

Returns task list with names, states, timing, and failure details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attempt_idYes

Implementation Reference

  • The handler function for td_get_attempt_tasks tool. It retrieves tasks for the given attempt_id using the TD client, processes each task to extract relevant details (hierarchy, timing, dependencies, type, errors), computes statistics, and returns a structured response.
    async def td_get_attempt_tasks(attempt_id: str) -> dict[str, Any]:
        """Get task breakdown to find which step failed or is slow in workflow.
    
        Shows all individual tasks (steps) within a workflow execution with their
        status, timing, and dependencies. Essential for debugging failed workflows.
    
        Common scenarios:
        - Find exactly which task/query failed in a complex workflow
        - Identify slow-running tasks causing delays
        - Understand task execution order and dependencies
        - Debug data processing issues at task level
    
        Returns task list with names, states, timing, and failure details.
        """
        if not attempt_id or not attempt_id.strip():
            return _format_error_response("Attempt ID cannot be empty")
    
        client = _create_client(include_workflow=True)
        if isinstance(client, dict):
            return client
    
        try:
            tasks = client.get_attempt_tasks(attempt_id)
    
            # Process tasks to create hierarchy and statistics
            task_list = []
            task_stats = {
                "total": len(tasks),
                "success": 0,
                "failed": 0,
                "running": 0,
                "blocked": 0,
                "other": 0,
            }
    
            for task in tasks:
                task_info = {
                    "id": task.id,
                    "name": task.full_name,
                    "state": task.state,
                    "is_group": task.is_group,
                }
    
                # Add parent info for hierarchy
                if task.parent_id:
                    task_info["parent_id"] = task.parent_id
    
                # Add timing info
                if task.started_at:
                    task_info["started_at"] = task.started_at
                if task.updated_at:
                    task_info["updated_at"] = task.updated_at
    
                # Add dependencies
                if task.upstreams:
                    task_info["depends_on"] = task.upstreams
    
                # Add non-sensitive config
                if task.config:
                    # Extract key task type info
                    if "td>" in task.config:
                        task_info["type"] = "td_query"
                        if "database" in task.config["td>"]:
                            task_info["database"] = task.config["td>"]["database"]
                    elif "py>" in task.config:
                        task_info["type"] = "python"
                    elif "sh>" in task.config:
                        task_info["type"] = "shell"
                    else:
                        task_info["type"] = "other"
    
                # Add error info if failed
                if task.error and task.state in ["failed", "error"]:
                    task_info["error"] = task.error
    
                # Update statistics
                if task.state == "success":
                    task_stats["success"] += 1
                elif task.state in ["failed", "error"]:
                    task_stats["failed"] += 1
                elif task.state == "running":
                    task_stats["running"] += 1
                elif task.state == "blocked":
                    task_stats["blocked"] += 1
                else:
                    task_stats["other"] += 1
    
                task_list.append(task_info)
    
            return {
                "attempt_id": attempt_id,
                "tasks": task_list,
                "statistics": task_stats,
            }
    
        except Exception as e:
            return _format_error_response(f"Failed to get attempt tasks: {str(e)}")
  • The registration function that sets up the MCP instance and globals, then registers all execution tools including td_get_attempt_tasks using mcp.tool() decorators.
    def register_execution_tools(mcp_instance, create_client_func, format_error_func):
        """Register execution tools with the provided MCP instance."""
        global mcp, _create_client, _format_error_response
        mcp = mcp_instance
        _create_client = create_client_func
        _format_error_response = format_error_func
    
        # Register all tools
        mcp.tool()(td_get_session)
        mcp.tool()(td_list_sessions)
        mcp.tool()(td_get_attempt)
        mcp.tool()(td_get_attempt_tasks)
        mcp.tool()(td_analyze_execution)
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by specifying the tool's purpose (debugging), output format ('task list with names, states, timing, and failure details'), and behavioral context (identifying failed/slow steps). It doesn't mention rate limits, authentication needs, or pagination, but provides substantial operational context.

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 well-structured and front-loaded with the core purpose, followed by bulleted scenarios and output details. Every sentence adds value without redundancy, making it efficient and easy to parse.

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?

For a tool with no annotations, no output schema, and low schema coverage, the description does well by explaining purpose, usage scenarios, and output format. It could improve by explicitly describing the 'attempt_id' parameter and potential error cases, but is largely complete for a debugging-focused tool.

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

Parameters4/5

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

With 0% schema description coverage and 1 parameter, the description compensates by implying the parameter's purpose through context ('workflow execution'), though it doesn't explicitly explain 'attempt_id'. The description adds value by clarifying what the tool analyzes, but could better define the parameter's role.

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

Purpose5/5

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

The description clearly states the specific verb ('Get task breakdown') and resource ('workflow execution'), distinguishing it from siblings like td_get_attempt or td_diagnose_workflow by focusing on individual task-level details rather than overall execution status or workflow-level diagnostics.

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

Usage Guidelines5/5

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

The description provides explicit usage scenarios with 'Common scenarios' listing four specific cases (debugging failures, identifying slow tasks, understanding dependencies, debugging data issues), clearly indicating when to use this tool versus alternatives like td_get_attempt for high-level status or td_diagnose_workflow for broader diagnostics.

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/knishioka/td-mcp-server'

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