From d125c81a4d56b192b86ff9161d7cdd1a64aff7e3 Mon Sep 17 00:00:00 2001 From: Trevor McCormick Date: Thu, 12 Mar 2026 09:07:07 -0400 Subject: [PATCH] fix: resolve execute_sql AttributeError and default warehouse_id from env - The execute_sql tool called sql.execute_sql(), which doesn't exist in src/api/sql.py. Changed to sql.execute_and_wait() which polls for query completion and returns results. - Also made warehouse_id optional by falling back to the DATABRICKS_SQL_WAREHOUSE_ID environment variable, so users can configure it once in their server config. --- src/server/databricks_mcp_server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/databricks_mcp_server.py b/src/server/databricks_mcp_server.py index 4534c97..7a2adc2 100644 --- a/src/server/databricks_mcp_server.py +++ b/src/server/databricks_mcp_server.py @@ -192,17 +192,17 @@ async def list_files(params: Dict[str, Any]) -> List[TextContent]: # SQL tools @self.tool( name="execute_sql", - description="Execute a SQL statement with parameters: statement (required), warehouse_id (required), catalog (optional), schema (optional)", + description="Execute a SQL statement with parameters: statement (required), warehouse_id (optional, defaults to DATABRICKS_SQL_WAREHOUSE_ID env var), catalog (optional), schema (optional)", ) async def execute_sql(params: Dict[str, Any]) -> List[TextContent]: logger.info(f"Executing SQL with params: {params}") try: statement = params.get("statement") - warehouse_id = params.get("warehouse_id") + warehouse_id = params.get("warehouse_id") or os.environ.get("DATABRICKS_SQL_WAREHOUSE_ID") catalog = params.get("catalog") schema = params.get("schema") - result = await sql.execute_sql(statement, warehouse_id, catalog, schema) + result = await sql.execute_and_wait(statement, warehouse_id, catalog, schema) return [{"text": json.dumps(result)}] except Exception as e: logger.error(f"Error executing SQL: {str(e)}") @@ -229,4 +229,4 @@ async def main(): if hasattr(sys.stdout, 'reconfigure'): sys.stdout.reconfigure(line_buffering=True) - asyncio.run(main()) \ No newline at end of file + asyncio.run(main())