From 33d5579e8e521c08d3fbe51315a694e1ee8086b5 Mon Sep 17 00:00:00 2001 From: Julian Underdown <62287663+j-underdown@users.noreply.github.com> Date: Tue, 9 Jun 2026 09:00:50 +0200 Subject: [PATCH] feat: allow DATABRICKS_MCP_CLIENT env var to override product name in user-agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Organisations running the MCP server from multiple AI clients (Claude Code, Codex, Cursor, etc.) have no way to distinguish traffic in Databricks audit logs and SQL warehouse query history — PRODUCT_NAME was hardcoded. Reading from DATABRICKS_MCP_CLIENT with "databricks-ai-dev-kit" as fallback preserves existing behaviour for anyone who doesn't set the variable. Co-Authored-By: Claude Sonnet 4.6 --- .../databricks_tools_core/identity.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/databricks-tools-core/databricks_tools_core/identity.py b/databricks-tools-core/databricks_tools_core/identity.py index db9b4493..c0bae13a 100644 --- a/databricks-tools-core/databricks_tools_core/identity.py +++ b/databricks-tools-core/databricks_tools_core/identity.py @@ -8,9 +8,26 @@ Resources created by the MCP server are also tagged with project metadata and any freeform tags defined in ``.databricks-ai-dev-kit.yaml``. -Example user-agent string:: +The product name can be overridden via the ``DATABRICKS_MCP_CLIENT`` environment +variable. This allows organisations running the MCP server from multiple AI +clients (Claude Code, Codex, Cursor, etc.) to distinguish traffic in Databricks +audit logs and SQL warehouse query history without maintaining a fork. + +Example user-agent strings:: databricks-ai-dev-kit/0.1.0 databricks-sdk-py/0.73.0 python/3.11.13 os/darwin auth/pat project/my-repo + my-org-claude-code/0.1.0 databricks-sdk-py/0.73.0 python/3.11.13 os/darwin auth/pat project/my-repo + +Setting ``DATABRICKS_MCP_CLIENT`` per client: + +Claude Code (``~/.claude.json`` MCP server env block):: + + "env": { "DATABRICKS_MCP_CLIENT": "my-org-claude-code" } + +Codex (``~/.codex/config.toml``):: + + [mcp_servers.databricks.env] + DATABRICKS_MCP_CLIENT = "my-org-codex" Example config file (``.databricks-ai-dev-kit.yaml`` at repo root):: @@ -32,7 +49,7 @@ logger = logging.getLogger(__name__) -PRODUCT_NAME = "databricks-ai-dev-kit" +PRODUCT_NAME = os.environ.get("DATABRICKS_MCP_CLIENT", "databricks-ai-dev-kit") DESCRIPTION_FOOTER = "Built with Databricks AI Dev Kit"