Skip to main content
Glama
knishioka

Treasure Data MCP Server

by knishioka

td_list_workflows

Monitor Treasure Data workflows to identify failed jobs, track execution status, and audit data pipeline health across all projects.

Instructions

List all workflows to monitor executions and find failed jobs.

Shows workflows across all projects with their latest execution status.
Essential for monitoring data pipeline health and finding issues.

Common scenarios:
- Check which workflows are failing (status_filter="error")
- Monitor currently running workflows (status_filter="running")
- Find workflows by name (use search parameter)
- Get overview of all scheduled jobs
- Audit workflow execution patterns

Filter options: status ('success', 'error', 'running'), search by name.
Set verbose=True for execution history. Limit count to avoid token issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
verboseNo
countNo
include_systemNo
status_filterNo
searchNo

Implementation Reference

  • The primary handler for the 'td_list_workflows' tool. It creates a TreasureDataClient, fetches workflows using client.get_workflows, applies filters for system workflows, status, and search terms, and returns formatted results in verbose or summary mode. Decorated with @mcp.tool() for automatic registration.
    @mcp.tool()
    async def td_list_workflows(
        verbose: bool = False,
        count: int = 50,
        include_system: bool = False,
        status_filter: str | None = None,
        search: str | None = None,
    ) -> dict[str, Any]:
        """List all workflows to monitor executions and find failed jobs.
    
        Shows workflows across all projects with their latest execution status.
        Essential for monitoring data pipeline health and finding issues.
    
        Common scenarios:
        - Check which workflows are failing (status_filter="error")
        - Monitor currently running workflows (status_filter="running")
        - Find workflows by name (use search parameter)
        - Get overview of all scheduled jobs
        - Audit workflow execution patterns
    
        Filter options: status ('success', 'error', 'running'), search by name.
        Set verbose=True for execution history. Limit count to avoid token issues.
        """
        client = _create_client(include_workflow=True)
        if isinstance(client, dict):
            return client
    
        try:
            workflows = client.get_workflows(count=min(count, 12000), all_results=True)
    
            # Filter out system workflows if requested
            if not include_system:
                workflows = [
                    w
                    for w in workflows
                    if not any(
                        meta.key == "sys"
                        for meta in w.project.model_dump().get("metadata", [])
                    )
                ]
    
            # Filter by status if requested
            if status_filter:
                filtered_workflows = []
                for workflow in workflows:
                    if workflow.latest_sessions:
                        last_status = workflow.latest_sessions[0].last_attempt.status
                        if last_status == status_filter:
                            filtered_workflows.append(workflow)
                workflows = filtered_workflows
    
            # Filter by search term if requested
            if search:
                search_lower = search.lower()
                filtered_workflows = []
                for workflow in workflows:
                    workflow_name = workflow.name.lower()
                    project_name = workflow.project.name.lower()
                    if search_lower in workflow_name or search_lower in project_name:
                        filtered_workflows.append(workflow)
                workflows = filtered_workflows
    
            if verbose:
                # Return full workflow details including sessions
                return {
                    "workflows": [
                        {
                            "id": w.id,
                            "name": w.name,
                            "project": {
                                "id": w.project.id,
                                "name": w.project.name,
                            },
                            "timezone": w.timezone,
                            "schedule": w.schedule,
                            "latest_sessions": [
                                {
                                    "session_time": s.session_time,
                                    "status": s.last_attempt.status,
                                    "success": s.last_attempt.success,
                                    "duration": None,  # Would need date parsing
                                }
                                for s in w.latest_sessions[:3]  # Show last 3 sessions
                            ],
                        }
                        for w in workflows
                    ]
                }
            else:
                # Return summary information
                return {
                    "workflows": [
                        {
                            "id": w.id,
                            "name": w.name,
                            "project": w.project.name,
                            "last_status": (
                                w.latest_sessions[0].last_attempt.status
                                if w.latest_sessions
                                else "no_runs"
                            ),
                            "scheduled": w.schedule is not None,
                        }
                        for w in workflows
                    ],
                    "total_count": len(workflows),
                }
        except (ValueError, requests.RequestException) as e:
            return _format_error_response(f"Failed to retrieve workflows: {str(e)}")
        except Exception as e:
            return _format_error_response(
                f"Unexpected error while retrieving workflows: {str(e)}"
            )
  • Supporting method in TreasureDataClient class that performs the actual API calls to retrieve workflows, supporting pagination and all_results mode by querying the /console/workflows endpoint.
    def get_workflows(
        self,
        count: int = 100,
        all_results: bool = False,
        page: int = 1,
    ) -> list[Workflow]:
        """
        Retrieve a list of workflows across all projects.
    
        This method retrieves workflows from the Treasure Data workflow console API.
        Workflows are the actual executable units that contain tasks defined in
        Digdag files (.dig). Each workflow belongs to a project and can have
        multiple sessions (execution instances).
    
        Args:
            count: Maximum number of workflows to retrieve per page (defaults to 100)
            all_results: If True, retrieves all workflows across multiple pages
            page: Page number for pagination (defaults to 1)
    
        Returns:
            A list of Workflow objects
    
        Raises:
            requests.HTTPError: If the API returns an error response
        """
        if all_results:
            # Retrieve all workflows by iterating through pages
            all_workflows = []
            current_page = 1
            per_page = min(count, 1000)  # Use reasonable page size
    
            while True:
                params = {
                    "count": per_page,
                    "page": current_page,
                    "order": "asc",
                    "sessions": 5,  # Include last 5 sessions for each workflow
                    "output": "simple",
                    "project_type": "user",
                }
    
                response = requests.get(
                    f"{self.workflow_base_url}/console/workflows",
                    headers=self.headers,
                    params=params,
                )
                response.raise_for_status()
    
                data = response.json()
                workflows = [
                    Workflow(**workflow) for workflow in data.get("workflows", [])
                ]
    
                if not workflows:
                    # No more workflows on this page
                    break
    
                all_workflows.extend(workflows)
    
                # Check if we've reached the desired count
                if len(all_workflows) >= count:
                    return all_workflows[:count]
    
                current_page += 1
    
            return all_workflows
        else:
            # Single page request
            params = {
                "count": count,
                "page": page,
                "order": "asc",
                "sessions": 5,  # Include last 5 sessions for each workflow
                "output": "simple",
                "project_type": "user",
            }
    
            response = requests.get(
                f"{self.workflow_base_url}/console/workflows",
                headers=self.headers,
                params=params,
            )
            response.raise_for_status()
    
            data = response.json()
            workflows = [Workflow(**workflow) for workflow in data.get("workflows", [])]
    
            return workflows
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 important behavioral aspects: 'Shows workflows across all projects with their latest execution status,' 'Limit count to avoid token issues,' and 'Set verbose=True for execution history.' However, it doesn't cover critical details like pagination behavior, rate limits, authentication requirements, or what specific data is returned in the response.

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

