<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gordo on Medium]]></title>
        <description><![CDATA[Stories by Gordo on Medium]]></description>
        <link>https://medium.com/@cheery.gear93817?source=rss-49ffd9fca935------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Gordo on Medium</title>
            <link>https://medium.com/@cheery.gear93817?source=rss-49ffd9fca935------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 03:11:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cheery.gear93817/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Databricks MCP Servers: A Complete Reference]]></title>
            <link>https://medium.com/databricks-platform-sme/databricks-mcp-servers-a-complete-reference-946428fd4fdf?source=rss-49ffd9fca935------2</link>
            <guid isPermaLink="false">https://medium.com/p/946428fd4fdf</guid>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[mcps]]></category>
            <dc:creator><![CDATA[Gordo]]></dc:creator>
            <pubDate>Mon, 01 Jun 2026 17:48:40 GMT</pubDate>
            <atom:updated>2026-06-01T17:48:40.958Z</atom:updated>
            <content:encoded><![CDATA[<p>By <a href="https://medium.com/u/ef6fe39e2eeb">Mohamed Naseer Ahmed</a> and <a href="https://medium.com/u/49ffd9fca935">Gordo</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*5sV8IC4LBmHDrxrXzOI3PA.png" /></figure><p>Databricks supports three layers of MCP servers: managed (built-in), external (third-party via proxy), and custom (your own code on Databricks Apps). This document covers all three, including tools, calling examples, client configuration, and the role of Dynamic Client Registration (DCR). See the <a href="https://docs.databricks.com/aws/en/generative-ai/mcp/managed-mcp">official documentation</a> for enhancements released after publication.</p><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*OeXPNdHoXBpboX9MNC9ZxA.png" /></figure><h3>1. Genie Space MCP Server</h3><p><strong>URL</strong>: https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;<br><strong>Tools</strong>: query_space and poll_response</p><p>Genie spaces allow users to query structured data using natural language. The Genie MCP server exposes this capability as two tools. Because Genie needs time to generate SQL and execute it, the flow is asynchronous. You submit a question, get back the IDs, then poll until the results are ready.</p><p><strong>Limitation: </strong>Genie MCP invokes Genie as a stateless tool, meaning conversation history is not passed between calls. Each query_space call is a brand new question. For history-aware conversations, use Genie in a multi-agent system instead.</p><p><strong>query_space</strong><br>Submits a natural language question to the Genie space. Returns a conversation ID and message ID for polling.</p><p><strong>Arguments</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*7LYJCBVw2YUwatuBl8jRjQ.png" /></figure><p>Example call:</p><pre>result = client.call_tool(&quot;query_space&quot;, {<br>    &quot;query&quot;: &quot;What were total sales by region last quarter?&quot;<br>})</pre><p>Example response:</p><pre>{<br>  &quot;conversation_id&quot;: &quot;conv-a1b2c3d4&quot;,<br>  &quot;message_id&quot;: &quot;msg-e5f6g7h8&quot;,<br>  &quot;status&quot;: &quot;EXECUTING_QUERY&quot;<br>}</pre><p><strong>poll_response<br></strong>Polls for the result of a previously submitted query. Call repeatedly until status is COMPLETED.</p><p><strong>Arguments:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*BPkX5uqdGklhtJtVo8RgfQ.png" /></figure><p>Example call:</p><pre>result = client.call_tool(&quot;poll_response&quot;, {<br>    &quot;conversation_id&quot;: &quot;conv-a1b2c3d4&quot;,<br>    &quot;message_id&quot;: &quot;msg-e5f6g7h8&quot;<br>})</pre><p>Example response:</p><pre>{<br>  &quot;status&quot;: &quot;COMPLETED&quot;,<br>  &quot;result&quot;: &quot;| Region | Total Sales |\n|---|---|\n| North America | $4.2M |\n| EMEA | $3.1M |\n...&quot;<br>}</pre><p><strong>Full Python Example</strong></p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br>import time<br><br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br>genie_url = f&quot;{ws.config.host}/api/2.0/mcp/genie/01f11bbc4cc6126eaae20be0e9bdc9cc&quot;<br>client = DatabricksMCPClient(server_url=genie_url, workspace_client=ws)<br><br>tools = client.list_tools()<br>print([t.name for t in tools])  # [&#39;query_space&#39;, &#39;poll_response&#39;]<br><br>submit = client.call_tool(&quot;query_space&quot;, {<br>    &quot;query&quot;: &quot;Top 5 customers by revenue&quot;<br>})<br><br>while True:<br>    time.sleep(3)<br>    result = client.call_tool(&quot;poll_response&quot;, {<br>        &quot;conversation_id&quot;: &quot;&lt;from submit&gt;&quot;,<br>        &quot;message_id&quot;: &quot;&lt;from submit&gt;&quot;<br>    })<br>    if &quot;COMPLETED&quot; in str(result.content):<br>        print(result.content)<br>        break</pre><h3><strong>2. Databricks SQL MCP Server</strong></h3><p><strong>URL</strong>: https://&lt;workspace&gt;/api/2.0/mcp/sql<br><strong>Tools</strong>: execute_sql and poll_response</p><p>This is the most powerful of the managed server offerings. It is read-write, meaning the AI agent can generate and execute actual SQL statements, including CREATE, INSERT, and ALTER. This tool is designed for IDEs like Cursor and Claude Code, enabling users to create data pipelines efficiently.</p><p><strong>execute_sql<br></strong>Executes a SQL query against Databricks. Supports both read and write operations.</p><p><strong>Arguments</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*u2valXJwLzORzxKojooNdQ.png" /></figure><p><strong>_meta parameters (optional)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*ozlwOPlJpTN-lZ06hgRaIA.png" /></figure><p>Example call:</p><pre>result = client.call_tool(&quot;execute_sql&quot;, {<br>    &quot;query&quot;: &quot;SELECT customer_name, SUM(amount) as total FROM sales.transactions GROUP BY 1 ORDER BY 2 DESC LIMIT 10&quot;<br>})</pre><p>Example with _meta (pinning a warehouse):</p><pre>request = CallToolRequest(<br>    method=&quot;tools/call&quot;,<br>    params={<br>        &quot;name&quot;: &quot;execute_sql&quot;,<br>        &quot;arguments&quot;: {<br>            &quot;query&quot;: &quot;SELECT * FROM prod.analytics.daily_revenue LIMIT 10&quot;<br>        },<br>        &quot;_meta&quot;: {<br>            &quot;warehouse_id&quot;: &quot;a1b2c3d4e5f67890&quot;<br>        }<br>    }<br>)</pre><p><strong>Full Python Example</strong>:</p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br>sql_url = f&quot;{ws.config.host}/api/2.0/mcp/sql&quot;<br>client = DatabricksMCPClient(server_url=sql_url, workspace_client=ws)<br><br>tools = client.list_tools()<br>print([t.name for t in tools])  # [&#39;execute_sql&#39;, &#39;poll_response&#39;]<br><br>result = client.call_tool(&quot;execute_sql&quot;, {<br>    &quot;query&quot;: &quot;SHOW TABLES IN prod.analytics&quot;<br>})<br>print(result.content)</pre><h3>3. Vector Search MCP Server</h3><p><strong>URL: </strong>https://&lt;workspace&gt;/api/2.0/mcp/vector-search/{catalog}/{schema}<br><strong>Tools: </strong>One tool per Vector Search index, named {catalog}__{schema}__{index_name}</p><p>Enables semantic similarity search across documents stored in Databricks Vector Search indexes. The index must use Databricks managed embeddings.</p><h4><strong>Search Tool</strong></h4><p><strong>Arguments</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*YcNwMWi9ls3-ANTi47SmVg.png" /></figure><p><strong>_meta parameters (optional)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*UuwMbiipeRDgf-1lo7kBEQ.png" /></figure><p>Example call:</p><pre>result = client.call_tool(&quot;prod__docs__knowledge_base_index&quot;, {<br>    &quot;query&quot;: &quot;How do I reset my password?&quot;<br>})</pre><p>Example with _meta (hybrid search, filtering, reranking):</p><pre>request = CallToolRequest(<br>    method=&quot;tools/call&quot;,<br>    params={<br>        &quot;name&quot;: &quot;prod__docs__knowledge_base_index&quot;,<br>        &quot;arguments&quot;: {&quot;query&quot;: &quot;How do I configure SSO?&quot;},<br>        &quot;_meta&quot;: {<br>            &quot;num_results&quot;: &quot;5&quot;,<br>            &quot;query_type&quot;: &quot;HYBRID&quot;,<br>            &quot;columns&quot;: &quot;id,text,metadata&quot;,<br>            &quot;score_threshold&quot;: &quot;0.5&quot;,<br>            &quot;include_score&quot;: &quot;true&quot;,<br>            &quot;filters&quot;: &#39;{&quot;updated_after&quot;: &quot;2025-01-01&quot;}&#39;,<br>            &quot;columns_to_rerank&quot;: &quot;text,title&quot;<br>        }<br>    }<br>)</pre><p><strong>Full Python Example</strong>:</p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br>vs_url = f&quot;{ws.config.host}/api/2.0/mcp/vector-search/prod/docs&quot;<br>client = DatabricksMCPClient(server_url=vs_url, workspace_client=ws)<br><br>tools = client.list_tools()<br>print([t.name for t in tools])<br># [&#39;prod__docs__knowledge_base_index&#39;, &#39;prod__docs__faq_index&#39;]<br><br>result = client.call_tool(&quot;prod__docs__knowledge_base_index&quot;, {<br>    &quot;query&quot;: &quot;How do I reset my password?&quot;<br>})<br>print(result.content)</pre><h3><strong>4. Unity Catalog Functions MCP Server</strong></h3><p><strong>URL: </strong>https://&lt;workspace&gt;/api/2.0/mcp/functions/{catalog}/{schema}<br><strong>Tools: </strong>One tool per function, named {catalog}__{schema}__{function_name}</p><p>Exposes any Unity Catalog function as an MCP tool. Includes built-in system.ai functions and custom UDFs.</p><p><strong>Built-in system.ai Functions:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*IFalKLIoCRuMUFPuSt6GbA.png" /></figure><p>Example call (code interpreter):</p><pre>result = client.call_tool(&quot;system__ai__python_exec&quot;, {<br>    &quot;code&quot;: &quot;import math; print(math.factorial(20))&quot;<br>})<br>print(result.content)<br># 2432902008176640000</pre><p><strong>Custom Functions<br></strong>For a custom function at main.analytics.calculate_churn, connect to <em>/api/2.0/mcp/functions/main/analytics</em>. The tool is named main__analytics__calculate_churn.</p><p>Example call:</p><pre>result = client.call_tool(&quot;main__analytics__calculate_churn&quot;, {<br>    &quot;customer_segment&quot;: &quot;enterprise&quot;,<br>    &quot;time_period&quot;: &quot;Q4_2025&quot;<br>})<br>print(result.content)</pre><p><strong>Full Python Example</strong></p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br>uc_url = f&quot;{ws.config.host}/api/2.0/mcp/functions/system/ai&quot;<br>client = DatabricksMCPClient(server_url=uc_url, workspace_client=ws)<br><br>tools = client.list_tools()<br>print([t.name for t in tools])<br># [&#39;system__ai__python_exec&#39;, &#39;system__ai__similarity&#39;, ...]<br><br>result = client.call_tool(&quot;system__ai__python_exec&quot;, {<br>    &quot;code&quot;: &quot;print(&#39;Hello from Databricks!&#39;)&quot;<br>})<br>print(result.content)</pre><h3>Connecting from Claude Code, Cursor, or Other MCP Clients</h3><p>The examples below show how to connect external clients to any of the four managed servers. All examples use the Genie Space URL. Replace the path for your server type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*bN9zqbOy_H5xTbmg7Fhwvg.png" /><figcaption>Authentication methods comparison</figcaption></figure><h4>Option A: Streamable HTTP with OAuth (Recommended)</h4><p>This is the preferred method. The client connects directly to the Databricks MCP endpoint using the native streamable-http transport and authenticates via OAuth. No proxy layer is needed.</p><p><strong>Cursor configuration </strong>(~/.cursor/mcp.json)<br>For a public OAuth client (no client secret):</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;type&quot;: &quot;streamable-http&quot;,<br>      &quot;url&quot;: &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>      &quot;oauth&quot;: {<br>        &quot;clientId&quot;: &quot;&lt;your-oauth-client-id&gt;&quot;<br>      }<br>    }<br>  }<br>}</pre><p>For a confidential OAuth client (with client secret):</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;type&quot;: &quot;streamable-http&quot;,<br>      &quot;url&quot;: &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>      &quot;oauth&quot;: {<br>        &quot;clientId&quot;: &quot;&lt;your-oauth-client-id&gt;&quot;,<br>        &quot;clientSecret&quot;: &quot;&lt;your-oauth-client-secret&gt;&quot;<br>      }<br>    }<br>  }<br>}</pre><p><strong>Claude Code configuration<br></strong>Public client:</p><pre>claude mcp add-json genie-sales \<br>  &#39;{&quot;type&quot;:&quot;http&quot;,<br>    &quot;url&quot;:&quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>    &quot;oauth&quot;:{&quot;clientId&quot;:&quot;&lt;your-oauth-client-id&gt;&quot;,&quot;callbackPort&quot;:8080}}&#39;</pre><p>Confidential client:</p><pre>claude mcp add-json genie-sales \<br>  &#39;{&quot;type&quot;:&quot;http&quot;,<br>    &quot;url&quot;:&quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>    &quot;oauth&quot;:{&quot;clientId&quot;:&quot;&lt;your-oauth-client-id&gt;&quot;,&quot;callbackPort&quot;:8080}}&#39; \<br>  --client-secret &lt;your-oauth-client-secret&gt;</pre><h4><strong>Option B: Streamable HTTP with Personal Access Token (PAT)</strong></h4><p>Simpler setup for individual testing. Not recommended for production or shared environments. PATs are only supported for managed and external MCP servers — custom MCP servers (Databricks Apps) require OAuth.</p><p><strong>Cursor configuration </strong>(~/.cursor/mcp.json):</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;type&quot;: &quot;streamable-http&quot;,<br>      &quot;url&quot;: &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>      &quot;headers&quot;: {<br>        &quot;Authorization&quot;: &quot;Bearer &lt;YOUR_PAT&gt;&quot;<br>      }<br>    }<br>  }<br>}</pre><p><strong>Claude Desktop configuration </strong>(claude_desktop_config.json — requires mcp-remote for PAT header passthrough):</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;mcp-remote&quot;,<br>        &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>        &quot;--header&quot;,<br>        &quot;Authorization: Bearer &lt;YOUR_PAT&gt;&quot;<br>      ]<br>    }<br>  }<br>}</pre><h4>Option C: mcp-remote with OAuth (Fallback)</h4><p>Use <em>mcp-remote</em> as a local proxy bridge when the client’s native HTTP transport has issues (e.g., the known Claude Code reconnection bug, or clients that only support stdio transport like Claude Desktop). <em>mcp-remote</em> handles the OAuth flow and proxies the MCP connection over stdio.</p><p><strong>Cursor / Windsurf configuration </strong>(mcp config file)<br>Public client:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;mcp-remote&quot;,<br>        &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>        &quot;--static-oauth-client-info&quot;,<br>        &quot;{ \&quot;client_id\&quot;: \&quot;&lt;your-oauth-client-id&gt;\&quot; }&quot;<br>      ]<br>    }<br>  }<br>}</pre><p>Confidential client:</p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;genie-sales&quot;: {<br>      &quot;command&quot;: &quot;npx&quot;,<br>      &quot;args&quot;: [<br>        &quot;mcp-remote&quot;,<br>        &quot;https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>        &quot;--static-oauth-client-info&quot;,<br>        &quot;{ \&quot;client_id\&quot;: \&quot;&lt;your-oauth-client-id&gt;\&quot;, \&quot;client_secret\&quot;: \&quot;&lt;your-secret&gt;\&quot; }&quot;<br>      ]<br>    }<br>  }<br>}</pre><p><strong>Claude Code via mcp-remote:</strong></p><pre>claude mcp add -- npx -y mcp-remote@latest \<br>  https://&lt;workspace&gt;/api/2.0/mcp/genie/&lt;genie_space_id&gt;</pre><p>URL quick reference by server type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*4guHR6nsCkVe-G8j2EqJbQ.png" /><figcaption>URL Quick Reference by Server Type</figcaption></figure><p>All configuration examples above use the Genie Space URL. To connect to a different managed server, simply swap the URL path. Everything else (OAuth settings, transport type, headers) stays the same.</p><h3>Calling MCP Tools Directly from Your Own Application</h3><p>If you are building your own application (e.g., a web app with a search bar, a dashboard, a backend service, etc.) rather than using an AI coding assistant like Cursor or Claude Code, your application acts as the MCP client. You call the MCP tools directly. No LLM or agent framework is required.</p><h4><strong>How It Works</strong></h4><p>Your app connects to one or more Databricks-managed MCP servers using the <em>databricks-mcp</em> Python SDK, then calls tools directly based on user input. The pattern is always the same:</p><ol><li><strong>Connect:</strong> Authenticate using the Databricks SDK (OAuth or PAT via WorkspaceClient)</li><li><strong>Discover tools:</strong> Call list_tools() to see what is available on that server</li><li><strong>Call a tool:</strong> Call call_tool(name, arguments) with the user’s input</li><li><strong>Render:</strong> Parse the result and display it in your UI</li></ol><h4>Setup</h4><p>Install the required packages: pip install -U databricks-mcp databricks-sdk</p><p>Initialize the clients for the servers you need:</p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br><br># Connect to whichever servers your app needs<br>genie = DatabricksMCPClient(<br>    server_url=f&quot;{ws.config.host}/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>    workspace_client=ws<br>)<br><br>sql = DatabricksMCPClient(<br>    server_url=f&quot;{ws.config.host}/api/2.0/mcp/sql&quot;,<br>    workspace_client=ws<br>)<br><br>vector_search = DatabricksMCPClient(<br>    server_url=f&quot;{ws.config.host}/api/2.0/mcp/vector-search/prod/docs&quot;,<br>    workspace_client=ws<br>)<br><br>uc_functions = DatabricksMCPClient(<br>    server_url=f&quot;{ws.config.host}/api/2.0/mcp/functions/system/ai&quot;,<br>    workspace_client=ws<br>)</pre><p><strong>Example: Search Field -&gt; Genie (Natural Language to Structured Data)<br></strong>User types a plain English question in your search field. Your app sends it to Genie via query_space, polls for the result, and displays the data table:</p><pre>import time<br><br>def search_genie(user_query: str) -&gt; str:<br>    &quot;&quot;&quot;User types: &#39;total sales by region last quarter&#39; &quot;&quot;&quot;<br><br>    # Submit the question<br>    submit = genie.call_tool(&quot;query_space&quot;, {&quot;query&quot;: user_query})<br>    # Extract conversation_id and message_id from response<br>    # (parse from submit.content)<br><br>    # Poll until Genie finishes generating and running the SQL<br>    while True:<br>        time.sleep(3)<br>        result = genie.call_tool(&quot;poll_response&quot;, {<br>            &quot;conversation_id&quot;: &quot;&lt;from submit&gt;&quot;,<br>            &quot;message_id&quot;: &quot;&lt;from submit&gt;&quot;<br>        })<br>        if &quot;COMPLETED&quot; in str(result.content):<br>            return result.content  # Data table to render in your UI</pre><p><strong>Example: Search Field -&gt; Databricks SQL (Direct Query Execution)<br></strong>User types a SQL query (or your app constructs one based on form inputs). Your app executes it directly via execute_sql:</p><pre>def run_sql(query: str) -&gt; str:<br>    &quot;&quot;&quot;User types: &#39;SELECT region, SUM(amount) FROM sales.txn GROUP BY 1&#39; &quot;&quot;&quot;<br><br>    result = sql.call_tool(&quot;execute_sql&quot;, {&quot;query&quot;: query})<br>    return result.content  # Query results to render in your UI</pre><p><strong>Example: Search Field -&gt; Vector Search (Semantic Document Search)<br></strong>User types a natural language search query. Your app performs semantic similarity search across a Vector Search index and returns matching documents:</p><pre>def search_docs(user_query: str) -&gt; str:<br>    &quot;&quot;&quot;User types: &#39;how do I reset my password&#39; &quot;&quot;&quot;<br><br>    result = vector_search.call_tool(<br>        &quot;prod__docs__knowledge_base_index&quot;,<br>        {&quot;query&quot;: user_query}<br>    )<br>    return result.content  # Matching documents to render in your UI</pre><p><strong>Example: Button Click -&gt; Unity Catalog Function<br></strong>User clicks a button or submits a form. Your app calls a specific UC function with the parameters from the form:</p><pre>def run_code(code: str) -&gt; str:<br>    &quot;&quot;&quot;User submits Python code from an editor widget&quot;&quot;&quot;<br><br>    result = uc_functions.call_tool(<br>        &quot;system__ai__python_exec&quot;,<br>        {&quot;code&quot;: code}<br>    )<br>    return result.content  # Execution output to render in your UI</pre><p><strong>Putting It Together: Minimal Flask App<br></strong>A complete example of a web app with a search bar that queries Genie, executes SQL, or searches documents depending on which tab the user selects:</p><pre>from flask import Flask, request, jsonify<br>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br>import time<br><br>app = Flask(__name__)<br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br><br>clients = {<br>    &quot;genie&quot;: DatabricksMCPClient(<br>        server_url=f&quot;{ws.config.host}/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>        workspace_client=ws<br>    ),<br>    &quot;sql&quot;: DatabricksMCPClient(<br>        server_url=f&quot;{ws.config.host}/api/2.0/mcp/sql&quot;,<br>        workspace_client=ws<br>    ),<br>    &quot;search&quot;: DatabricksMCPClient(<br>        server_url=f&quot;{ws.config.host}/api/2.0/mcp/vector-search/prod/docs&quot;,<br>        workspace_client=ws<br>    ),<br>}<br><br><br>@app.route(&quot;/api/genie&quot;, methods=[&quot;POST&quot;])<br>def genie_query():<br>    query = request.json[&quot;query&quot;]<br>    submit = clients[&quot;genie&quot;].call_tool(&quot;query_space&quot;, {&quot;query&quot;: query})<br>    # poll until complete (simplified)<br>    time.sleep(5)<br>    result = clients[&quot;genie&quot;].call_tool(&quot;poll_response&quot;, {<br>        &quot;conversation_id&quot;: &quot;&lt;parse from submit&gt;&quot;,<br>        &quot;message_id&quot;: &quot;&lt;parse from submit&gt;&quot;<br>    })<br>    return jsonify({&quot;result&quot;: str(result.content)})<br><br><br>@app.route(&quot;/api/sql&quot;, methods=[&quot;POST&quot;])<br>def sql_query():<br>    query = request.json[&quot;query&quot;]<br>    result = clients[&quot;sql&quot;].call_tool(&quot;execute_sql&quot;, {&quot;query&quot;: query})<br>    return jsonify({&quot;result&quot;: str(result.content)})<br><br><br>@app.route(&quot;/api/search&quot;, methods=[&quot;POST&quot;])<br>def doc_search():<br>    query = request.json[&quot;query&quot;]<br>    result = clients[&quot;search&quot;].call_tool(<br>        &quot;prod__docs__knowledge_base_index&quot;, {&quot;query&quot;: query}<br>    )<br>    return jsonify({&quot;result&quot;: str(result.content)})<br><br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(port=5000)</pre><p><strong>Async Variant (for High-Throughput Apps)<br></strong>If your app handles many concurrent requests (e.g., a FastAPI service), use the async methods instead:</p><pre>from fastapi import FastAPI<br>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>app = FastAPI()<br>ws = WorkspaceClient(profile=&quot;my-profile&quot;)<br>genie = DatabricksMCPClient(<br>    server_url=f&quot;{ws.config.host}/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,<br>    workspace_client=ws<br>)<br><br><br>@app.post(&quot;/api/genie&quot;)<br>async def genie_query(query: str):<br>    # Use async variants: alist_tools(), acall_tool()<br>    result = await genie.acall_tool(&quot;query_space&quot;, {&quot;query&quot;: query})<br>    return {&quot;result&quot;: str(result.content)}</pre><p><strong>Key Points</strong></p><ul><li><strong>No LLM required.</strong> Your app is the MCP client. You call call_tool() directly: no LLM, no agent framework needed.</li><li><strong>Simple API.</strong> call_tool() takes a tool name and a dictionary of arguments. The MCP server handles authentication, execution, and Unity Catalog permission enforcement.</li><li><strong>Dynamic discovery.</strong> Use list_tools() at startup to discover what is available. If someone adds a new Vector Search index or UC function, your app picks it up automatically.</li><li><strong>Sync or async.</strong> DatabricksMCPClient provides both sync (call_tool) and async (acall_tool) methods.</li><li><strong>Auth is handled by the SDK.</strong> WorkspaceClient handles OAuth or PAT authentication. No extra auth code needed in your app.</li></ul><h3>The Three Layers of Databricks MCP</h3><p>Before diving into External MCP servers, it helps to understand the full architecture. Databricks organizes MCP into three layers, all accessed the same way via DatabricksMCPClient or external clients:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*xq0R-eLBAryJ4IFmYqgIXg.png" /></figure><p>From your agent or app code, all three layers look identical. You use the same 1, the same call_tool() method, and the same list_tools() discovery. The only difference is the URL.</p><h3>5. External MCP Servers (Third-Party via Databricks Proxy)</h3><p>External MCP servers let your agents access third-party services (GitHub, Google Drive, SharePoint, Slack, etc.) through a Databricks-managed proxy. Databricks handles authentication, token refresh, and secure credential storage via Unity Catalog connections. The external server appears to your code as if it were a managed server (<a href="https://docs.databricks.com/aws/en/generative-ai/mcp/external-mcp">docs link</a>).</p><p>There are four ways to install an external MCP server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*mODi54itWt5F943QDfOzJg.png" /></figure><p>At the time of writing, these are the managed OAuth providers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*zx2gYmrQzCPYl8gSZ7i6Mg.png" /></figure><p>Setup for Managed OAuth:</p><ol><li>In your workspace, go to <em>Catalog -&gt; Connections -&gt; Create connection</em></li><li>Select <em>HTTP</em> as the connection type</li><li>Select <em>OAuth User to Machine Per User</em> as the auth type</li><li>Select your provider from the OAuth Provider dropdown</li><li>Enter the required scopes (space-delimited)</li><li>Click <em>Create connection</em></li></ol><p>Each user is prompted to authorize with the provider on first use.</p><h4>Using External MCP Servers in Your Code</h4><p>Once installed, external servers are accessed via a proxy URL at <em>/api/2.0/mcp/external/{connection_name}</em>. You use the same DatabricksMCPClient as managed servers:</p><pre>from databricks_mcp import DatabricksMCPClient<br>from databricks.sdk import WorkspaceClient<br><br>ws = WorkspaceClient()<br>host = ws.config.host<br><br># External server — accessed identically to managed servers<br>github = DatabricksMCPClient(<br>    server_url=f&quot;{host}/api/2.0/mcp/external/github_connection&quot;,<br>    workspace_client=ws<br>)<br><br># Discover tools<br>tools = github.list_tools()<br>print([t.name for t in tools])<br># [&#39;list_commits&#39;, &#39;get_file_contents&#39;, &#39;search_repositories&#39;, ...]<br><br># Call a tool<br>result = github.call_tool(&quot;list_commits&quot;, {<br>    &quot;owner&quot;: &quot;mlflow&quot;,<br>    &quot;repo&quot;: &quot;mlflow&quot;,<br>    &quot;sha&quot;: &quot;master&quot;<br>})<br>print(result.content[0].text)</pre><p>Mixing managed and external servers in a single app:</p><pre>MCP_SERVERS = [<br>    f&quot;{host}/api/2.0/mcp/genie/&lt;genie_space_id&gt;&quot;,        # Managed<br>    f&quot;{host}/api/2.0/mcp/sql&quot;,                           # Managed<br>    f&quot;{host}/api/2.0/mcp/functions/system/ai&quot;,           # Managed<br>    f&quot;{host}/api/2.0/mcp/external/github_connection&quot;,    # External<br>    f&quot;{host}/api/2.0/mcp/external/gdrive_connection&quot;,    # External<br>]<br><br># All accessed the same way<br>for url in MCP_SERVERS:<br>    client = DatabricksMCPClient(server_url=url, workspace_client=ws)<br>    tools = client.list_tools()<br>    print(f&quot;{url}: {[t.name for t in tools]}&quot;)</pre><h4>Dynamic Client Registration (DCR)</h4><p>DCR is one of the most misunderstood aspects of MCP authentication. This section clarifies what it is, how it works, and where Databricks supports it versus where it does not.</p><h4>What Is DCR?</h4><p>In traditional OAuth, before an app can authenticate a user, someone must manually pre-register the app: go into a dashboard, create an OAuth app, set redirect URLs, pick scopes, and copy the client_id back into the app config.</p><p>Dynamic Client Registration (RFC 7591) automates this. The client sends its metadata (name, redirect URIs, grant types) to the authorization server’s registration endpoint and gets back a client_id on the fly. No human involved.</p><p>MCP adopted DCR because a single MCP client (like Claude Desktop) might connect to dozens of servers at runtime, and asking users to manually register with every server is impractical.</p><p><strong>The Two Directions of DCR in Databricks<br></strong>This is the critical distinction that causes confusion:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*kpmL9fGmW_7S0bA3Ps4QXw.png" /></figure><p><strong>How Outbound DCR Works<br></strong>When your Databricks agent needs to connect to a third-party MCP server that supports DCR:</p><pre>from databricks.sdk import WorkspaceClient<br>from databricks_mcp import register_mcp_server_via_dcr<br><br>ws = WorkspaceClient()<br><br>connection_url = register_mcp_server_via_dcr(<br>    connection_name=&quot;my_external_mcp&quot;,<br>    mcp_url=&quot;https://mcp.example.com/api&quot;,<br>    workspace_client=ws<br>)<br>print(f&quot;Connection created: {connection_url}&quot;)</pre><p>Behind the scenes, this function:</p><ol><li>Fetches <em>/.well-known/oauth-protected-resource</em> from the external server</li><li>Fetches <em>/.well-known/oauth-authorization-server</em> to discover the registration_endpoint</li><li>POSTs to the registration endpoint (RFC 7591 DCR) to auto-register Databricks as a client</li><li>Stores the resulting client_id and credentials as a Unity Catalog HTTP connection</li><li>The proxy endpoint is now available at <em>/api/2.0/mcp/external/{connection_name}</em></li></ol><p>After registration, you use it like any other server:</p><pre>client = DatabricksMCPClient(<br>    server_url=f&quot;{host}/api/2.0/mcp/external/my_external_mcp&quot;,<br>    workspace_client=ws<br>)<br>tools = client.list_tools()<br>result = client.call_tool(&quot;some_tool&quot;, {&quot;arg&quot;: &quot;value&quot;})</pre><p><strong>Why Inbound DCR Is Not Supported<br></strong>Databricks is an enterprise platform. Auto-creating OAuth apps with no human approval is a security risk. Databricks requires an account admin to explicitly create OAuth apps via the Account Console, controlling exactly which scopes, redirect URLs, and client types are allowed.</p><p>This is also aligned with the direction of the MCP spec. The November 2025 MCP spec update de-prioritized DCR in favor of Client ID Metadata Documents (CIMD). The new priority order is:</p><ol><li>Pre-registered credentials (what Databricks requires for inbound)</li><li>Client ID Metadata Documents (new MCP default)</li><li>Dynamic Client Registration (optional fallback)</li><li>Manual entry (last resort)</li></ol><p><strong>What This Means for Customer Troubleshooting<br></strong>When a client like Claude.ai tries to connect to a Databricks MCP server, it may attempt DCR first (looking for a registration_endpoint in the <em>/.well-known/oauth-authorization-server</em> metadata). When Databricks does not expose one, some clients fail silently or show cryptic errors. The fix is always the same: pre-register an OAuth app in the Account Console and provide the client_id manually.</p><h3>Complete URL Reference (All Three Layers)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*-hK5bIc74OlLXG4gAaNaOw.png" /></figure><p>All managed and external servers use the workspace hostname (e.g., <em>https://my-workspace.azuredatabricks.net/api/2.0/mcp/...</em>). Custom servers use their own dedicated App hostname.</p><h3>Private Connectivity</h3><p>MCP servers hosted on the Databricks platform honor the private connectivity configuration for the associated workspace. External MCP servers take advantage of <a href="https://docs.databricks.com/aws/en/security/network/serverless-network-security/pl-to-internal-network">serverless private connections</a> when configured.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=946428fd4fdf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/databricks-platform-sme/databricks-mcp-servers-a-complete-reference-946428fd4fdf">Databricks MCP Servers: A Complete Reference</a> was originally published in <a href="https://medium.com/databricks-platform-sme">Databricks Platform SME</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Databricks as an IdP: Run Databricks SQL Queries]]></title>
            <link>https://medium.com/databricks-platform-sme/databricks-as-an-idp-run-databricks-sql-queries-d614667ea446?source=rss-49ffd9fca935------2</link>
            <guid isPermaLink="false">https://medium.com/p/d614667ea446</guid>
            <category><![CDATA[databricks-iam]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[identity-management]]></category>
            <dc:creator><![CDATA[Gordo]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 15:19:48 GMT</pubDate>
            <atom:updated>2025-11-04T15:19:48.726Z</atom:updated>
            <content:encoded><![CDATA[<p>When building secure data workflows from external applications, authentication must be handled with care. Databricks provides identity and access management capabilities that enable it to be used as an OAuth2 identity provider (IdP) for custom applications. In this guide, you’ll learn how to leverage Databricks as an IdP, integrate it with your internal application, and issue SQL queries while maintaining user identity. Essentially, your custom application runs queries as the user’s identity, and Databricks enforces governance as if the user logged into the workspace directly.</p><h3>Use case</h3><p>This post applies under the following circumstances:</p><ol><li>A customer hosts an application external to their Databricks environment (e.g., on-premises or in their private cloud environment)</li><li>The external application must preserve user identity to guarantee that data governance applies to queried data</li><li>The external application wants to use the same authentication method that users use to log in to Databricks (e.g., SSO through a company IdP, sign-in with Google, etc.)</li><li>The application requires executing SQL queries against a SQL warehouse</li><li>The application only needs the SQL scope to interact with Databricks</li></ol><h3>Process overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*sTx49EwhRrtgqdJw23Ycuw.png" /><figcaption>High-level steps to leverage Databricks as an IdP</figcaption></figure><h3>Prerequisites</h3><ul><li>An existing SQL warehouse where all external application users have the CAN_USE permission</li><li>Permission to create an app connection in the account console</li></ul><h3>Create an App connection</h3><p>A Databricks <em>App connection</em> is a secure integration point that allows third-party applications or services to access Databricks resources using OAuth 2.0. These third-party applications are not to be confused with <a href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/">Databricks Apps</a>. Common examples include proprietary, internal applications running in a customer’s on-premises environment, BI tools such as Tableau, and other SaaS platforms.</p><p>The setup steps follow immediately below. The latest instructions, available <a href="https://docs.databricks.com/aws/en/integrations/enable-disable-oauth#enable-custom-oauth-applications-using-the-databricks-ui">here</a>, capture any changes to the UI:</p><ul><li>As a Databricks account admin, log in to the Databricks account console at <a href="https://accounts.cloud.databricks.com/">https://accounts.cloud.databricks.com</a></li><li>Go to <em>Settings -&gt; App connections</em>:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*y44PsprtsDjKLjGY8QyOTw.png" /><figcaption>Navigate to “App connections”</figcaption></figure><ul><li>Click <em>Add connection </em>on the right side of the screen:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/1*3IRgAVNY2FcEvbhc2O3hSA.png" /><figcaption>Add a new App connection</figcaption></figure><ul><li>Provide details for the app connection<br>- Name the connection for easy identification.<br>- Provide a redirect URL where Databricks will publish OAuth 2.0 tokens. This URL typically points to the domain where the custom application runs.<br>- Choose <em>SQL </em>for the access scope since the custom application only needs to run SQL queries.<br>- Ensure that <em>Generate a client secret</em> is selected to secure the connection between the custom application and the Databricks IdP.<br>- Click <em>Add </em>to complete the connection setup.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*oWOz_7Iy34ccUMLCS8T5jA.png" /><figcaption>Configuration of the new App connection</figcaption></figure><ul><li>The system generates a client ID and client secret used to request tokens on behalf of the user. This credential differs from the client ID and secret used for service principals and cannot access Databricks resources. Record these values for later use, then click <em>Done</em> to dismiss the window:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*ITuRNgejwhiM0rbb5mnvAA.png" /><figcaption>Client credentials used by the external application to talk to the Databricks IdP</figcaption></figure><h3>Retrieve a Databricks SQL warehouse ID</h3><p>The <a href="https://docs.databricks.com/api/workspace/statementexecution/executestatement">statement execution API</a> requires the ID for an accessible SQL warehouse. Navigate to the workspace that hosts the SQL warehouse, then go to <em>SQL Warehouses -&gt; &lt;your SQL warehouse&gt;</em>. The warehouse ID appears in the <em>Overview</em> tab. Record this value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Broi9M8gkjG3N9S8jNMjJg.png" /><figcaption>Location of the SQL warehouse ID</figcaption></figure><h3>Obtain an OAuth2 access token from Databricks</h3><p><strong>Note: your custom application must be able to accept HTTP requests at the <em>Redirect URLs </em>provided in the previous section</strong></p><p>Given the large number of programming languages and frameworks available for building applications, the following code snippets utilize the popular curl application to demonstrate the necessary API calls. Translate to your desired language as needed. Also, substitute actual values for any placeholders identified as &lt;placeholder&gt;.</p><ul><li>Generate a random value to track user requests in your application<br>- For example: fpTGNRKEB8MN4eLYLGBGT2</li><li>Direct the user to the Databricks authorization endpoint for their workspace to obtain an authorization code. The format for the endpoint is https://&lt;workspace-url&gt;/oidc/v1/authorize <br>- For example: <a href="https://dbc-75450a28-a5e9.cloud.databricks.com/oidc/v1/authorize"><em>https://dbc-75450a28-a5e9.cloud.databricks.com/oidc/v1/authorize</em></a></li><li>The HTTP request requires the following parameters:</li></ul><pre>curl --location --get \<br>  --url &quot;https://&lt;workspace-url&gt;/oidc/v1/authorize&quot; \<br>  --url-query &quot;response_type=code&quot; \<br>  --url-query &quot;response_mode=query&quot; \<br>  --url-query &quot;client_id=&lt;client-id-from-the-app-registration&gt;&quot; \<br>  --url-query &quot;redirect_uri=&lt;redirect-uri-from-the-app-registration&gt;&quot; \<br>  --url-query &quot;scope=sql offline_access&quot; \<br>  --url-query &quot;state=&lt;random-value-to-track-user-requests&gt;&quot;</pre><ul><li>Using example values referenced earlier, the curl command looks like the following after variable substitution:</li></ul><pre>curl --location --get \<br>  --url &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/oidc/v1/authorize&quot; \<br>  --url-query &quot;response_type=code&quot; \<br>  --url-query &quot;response_mode=query&quot; \<br>  --url-query &quot;client_id=7e01561f-9693-47e9-9e3e-1ee33ff76437&quot; \<br>  --url-query &quot;redirect_uri=http://localhost:9999&quot; \<br>  --url-query &quot;scope=sql offline_access&quot; \<br>  --url-query &quot;state=fpTGNRKEB8MN4eLYLGBGT2&quot;</pre><ul><li>The Databricks IdP returns the authorization code to <em>&lt;redirect-uri-from-the-app-registration&gt;</em> (e.g., http://localhost:9999) as a query parameter named <em>code</em>. Retrieve this value for use in the next step.</li><li>Once the listener receives the code, use the following curl command to exchange the code for an access token:</li></ul><pre>curl --request POST \<br>  --url &quot;https://&lt;workspace-url&gt;/oidc/v1/token&quot; \<br>  --header &quot;Content-Type: application/x-www-form-urlencoded&quot; \<br>  --data-urlencode &quot;grant_type=authorization_code&quot; \<br>  --data-urlencode &quot;code=&lt;authorization-code-from-previous-step&gt;&quot; \<br>  --data-urlencode &quot;redirect_uri=&lt;redirect-uri-from-the-app-registration&gt;&quot; \<br>  --data-urlencode &quot;client_id=&lt;client-id-from-the-app-registration&gt;&quot; \<br>  --data-urlencode &quot;client_secret=&lt;client-secret-from-the-app-registration&gt;&quot;</pre><ul><li>Using example values referenced earlier, the curl command looks like the following after variable substitution:</li></ul><pre>curl --request POST \<br>  --url &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/oidc/v1/token&quot; \<br>  --header &quot;Content-Type: application/x-www-form-urlencoded&quot; \<br>  --data-urlencode &quot;grant_type=authorization_code&quot; \<br>  --data-urlencode &quot;code=dcod3b15a36297db936376c53144ce36bbe4&quot; \<br>  --data-urlencode &quot;redirect_uri=http://localhost:9999&quot; \<br>  --data-urlencode &quot;client_id=7e01561f-9693-47e9-9e3e-1ee33ff76437&quot; \<br>  --data-urlencode &quot;client_secret=dose...&quot;</pre><ul><li>Databricks returns a JSON object containing fields with an access token (access_token) and a refresh token (refresh_token). For example:</li></ul><pre>{                                                                                                                                                                         <br>  &quot;access_token&quot;: &quot;eyJ...maxA&quot;,<br>  &quot;expires_in&quot;: 3600,<br>  &quot;refresh_token&quot;: &quot;doaudfa132296770a21a163c9c69f67f1363&quot;,<br>  &quot;scope&quot;: &quot;offline_access sql&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;<br>}</pre><h3>Execute a SQL query</h3><h4>Option 1: invoke the REST API</h4><ul><li>Use the access token to execute a query on a Databricks SQL warehouse:</li></ul><pre>curl --request POST \<br>  --url &quot;https://&lt;workspace-url&gt;/api/2.0/sql/statements&quot; \<br>  --header &#39;authorization: Bearer &lt;access-token&gt;&#39; \<br>  --header &#39;content-type: application/json&#39; \<br>  --data &#39;{<br>  &quot;row_limit&quot;: 100,<br>  &quot;statement&quot;: &quot;SELECT * FROM range(100)&quot;,<br>  &quot;warehouse_id&quot;: &quot;&lt;sql-warehouse-id&gt;&quot;<br>}&#39;</pre><ul><li>For example:</li></ul><pre># The access token is truncated for readability<br>curl --request POST \<br>  --url &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/api/2.0/sql/statements&quot; \<br>  --header &#39;authorization: Bearer eyJ...maxA&#39; \<br>  --header &#39;content-type: application/json&#39; \<br>  --data &#39;{<br>  &quot;row_limit&quot;: 100,<br>  &quot;statement&quot;: &quot;SELECT * FROM range(100)&quot;,<br>  &quot;warehouse_id&quot;: &quot;d42d841170210a31&quot;<br>}&#39;</pre><ul><li>Process the results as needed for your application</li></ul><h4>Option 2: use the Databricks SDK</h4><p>The Databricks SDK handles many low-level concerns left to the caller by directly invoking the APIs, such as automatically iterating through paginated result sets. The following example uses the Java SDK.</p><p>Note: this guide is not intended to cover best practices for using the SDK. Refer to the guides for <a href="https://docs.databricks.com/aws/en/dev-tools/sdk-python">Python</a>, <a href="https://docs.databricks.com/aws/en/dev-tools/sdk-java">Java</a>, or <a href="https://docs.databricks.com/aws/en/dev-tools/sdk-go">Go</a> for the latest recommendations.</p><ul><li>Instantiate a WorkspaceClient using the access token generated earlier:</li></ul><pre>DatabricksConfig config = new DatabricksConfig()<br>  .setHost(&quot;https://dbc-75450a28-a5e9.cloud.databricks.com&quot;)<br>  .setToken(&quot;eyJ...maxA&quot;);<br><br>WorkspaceClient workspace = new WorkspaceClient(config);</pre><ul><li>Use the WorkspaceClient to submit SQL for execution:</li></ul><pre>StatementResponse response = workspace.statementExecution().executeStatement(new ExecuteStatementRequest()<br>  .setRowLimit(100L)<br>  .setStatement(&quot;SELECT * FROM range(100)&quot;)<br>  .setWarehouseId(&quot;d42d841170210a31&quot;));<br><br>// Handle results below</pre><h3>Refresh the token as needed</h3><p>Access tokens are short-lived credentials. The <em>expires_in</em> field returned by Databricks in the response containing the OAuth 2.0 tokens determines the lifetime of the access token in seconds. For longer sessions, acquire a new access token before it expires. Request new tokens from Databricks by presenting the refresh token:</p><pre>curl --request POST \<br>  --url &quot;https://&lt;workspace-url&gt;/oidc/v1/token&quot; \<br>  --header &quot;Content-Type: application/x-www-form-urlencoded&quot; \<br>  --data-urlencode &quot;grant_type=refresh_token&quot; \<br>  --data-urlencode &quot;refresh_token=&lt;refresh-token&gt;&quot; \<br>  --data-urlencode &quot;client_id=&lt;client-id-from-the-app-registration&gt;&quot; \<br>  --data-urlencode &quot;client_secret=&lt;client-secret-from-the-app-registration&gt;&quot;</pre><p>Using example values referenced earlier, the curl command looks like the following after variable substitution:</p><pre>curl --request POST \<br>  --url &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/oidc/v1/token&quot; \<br>  --header &quot;Content-Type: application/x-www-form-urlencoded&quot; \<br>  --data-urlencode &quot;grant_type=refresh_token&quot; \<br>  --data-urlencode &quot;refresh_token=doaudfa132296770a21a163c9c69f67f1363&quot; \<br>  --data-urlencode &quot;client_id=7e01561f-9693-47e9-9e3e-1ee33ff76437&quot; \<br>  --data-urlencode &quot;client_secret=dose...&quot;</pre><p>The response contains new access and refresh tokens. Replace the previous tokens with these new values:</p><pre>{<br>  &quot;access_token&quot;: &quot;eyJ...IOU2YQ&quot;,<br>  &quot;refresh_token&quot;: &quot;doau9d2bd4c88101049b0332cb40491fd7f2&quot;,<br>  &quot;scope&quot;: &quot;offline_access sql&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expires_in&quot;: 3600<br>}</pre><h3>Conclusion</h3><p>This blog outlines the necessary steps for integrating an external application with Databricks SQL, ensuring secure access to SQL warehouses while maintaining data governance and integrity. By following the procedures for creating an app connection, obtaining OAuth2 tokens, and executing SQL queries, users can efficiently leverage their applications while preserving user identity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d614667ea446" width="1" height="1" alt=""><hr><p><a href="https://medium.com/databricks-platform-sme/databricks-as-an-idp-run-databricks-sql-queries-d614667ea446">Databricks as an IdP: Run Databricks SQL Queries</a> was originally published in <a href="https://medium.com/databricks-platform-sme">Databricks Platform SME</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Say No to Long-Term Credentials Part 1: The Databricks CLI]]></title>
            <link>https://medium.com/databricks-platform-sme/say-no-to-long-term-credentials-part-1-the-databricks-cli-0ba8765e5b89?source=rss-49ffd9fca935------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ba8765e5b89</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Gordo]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 17:49:05 GMT</pubDate>
            <atom:updated>2025-09-22T17:49:05.833Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCriYLnTfWoFkFRHjL9FSQ.png" /><figcaption>A subset of the Databricks CLI commands</figcaption></figure><p>This is the first in a short series of posts targeting the elimination of long-term credentials, starting with the <a href="https://docs.databricks.com/aws/en/dev-tools/cli">Databricks CLI</a>. Many users of this tool use service principals or Personal Access Tokens (PATs) to authenticate to their workspaces and accounts. This blog covers three CLI features to avoid persisting long-term credentials, namely:</p><ul><li>User-to-machine (U2M) authentication instead of machine-to-machine (M2M)</li><li>Short-term credential vending for external tools</li><li>Arbitrary API calls to any public Databricks API</li></ul><h3>Drawbacks of long-term credentials</h3><p>Long-term credentials pose a number of problems from a security standpoint. Leaked or stolen credentials could result in catastrophic outcomes, leading to loss of confidence from customers. When unavoidable, teams should implement strong audit and rotation policies as described in the <a href="https://docs.aws.amazon.com/wellarchitected/latest/framework/sec_identities_audit.html">AWS Well-Architected Framework</a>. While not necessarily difficult, doing so requires dedicated time and resources.</p><h3>Authenticate as yourself</h3><p>The <a href="https://docs.databricks.com/aws/en/dev-tools/cli">Databricks CLI</a> is an excellent tool for running ad hoc tasks against your environment. Its interface is far more pleasant than calling APIs directly, as it handles low-level concerns such as authentication, token refresh, pagination, etc. Some experience with the CLI is helpful, but anyone new to the tool should be able to follow along.</p><p>The diagram below shows a simplified view of common CLI usage. A user executes a command that instructs the CLI to read credentials stored in a configuration file. The CLI then calls the API(s) in the Databricks environment to complete the request. When using a service principal as depicted here, the user assumes the role of the service principal and is confined to actions accessible by that system identity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*2HA92gmzXbcp6fP9Sm2xmg.png" /><figcaption>Common authentication flow using long-term credentials assigned to a service principal</figcaption></figure><p>In contrast, the diagram below is what we want to achieve. The caller authenticates using the assigned authentication method for their Databricks account/workspace:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*BT1KCbwpYfl0dN5fXn3hcw.png" /><figcaption>Authenticate as yourself</figcaption></figure><p>We start by establishing a session to a workspace using the user-to-machine (aka U2M) OAuth2 flow. U2M fits cases where a human is present in the process and their identity needs to be preserved. In contrast, machine-to-machine (aka M2M) targets automation workflows where the user’s identity isn’t needed. Most importantly, U2M relies on short-term credentials for authentication. The CLI makes this easy with the auth login subcommand and defaults to U2M:</p><pre>% databricks auth login --host &quot;https://dbc-75450a28-a5e9.cloud.databricks.com&quot;  --profile blog<br>Profile blog was successfully saved # Shown after authentication succeeds</pre><p>When executed, the spawns a new browser tab targeting the supplied workspace to authenticate using whichever authentication method is configured for the workspace. This is SSO for Azure/Google and SSO or email with a one-time passcode on AWS. The CLI creates a profile (<em>blog</em> for this example) and stores it in ~/.databrickscfg by default. It can be used in subsequent sessions with the--profile blog option. A success message appears to confirm authentication worked:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*VoaXBb0l4Y2aRHQAMcGOjA.png" /><figcaption>Successful U2M authentication</figcaption></figure><p>With an authenticated session, several APIs are at your disposal. To retrieve information about the current user, for example:</p><pre>% databricks --profile blog current-user me<br>{                         <br>  &quot;active&quot;:true,          <br>  &quot;displayName&quot;:&quot;Bricky Brickerson&quot;,                      <br>  &quot;emails&quot;: [             <br>    {                                               <br>      &quot;primary&quot;:true,                               <br>      &quot;type&quot;:&quot;work&quot;,                                <br>      &quot;value&quot;:&quot;bricky.brickerson@databricks.com&quot;                                                               <br>    }                     <br>  ],                      <br>  &quot;entitlements&quot;: [                                 <br>    {                     <br>      &quot;value&quot;:&quot;allow-cluster-create&quot;                <br>    },                                              <br>    {                     <br>      &quot;value&quot;:&quot;allow-instance-pool-create&quot;                                                               <br>    }<br>  ...<br>}</pre><h3>Generate short-term credentials for external tools</h3><p>The Databricks APIs are all REST-based, so DevOps and infrastructure teams sometimes prefer to use existing tooling like <a href="https://curl.se/"><em>curl</em></a> to access them. <em>curl</em> is a fantastic tool that (hopefully) needs no introduction. One downside of using non-native tooling is the need to specify a bearer token for authentication. Here is the same call to the <a href="https://docs.databricks.com/api/workspace/currentuser/me"><em>Me</em> API</a> using <em>curl</em> instead of the CLI:</p><pre>curl --header &quot;Authorization: Bearer SOME-TOKEN&quot; &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/api/2.0/preview/scim/v2/Me&quot;</pre><p>As you can see, <em>curl</em> needs a reference to a credential to call the API successfully. One solution is to visit the workspace and generate a <a href="https://docs.databricks.com/aws/en/dev-tools/auth/pat">PAT</a>. Easy peasy. Note: this doesn’t work for account APIs since a PAT is scoped to a workspace. But this article is all about avoiding long-term credentials. Let’s use a short-lived OAuth2 token instead. The target workflow looks very similar to the U2M diagram shown earlier. <em>curl</em>, using a short-term OAuth2 token, simply replaces the CLI to execute an API call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*ZShACkWl8tXlfgT1wfzCnQ.png" /></figure><p>How do we get one of these tokens? The <a href="https://docs.databricks.com/aws/en/dev-tools/auth/oauth-u2m?language=Environment#manually-generate-oauth-u2m-access-tokens">docs</a> lay out the steps to manually generate it. Yikes! While this works, I doubt anyone would intentionally sign up for that workflow.</p><p>The CLI comes to the rescue. Simply tell it to generate an OAuth2 token:</p><pre>% databricks --profile blog auth token<br>{<br>  &quot;access_token&quot;: &quot;eyJraWQiOiJk...&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expiry&quot;: &quot;...&quot;,<br>  &quot;expires_in&quot;: 3600<br>}</pre><p>The value in the <em>access_token</em> field is an OAuth2 token suitable for use in any tool capable of making REST calls. On Unix/Linux systems, it’s easy to streamline the workflow with help from <a href="https://jqlang.org/">jq</a> or similar tools:</p><pre>% export TOKEN=$(databricks --profile blog auth token | jq &#39;.access_token&#39;)<br>% curl --header &quot;Authorization: Bearer $TOKEN&quot; &quot;https://dbc-75450a28-a5e9.cloud.databricks.com/api/2.0/preview/scim/v2/Me&quot;<br>{                         <br>  &quot;active&quot;:true,          <br>  &quot;displayName&quot;:&quot;Bricky Brickerson&quot;,                      <br>  &quot;emails&quot;: [             <br>    {                                               <br>      &quot;primary&quot;:true,                               <br>      &quot;type&quot;:&quot;work&quot;,                                <br>      &quot;value&quot;:&quot;bricky.brickerson@databricks.com&quot;                                                               <br>    }                     <br>  ],                      <br>  &quot;entitlements&quot;: [                                 <br>    {                     <br>      &quot;value&quot;:&quot;allow-cluster-create&quot;                <br>    },                                              <br>    {                     <br>      &quot;value&quot;:&quot;allow-instance-pool-create&quot;                                                               <br>    }<br>  ...<br>}</pre><p>Now we’re cooking. Note that, unlike using the CLI directly, <em>curl</em> will not automatically refresh the token once it expires. If this happens, simply generate a new one.</p><h3>Call any Databricks API directly from the CLI</h3><p>We can go one step further with API calling. I like the flexibility of calling any API that <em>curl</em> gives me, but I also like the automatic token refresh from the CLI. I’m a <a href="https://uselessinformation.org/lazy-man-makes-tough-job-simple/">lazy developer</a> so I want a way to get both. Luckily, the CLI has a way to do just that. Assume the <em>Me</em> API isn’t public yet because it’s a private preview. Here is an example invocation to hit this endpoint:</p><pre>% databricks --profile blog api get /api/2.0/preview/scim/v2/Me<br>{                         <br>  &quot;active&quot;:true,          <br>  &quot;displayName&quot;:&quot;Bricky Brickerson&quot;,                      <br>  &quot;emails&quot;: [             <br>    {                                               <br>      &quot;primary&quot;:true,                               <br>      &quot;type&quot;:&quot;work&quot;,                                <br>      &quot;value&quot;:&quot;bricky.brickerson@databricks.com&quot;                                                               <br>    }                     <br>  ],                      <br>  &quot;entitlements&quot;: [                                 <br>    {                     <br>      &quot;value&quot;:&quot;allow-cluster-create&quot;                <br>    },                                              <br>    {                     <br>      &quot;value&quot;:&quot;allow-instance-pool-create&quot;                                                               <br>    }<br>  ...<br>}</pre><p>The often-overlooked api subcommand grants access to any API supported by the platform. Since the CLI is used, credentials are automatically handled including transparent refresh. PUT/PATCH/POST calls are possible too for more complex calls.</p><p>In summary, the CLI is a great tool for managing or querying your Databricks deployment. It has first-class support for short-term OAuth2 credentials and preserves the caller’s identity. It can generate short-term credentials for any other tool that makes REST calls. Lastly, for cases where a subcommand doesn’t exist yet, it also provides a mechanism to call those APIs while addressing low-level concerns like token refresh automatically.</p><p>Stay tuned for more in the series addressing alternatives to long-term credentials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ba8765e5b89" width="1" height="1" alt=""><hr><p><a href="https://medium.com/databricks-platform-sme/say-no-to-long-term-credentials-part-1-the-databricks-cli-0ba8765e5b89">Say No to Long-Term Credentials Part 1: The Databricks CLI</a> was originally published in <a href="https://medium.com/databricks-platform-sme">Databricks Platform SME</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[S3 Gateway Endpoints: Good and Good for Your Wallet]]></title>
            <link>https://medium.com/databricks-platform-sme/s3-gateway-endpoints-good-and-good-for-your-wallet-505cadaed1a5?source=rss-49ffd9fca935------2</link>
            <guid isPermaLink="false">https://medium.com/p/505cadaed1a5</guid>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cost-management]]></category>
            <dc:creator><![CDATA[Gordo]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 16:00:51 GMT</pubDate>
            <atom:updated>2024-06-24T16:00:51.382Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAu9L5K8htTRZCc7m_modA.png" /></figure><p>Accessing S3 for data storage often incurs additional networking costs when running applications on Amazon EC2 instances. My colleagues JD and Al covered the topic nicely in this <a href="https://www.databricks.com/blog/optimizing-aws-s3-access-databricks">blog post</a> since the same principle applies to Databricks on AWS. The most cost-effective way to eliminate these expenses is to use an S3 gateway endpoint. By keeping all S3 traffic within the AWS network, you can avoid data transfer charges and bypass the need for internet gateways or NAT gateways which carry hourly fees.</p><h3>What is an S3 Gateway Endpoint?</h3><p>An S3 gateway endpoint is a regional gateway you can provision to serve as an entry point for traffic destined to Amazon S3 from within your VPC. It allows you to keep all S3 traffic within the AWS network, eliminating the need to traverse the internet and reducing your attack surface.</p><h3>Benefits of Using an S3 Gateway Endpoint</h3><h4>Improved Security</h4><p>By keeping all S3 traffic within the AWS network, you reduce the risk of unauthorized access or data leakage. You can also restrict access to S3 buckets to only resources within your VPC by updating the bucket policy.</p><h4>Simplified Network Architecture</h4><p>EC2 instances with only private IP addresses can directly access S3 without needing a NAT gateway, internet gateway, public IP addresses, or bastion hosts. This simplifies your network design and eliminates the need to manage security group rules to allow internet access for S3. Compute nodes in the classic data plane use private IP addresses exclusively.</p><h4>Reduced Costs</h4><p>Using a gateway endpoint is free of charge, unlike NAT gateways which incur hourly costs. Additionally, you avoid data transfer costs for internet traffic since the S3 traffic stays within AWS.</p><h4>Increased Performance</h4><p>Traffic between your VPC and S3 may have lower latency and higher throughput by avoiding alternate routes.</p><h4>Validated Solution</h4><p>Databricks shoulders the burden to secure network communications when utilizing fully-managed compute in your Databricks account (i.e. the <a href="https://docs.databricks.com/en/getting-started/overview.html#serverless-compute-plane">serverless compute plane</a>). Although this post does not focus on serverless, the S3 gateway pattern plays a key role in achieving the stated goal for serverless. It is a tried-and-true solution that is on by default.</p><h4>Seamless Integration</h4><p>Deploying an S3 gateway is transparent to Databricks. Data access patterns such as Delta Sharing also benefit with no code changes needed. For example, in a Databricks-to-Databricks share situation, the recipient reads intra-region data over the gateway at no cost. The provider may explicitly allowlist the recipient’s VPC ID in their bucket policy for an additional layer of protection.</p><h4>Centralized Access Control</h4><p>The gateway supports <a href="https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html">endpoint policies</a> to centrally manage and audit S3 access from your VPC. This powerful feature enables you to define exactly which S3 buckets and operations are allowed and thus provides a strong safeguard against data exfiltration. As an example, a granular policy includes only minimal bucket references: buckets containing business data for analytics as well as other buckets <a href="https://docs.databricks.com/en/resources/supported-regions.html#artifact-storage-log-storage-system-tables-and-shared-datasets-buckets">required by the platform</a>.</p><h3>Setting Up an S3 Gateway Endpoint</h3><p>Setting up an S3 gateway endpoint is a straightforward process that can be done through the Amazon VPC console. Here are the high-level steps:</p><ul><li>Open the Amazon VPC console and navigate to the <em>Endpoints</em> section</li><li>Create a new endpoint, selecting the AWS service category and the appropriate S3 service name for your region (e.g. com.amazonaws.us-east-1.s3)</li><li>Select the VPC and route tables to associate with the endpoint. These are the same values used for compute in the <a href="https://docs.databricks.com/en/getting-started/overview.html#classic-compute-plane">classic compute plane</a></li><li>Configure the endpoint policy to allow full or custom access to S3</li><li>Update the security group rules for your EC2 instances to allow traffic to the Amazon S3 prefix list</li></ul><p>Once set up, your EC2 instances in the configured subnets will be able to access S3 buckets through the gateway endpoint over the AWS network. Neither an internet gateway nor a NAT device is needed. The <a href="https://aws.amazon.com/blogs/aws/new-visualize-your-vpc-resources-from-amazon-vpc-creation-experience/">AWS resource map</a> for the VPC should show a connection from the private subnets of the VPC to the gateway endpoint as shown here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nxTYJpGnOEZoML1eoa6M3g.png" /><figcaption>S3 Gateway connected to private subnets</figcaption></figure><p>Using an S3 gateway endpoint is a recommended best practice for securely and efficiently accessing Amazon S3 from your EC2 instances within the same region. It provides improved security, simplified networking, reduced costs, and potentially better performance compared to accessing S3 via more complicated approaches.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=505cadaed1a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/databricks-platform-sme/s3-gateway-endpoints-good-and-good-for-your-wallet-505cadaed1a5">S3 Gateway Endpoints: Good and Good for Your Wallet</a> was originally published in <a href="https://medium.com/databricks-platform-sme">Databricks Platform SME</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Storage Configuration Mystery]]></title>
            <link>https://medium.com/databricks-platform-sme/a-storage-configuration-mystery-f3b47acd8815?source=rss-49ffd9fca935------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3b47acd8815</guid>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[unity-catalog]]></category>
            <category><![CDATA[databricks]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[iam-roles]]></category>
            <dc:creator><![CDATA[Gordo]]></dc:creator>
            <pubDate>Fri, 19 Apr 2024 14:18:03 GMT</pubDate>
            <atom:updated>2024-11-04T22:17:20.518Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdaFnXjJ2sg_TcQiTlm4DA.png" /></figure><h3>Intro</h3><p>Ever wondered why there’s an IAM role ARN field in the Databricks storage configuration wizard in your Databricks AWS account console? I’m referring to the part of the new workspace wizard that asks for a default location for some workspace actions. Let’s unravel this mystery together in this short blog post!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*WpaZ7biCswp1xtAhFmJWQQ.png" /><figcaption>New storage configuration wizard</figcaption></figure><p>It’s optional so why is it there? A full explanation requires some understanding of Unity Catalog (UC) and its place as the de facto governance solution for the Databricks platform.</p><h3>What is UC?</h3><p>Databricks Unity Catalog is a managed service that enables users to discover, manage, and govern data assets across their lakehouse architecture. It provides a unified interface for managing data objects, such as tables, views, and machine learning models, and allows for secure data sharing. Some benefits of using Databricks Unity Catalog include:</p><ul><li><strong>Unified Data Management</strong>: Unity Catalog provides a single interface to manage all data assets, simplifying data discovery and access</li><li><strong>Data Governance</strong>: Unity Catalog includes features for data lineage, access control, and auditing, ensuring data is used securely and in compliance with regulations and internal policies</li><li><strong>Improved Collaboration</strong>: Unity Catalog enables secure data sharing allowing teams to collaborate more effectively</li><li><strong>Increased Productivity</strong>: by providing a unified interface for data management, Unity Catalog reduces the time and effort required to manage data, allowing users to focus on analysis and insights</li></ul><p>It should come as no surprise that UC is now <a href="https://www.databricks.com/blog/built-governance-your-databricks-workspace">enabled by default</a> for new workspaces given all its advantages. The linked blog post covers the 4 noticeable facets brought about by the change. Keen observers may be drawn to a particular phrase in the second bullet point (emphasis mine) which is our first clue:</p><p><em>You’ll find a catalog named after your workspace (‘acme prod’ in this example). This catalog serves as a place for you to put your data and AI assets, such as tables, models, files, and functions. </em><strong><em>This catalog uses cloud storage dedicated to your workspace to store underlying data</em></strong><em>.</em></p><p>In practical terms, the workspace catalog stores its data within the same bucket used by the workspace. This bucket is commonly referred to as DBFS or Databricks File System. It is no longer necessary to allocate a second bucket dedicated exclusively to UC. You may be wondering how this works since UC requires a <a href="https://docs.databricks.com/en/connect/unity-catalog/storage-credentials.html">storage credential</a> (i.e. a cross-account IAM role in AWS) to access data from cloud storage?</p><p>Now that mysterious field in the first image starts to make sense. Providing an appropriate IAM role creates a storage credential for use by UC. The storage credential grants UC permission to manage tables, views, models, etc. in the workspace’s catalog. An example IAM policy for the role is provided below. The second statement in the policy allows the role to assume itself as described in the documentation for storage credentials linked above:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Id&quot;: &quot;databricks-uc-dbfs-bucket-access&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Action&quot;: [<br>        &quot;s3:DeleteObject&quot;<br>        &quot;s3:GetBucketLocation&quot;,<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:PutObject&quot;,<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;&lt;YOUR-DBFS-BUCKET-ARN-HERE&gt;&quot;,<br>        &quot;&lt;YOUR-DBFS-BUCKET-ARN-HERE&gt;/unity-catalog/*&quot;<br>      ],<br>      &quot;Effect&quot;: &quot;Allow&quot;<br>    },<br>    {<br>      &quot;Action&quot;: [<br>        &quot;sts:AssumeRole&quot;<br>      ],<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Resource&quot;: [<br>        &quot;&lt;THE-ARN-OF-THIS-IAM-ROLE&gt;&quot;<br>      ]<br>    }<br>  ]<br>}</pre><p>The role needs a trust policy as well to allow UC to use it (see t<a href="https://docs.databricks.com/en/connect/unity-catalog/storage-credentials.html#step-3-update-the-iam-role-trust-relationship-policy">his section</a> of the docs). Here is the trust policy for reference:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: [<br>          &quot;arn:aws:iam::414351767826:role/unity-catalog-prod-UCMasterRole-14S5ZJVKOTYTL&quot;,<br>          &quot;arn:aws:iam::&lt;YOUR-AWS-ACCOUNT-ID&gt;:role/&lt;THIS-ROLE-NAME&gt;&quot;<br>        ]<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;sts:ExternalId&quot;: &quot;&lt;YOUR-DATABRICKS-ACCOUNT-ID&gt;&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>Those in the audience familiar with the DBFS access model may be wondering how this integrates with UC since both share space in the same bucket. Simple. The bucket policy prevents any control plane services except UC from accessing UC storage. An example policy makes the point clear. Pay special attention to the Prevent DBFS from accessing Unity Catalog metastore statement:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;Grant Databricks Access&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;arn:aws:iam::414351767826:root&quot;<br>      },<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:GetObjectVersion&quot;,<br>        &quot;s3:PutObject&quot;,<br>        &quot;s3:DeleteObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:GetBucketLocation&quot;<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;&lt;YOUR-DBFS-BUCKET-ARN-HERE&gt;/*&quot;,<br>        &quot;&lt;YOUR-DBFS-BUCKET-ARN-HERE&gt;&quot;<br>      ],<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalTag/DatabricksAccountId&quot;: [<br>            &quot;&lt;YOUR-DATABRICKS-ACCOUNT-ID-HERE&gt;&quot;<br>          ]<br>        }<br>      }<br>    },<br>    {<br>      &quot;Sid&quot;: &quot;Prevent DBFS from accessing Unity Catalog metastore&quot;,<br>      &quot;Effect&quot;: &quot;Deny&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;arn:aws:iam::414351767826:root&quot;<br>      },<br>      &quot;Action&quot;: [<br>        &quot;s3:*&quot;<br>      ],<br>      &quot;Resource&quot;: [<br>        &quot;&lt;YOUR-DBFS-BUCKET-ARN-HERE&gt;/unity-catalog/*&quot;<br>      ]<br>    }<br>  ]<br>}</pre><p>Mystery solved! All that’s left is to start using the new workspace with all the benefits of UC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3b47acd8815" width="1" height="1" alt=""><hr><p><a href="https://medium.com/databricks-platform-sme/a-storage-configuration-mystery-f3b47acd8815">A Storage Configuration Mystery</a> was originally published in <a href="https://medium.com/databricks-platform-sme">Databricks Platform SME</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>