Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_get_workflow

Retrieve workflow details by ID for debugging, project context, and execution status checks in Treasure Data.

Instructions

Get workflow details using numeric ID - essential for console URLs.

Direct workflow lookup when you have the ID. Handles large workflow IDs
that exceed pagination limits. Returns project info and execution history.

Common scenarios:
- Extracting ID from console URL (../workflows/12345678/info)
- Looking up workflow from error logs containing ID
- Getting project context for a known workflow ID
- Checking execution status by workflow ID

Returns workflow name, project details, schedule, and recent runs.
Includes console URL for quick browser access.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflow_idYes

Implementation Reference

  • Core handler function implementing td_get_workflow tool logic. Retrieves workflow details by numeric ID using direct API or fallback search through all workflows. Includes validation, error handling, project info, schedule details, recent sessions, and console URL.
    async def td_get_workflow(workflow_id: str) -> dict[str, Any]:
        """Get workflow details using numeric ID - essential for console URLs.
    
        Direct workflow lookup when you have the ID. Handles large workflow IDs
        that exceed pagination limits. Returns project info and execution history.
    
        Common scenarios:
        - Extracting ID from console URL (../workflows/12345678/info)
        - Looking up workflow from error logs containing ID
        - Getting project context for a known workflow ID
        - Checking execution status by workflow ID
    
        Returns workflow name, project details, schedule, and recent runs.
        Includes console URL for quick browser access.
        """
        if not workflow_id or not workflow_id.strip():
            return _format_error_response("Workflow ID cannot be empty")
    
        # Validate workflow ID format
        if not re.match(r"^\d+$", workflow_id):
            return _format_error_response("Invalid workflow ID format. Must be numeric.")
    
        client = _create_client(include_workflow=True)
        if isinstance(client, dict):
            return client
    
        try:
            # First try the direct API endpoint
            workflow = client.get_workflow_by_id(workflow_id)
    
            if workflow:
                # Found the workflow via direct API
                result: dict[str, Any] = {
                    "type": "workflow",
                    "workflow": {
                        "id": workflow.id,
                        "name": workflow.name,
                        "project": {
                            "id": workflow.project.id,
                            "name": workflow.project.name,
                        },
                        "timezone": workflow.timezone,
                        "scheduled": workflow.schedule is not None,
                    },
                }
    
                # Add schedule info if available
                if workflow.schedule:
                    result["workflow"]["schedule"] = workflow.schedule
    
                # Add latest session info if available
                # Note: Direct API might not include session info
                if workflow.latest_sessions:
                    latest_sessions = []
                    for session in workflow.latest_sessions[:5]:  # Last 5 sessions
                        latest_sessions.append(
                            {
                                "session_time": session.session_time,
                                "status": session.last_attempt.status,
                                "success": session.last_attempt.success,
                            }
                        )
                    result["workflow"]["latest_sessions"] = latest_sessions
    
                # Construct console URL
                result[
                    "console_url"
                ] = f"https://console.treasuredata.com/app/workflows/{workflow_id}/info"
    
                return result
    
            # If not found via direct API, fall back to searching through all workflows
            # This might be needed for workflows accessible via console API only
            workflows = client.get_workflows(count=1000, all_results=True)
    
            for workflow in workflows:
                if workflow.id == workflow_id:
                    # Found the workflow
                    result = {
                        "type": "workflow",
                        "workflow": {
                            "id": workflow.id,
                            "name": workflow.name,
                            "project": {
                                "id": workflow.project.id,
                                "name": workflow.project.name,
                            },
                            "timezone": workflow.timezone,
                            "scheduled": workflow.schedule is not None,
                        },
                    }
    
                    # Add schedule info if available
                    if workflow.schedule:
                        result["workflow"]["schedule"] = workflow.schedule
    
                    # Add latest session info if available
                    if workflow.latest_sessions:
                        latest_sessions = []
                        for session in workflow.latest_sessions[:5]:  # Last 5 sessions
                            latest_sessions.append(
                                {
                                    "session_time": session.session_time,
                                    "status": session.last_attempt.status,
                                    "success": session.last_attempt.success,
                                }
                            )
                        result["workflow"]["latest_sessions"] = latest_sessions
    
                    # Construct console URL
                    result[
                        "console_url"
                    ] = f"https://console.treasuredata.com/app/workflows/{workflow_id}/info"
    
                    return result
    
            return _format_error_response(f"Workflow with ID '{workflow_id}' not found")
    
        except Exception as e:
            return _format_error_response(f"Failed to get workflow: {str(e)}")
  • Registers the td_get_workflow tool by applying the mcp.tool() decorator inside the register_url_tools function.
    mcp.tool()(td_get_workflow)
  • Top-level registration call that invokes url_tools.register_url_tools(mcp, _create_client, _format_error_response), which in turn registers td_get_workflow and other URL tools.
    url_tools.register_url_tools(mcp, _create_client, _format_error_response)
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'Handles large workflow IDs that exceed pagination limits' (a useful behavioral trait) and describes the return content. However, it doesn't cover important aspects like error handling, rate limits, authentication requirements, or whether it's read-only (though implied by 'Get').

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. Every sentence adds value: the first states the purpose, the second explains usage context, the third describes behavioral capability, the fourth outlines return content, the bulleted scenarios provide concrete examples, and the final section details return values. No wasted words.

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 single-parameter read operation with no output schema, the description provides excellent context about usage scenarios, behavioral capabilities, and return values. The main gap is the lack of error handling or rate limit information, but given the tool's simplicity and the detailed usage guidance, it's mostly complete.

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?

The schema has 0% description coverage (no parameter descriptions), but the description compensates well. It explains that 'workflow_id' is a 'numeric ID' used for 'direct workflow lookup' and provides context about where these IDs come from (console URLs, error logs). However, it doesn't specify format constraints (e.g., numeric string vs. integer).

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 tool's purpose with specific verbs ('Get workflow details', 'Direct workflow lookup') and identifies the resource ('workflow details using numeric ID'). It distinguishes from siblings like 'td_list_workflows' (which lists workflows) and 'td_find_workflow' (which likely searches) by emphasizing direct ID-based lookup.

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 guidance on when to use this tool: 'Direct workflow lookup when you have the ID' and lists four common scenarios with concrete examples (extracting ID from URLs, error logs, project context, status checking). It implicitly distinguishes from alternatives by focusing on ID-based access rather than listing or searching.

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