Conciseness4/5

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

The description is well-structured with purpose statement, scope clarification, use case scenarios, and parameter explanations in logical sections. It's appropriately sized for a 5-parameter tool with no annotations. Minor redundancy exists in repeating 'filter options' after listing scenarios, but overall it's efficient and front-loaded with the core purpose.

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 5 parameters with 0% schema coverage and no output schema, the description does a reasonable job explaining parameter usage and common scenarios. However, for a list/monitoring tool with no annotations, it should ideally mention response format, pagination details, or what specific fields are returned. The absence of output schema means the description should provide more guidance on what data to expect.

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, the description compensates well by explaining all 5 parameters: it clarifies 'status_filter' with allowed values ('success', 'error', 'running'), explains 'search' is for name filtering, describes 'verbose' provides execution history, mentions 'count' for limiting results, and implies 'include_system' (though not explicitly named). The only gap is not explicitly mentioning the 'include_system' parameter by name.

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: 'List all workflows to monitor executions and find failed jobs.' It specifies the verb ('list') and resource ('workflows') with additional context about monitoring and finding issues. However, it doesn't explicitly differentiate from sibling tools like 'td_list_projects' or 'td_list_sessions' beyond the workflow focus.

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

Usage Guidelines4/5

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

The description provides clear usage scenarios with specific examples (e.g., 'Check which workflows are failing', 'Monitor currently running workflows'), which effectively guides when to use this tool. It mentions filtering options and common use cases, but doesn't explicitly state when NOT to use it or compare it to alternatives like 'td_find_workflow' or 'td_get_workflow'.

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