Skip to main content
Glama
samhavens

Databricks MCP Server

by samhavens

list_job_runs

Retrieve recent Databricks job runs with status, duration, and results. Filter by job ID or view all jobs to monitor execution history.

Instructions

List recent job runs with detailed status and duration information.

Args:
    job_id: Specific job ID to list runs for (optional, omit to see runs across all jobs)
    limit: Number of runs to return (default: 10, most recent first)

Returns:
    JSON with runs array. Each run includes state (RUNNING/SUCCESS/FAILED), result_state, 
    duration_minutes for completed runs, current_duration_minutes for running jobs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
job_idNo
limitNo

Implementation Reference

  • The primary handler for the 'list_job_runs' MCP tool. Decorated with @mcp.tool() for automatic registration. Fetches runs via jobs.list_runs(), enhances with duration calculations, and returns JSON.
    @mcp.tool()
    async def list_job_runs(job_id: Optional[int] = None, limit: int = 10) -> str:
        """List recent job runs with detailed status and duration information.
        
        Args:
            job_id: Specific job ID to list runs for (optional, omit to see runs across all jobs)
            limit: Number of runs to return (default: 10, most recent first)
        
        Returns:
            JSON with runs array. Each run includes state (RUNNING/SUCCESS/FAILED), result_state, 
            duration_minutes for completed runs, current_duration_minutes for running jobs.
        """
        logger.info(f"Listing job runs (job_id={job_id}, limit={limit})")
        try:
            result = await jobs.list_runs(job_id=job_id, limit=limit)
            
            if "runs" in result:
                enhanced_runs = []
                for run in result["runs"]:
                    enhanced_run = run.copy()
                    
                    # Calculate duration if both times available
                    start_time = run.get("start_time")
                    end_time = run.get("end_time")
                    if start_time and end_time:
                        duration_ms = end_time - start_time
                        enhanced_run["duration_seconds"] = duration_ms // 1000
                        enhanced_run["duration_minutes"] = duration_ms // 60000
                    elif start_time and not end_time:
                        # Running job - calculate current duration
                        import time
                        current_time = int(time.time() * 1000)
                        duration_ms = current_time - start_time
                        enhanced_run["current_duration_seconds"] = duration_ms // 1000
                        enhanced_run["current_duration_minutes"] = duration_ms // 60000
                    
                    enhanced_runs.append(enhanced_run)
                
                result["runs"] = enhanced_runs
            
            return json.dumps(result)
        except Exception as e:
            logger.error(f"Error listing job runs: {str(e)}")
            return json.dumps({"error": str(e)})
  • API helper function that performs the actual Databricks Jobs API call to list runs (GET /api/2.0/jobs/runs/list). Called by the main handler.
    async def list_runs(job_id: Optional[int] = None, limit: Optional[int] = None) -> Dict[str, Any]:
        """
        List job runs, optionally filtered by job_id.
        
        Args:
            job_id: ID of the job to list runs for (optional)
            limit: Maximum number of runs to return (optional)
            
        Returns:
            Response containing a list of job runs
            
        Raises:
            DatabricksAPIError: If the API request fails
        """
        params = {}
        if job_id is not None:
            params["job_id"] = job_id
        if limit is not None:
            params["limit"] = limit
            
        logger.info(f"Listing runs (job_id={job_id}, limit={limit})")
        return make_api_request("GET", "/api/2.0/jobs/runs/list", params=params if params else None) 
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. It discloses key behavioral traits: it's a read operation (implied by 'List'), returns detailed status/duration info, and specifies ordering (most recent first). However, it doesn't mention pagination, rate limits, authentication requirements, or error conditions that would be helpful for a tool with no annotation coverage.

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 efficiently structured with a clear purpose statement followed by organized sections for Args and Returns. Every sentence earns its place by providing essential information without redundancy. The formatting with clear section headers makes it 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 2 parameters, no annotations, and no output schema, the description does well by explaining parameters, return format, and behavior. However, it could be more complete by mentioning potential error cases, authentication requirements, or rate limits given the absence of annotations. The return format description partially compensates for the lack of output schema.

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

Parameters5/5

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

The description adds significant value beyond the input schema, which has 0% description coverage. It explains that job_id is optional and what happens when omitted ('omit to see runs across all jobs'), clarifies the limit default value and ordering ('most recent first'), and provides context not present in the schema's bare property definitions.

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 verb ('List') and resource ('recent job runs') with specific scope ('with detailed status and duration information'). It distinguishes from siblings like 'list_jobs' by focusing on runs rather than job definitions, and from 'get_sql_status' by covering job execution status.

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 context for when to use it (to see runs across all jobs or for a specific job) and includes parameter guidance (optional job_id, default limit). However, it doesn't explicitly state when NOT to use it or name specific alternatives among siblings for different scenarios.

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/samhavens/databricks-mcp-server'

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