Skip to main content
Glama
ChrisChoTW

databricks-mcp

by ChrisChoTW

databricks_query

Execute read-only SQL queries on Databricks to retrieve data, browse metadata, and monitor Delta Lake tables without performing destructive operations.

Instructions

Execute Databricks SQL query (supports SELECT, SHOW, DESCRIBE, CREATE, ALTER). INSERT, UPDATE, DELETE, DROP and other destructive operations are blocked.

Args: sql_query: SQL query statement (preferred parameter) sql: SQL query statement (fallback for backward compatibility)

Returns: Query results as list of dicts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sql_queryNo
sqlNo

Implementation Reference

  • The databricks_query function is defined and decorated as an MCP tool, containing logic to validate against destructive SQL operations before calling execute_sql.
    @mcp.tool
    def databricks_query(ctx: Context, sql_query: Optional[str] = None, sql: Optional[str] = None) -> List[Dict[str, Any]]:
        """
        Execute Databricks SQL query (supports SELECT, SHOW, DESCRIBE, CREATE, ALTER).
        INSERT, UPDATE, DELETE, DROP and other destructive operations are blocked.
    
        Args:
            sql_query: SQL query statement (preferred parameter)
            sql: SQL query statement (fallback for backward compatibility)
    
        Returns:
            Query results as list of dicts
        """
        query_to_execute = sql_query if sql_query is not None else sql
    
        if query_to_execute is None:
            raise ToolError("Must provide sql_query or sql parameter.")
    
        query_upper = query_to_execute.strip().upper()
        forbidden_keywords = [
            "INSERT INTO", "UPDATE ", "DELETE FROM", "DROP TABLE", "DROP VIEW",
            "DROP SCHEMA", "DROP CATALOG", "TRUNCATE TABLE", "MERGE INTO", "COPY INTO"
        ]
        for keyword in forbidden_keywords:
            if keyword in query_upper:
                raise ToolError(f"Destructive operation not allowed: {keyword}")
        return execute_sql(ctx, query_to_execute)

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

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