run_job
Execute a Databricks job by specifying the job ID and optional notebook parameters, enabling automation of workflows and task management within the Databricks environment.
Instructions
Run a Databricks job
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes | ||
| notebook_params | No |
Implementation Reference
- MCP tool handler for 'run_job': wraps the jobs API call, handles errors, and returns JSON response.@mcp.tool() async def run_job(job_id: str, notebook_params: Optional[Dict[str, Any]] = None) -> str: """Run a Databricks job""" logger.info(f"Running job: {job_id}") try: if notebook_params is None: notebook_params = {} result = await jobs.run_job(job_id, notebook_params) return json.dumps(result) except Exception as e: logger.error(f"Error running job: {str(e)}") return json.dumps({"error": str(e)})
- src/api/jobs.py:31-52 (helper)Underlying API helper that performs the actual POST request to Databricks /api/2.0/jobs/run-now to run the job.async def run_job(job_id: int, notebook_params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: """ Run a job now. Args: job_id: ID of the job to run notebook_params: Optional parameters for the notebook Returns: Response containing the run ID Raises: DatabricksAPIError: If the API request fails """ logger.info(f"Running job: {job_id}") run_params = {"job_id": job_id} if notebook_params: run_params["notebook_params"] = notebook_params return make_api_request("POST", "/api/2.0/jobs/run-now", data=run_params)
- src/server/simple_databricks_mcp_server.py:240-252 (registration)Registration of the 'run_job' tool via @mcp.tool() decorator in the FastMCP server.@mcp.tool() async def run_job(job_id: str, notebook_params: Optional[Dict[str, Any]] = None) -> str: """Run a Databricks job""" logger.info(f"Running job: {job_id}") try: if notebook_params is None: notebook_params = {} result = await jobs.run_job(job_id, notebook_params) return json.dumps(result) except Exception as e: logger.error(f"Error running job: {str(e)}") return json.dumps({"error": str(e)})