How databricks/ucode works
Purpose and entry points
ucode is a Python 3.12+ CLI that configures and launches third-party coding agents against Databricks AI Gateway using Databricks workspace credentials rather than agent-provider API keys. The command surface and dispatch live in src/ucode/cli.py; launch orchestration is in src/ucode/launcher.py; initial authentication/configuration flow begins in src/ucode/bootstrap.py.
Workspace state, authentication, and configuration lifecycle
The CLI resolves workspace URLs or Databricks CLI profiles, authenticates, discovers available Gateway models, persists local state, and writes/restores agent-owned configuration files. This is the boundary between local machine state and Databricks workspace APIs. Key modules are src/ucode/state.py, src/ucode/config_io.py, and src/ucode/databricks.py. Existing configurations are backed up before mutation and can be restored through revert.
Agent adapter layer
Each supported coding tool has an adapter responsible for native config format, launch command, model defaults, and validation behavior. Shared registration is in src/ucode/agents/__init__.py; representative implementations are src/ucode/agents/codex.py, src/ucode/agents/claude.py, and src/ucode/agents/cursor.py. Cursor is structurally distinct: it receives MCP configuration only and is not routed through Gateway model configuration.
Gateway launch and model routing
After local configuration, the launcher starts the selected external CLI as a child process with its normal arguments. Agent traffic is directed to Databricks AI Gateway endpoints, with model availability and validation mediated through the Databricks integration. Smart routing is opt-in for Codex and Claude: it selects a root-session model before launch and installs agent-profile hooks for subagent requests. Core routing logic and tool-specific integration are in src/ucode/smart_routing/routing.py, src/ucode/smart_routing/codex_routing.py, and src/ucode/smart_routing/claude_routing.py.
MCP and skills integration
MCP-capable agents are configured to invoke a local stdio proxy rather than directly contact Databricks HTTP endpoints. The proxy refreshes OAuth credentials per request, bridging the agent’s MCP client to Databricks streamable-HTTP MCP services. Registration and proxy behavior are centered in src/ucode/mcp.py, src/ucode/mcp_proxy.py, and src/ucode/gateway_proxy.py. Skills support either downloads Unity Catalog skill content into agent skill directories or exposes skills through MCP; implementation is in src/ucode/skills_download.py and src/ucode/mcp_web_search.py.
Managed workspace configuration
Workspace administrators can author a versioned local managed-config manifest, compose agents/models/MCPs/skills/spend tiers, compare it with the live workspace configuration, and publish updates atomically. This admin plane is separate from individual developer setup. Main stages are manifest representation and resolution (src/ucode/managed_config.py, src/ucode/managed_resolve.py), interactive authoring (src/ucode/managed_setup.py, src/ucode/managed_wizard.py), and budget policy (src/ucode/managed_budget.py).
Operational reporting and dependencies
Usage reporting can query AI Gateway activity and workspace SQL warehouse data; telemetry and tracing provide runtime observability. Relevant paths are src/ucode/usage.py, src/ucode/telemetry.py, and src/ucode/tracing.py. Material external dependencies are the Databricks CLI/auth profile system, Databricks AI Gateway, Databricks MCP and Unity Catalog services, installed coding-agent CLIs, and npm when an agent CLI must be installed.
Main entry points: launcher.py Launcher · __init__.py Agent registry · bootstrap.py Bootstrap · managed_config.py Managed manifest
Components 21
CLI & Launch
- CLI commands · Command parsing and dispatch.
src/ucode/cli.py - Launcher · Configures and starts the selected agent process.
src/ucode/launcher.py
Local Setup
- Bootstrap · Initial workspace authentication and configuration.
src/ucode/bootstrap.py - Local state & config I/O · Persists state and backs up or restores agent configuration.
src/ucode/state.py - Databricks integration · Resolves profiles, authenticates, and discovers Gateway models.
src/ucode/databricks.py
Agent Adapters
- Agent registry
src/ucode/agents/__init__.py - Codex adapter
src/ucode/agents/codex.py - Claude adapter
src/ucode/agents/claude.py - Cursor adapter · Uses MCP configuration rather than Gateway model configuration.
src/ucode/agents/cursor.py
Gateway & MCP
- Smart routing · Selects root models and coordinates subagent routing.
src/ucode/smart_routing/routing.py - Agent routing hooks · Codex and Claude profiles route subagent requests.
src/ucode/smart_routing/codex_routing.py - MCP registration
src/ucode/mcp.py - Local MCP proxy · Refreshes OAuth credentials for each MCP request.
src/ucode/mcp_proxy.py - Skills integration · Downloads Unity Catalog skills or exposes skills through MCP.
src/ucode/skills_download.py
Managed Admin Plane
- Managed manifest · Defines managed agents, models, MCPs, skills, and spend tiers.
src/ucode/managed_config.py - Managed resolution · Compares and resolves manifest state against the workspace.
src/ucode/managed_resolve.py - Managed authoring
src/ucode/managed_setup.py - Budget policy
src/ucode/managed_budget.py
Other components
- Usage & observability · Queries usage and emits telemetry and tracing.
src/ucode/usage.py - Databricks workspace · AI Gateway, MCP services, Unity Catalog, and SQL warehouse.
- Installed agent CLIs · Third-party coding agents launched as child processes.
Connections 24
- CLI commands → Bootstrap: setup commands
- CLI commands → Launcher: launch / revert
- Bootstrap → Databricks integration: authenticate and discover
- Bootstrap → Local state & config I/O: persist setup
- Launcher → Local state & config I/O: write, backup, restore config
- Launcher → Agent registry: select adapter
- Agent registry → Codex adapter
- Agent registry → Claude adapter
- Agent registry → Cursor adapter
- Launcher → Smart routing: opt-in routing
- Smart routing → Agent routing hooks: install profiles
- Launcher → MCP registration: configure MCP agents
- MCP registration → Local MCP proxy: local stdio endpoint
- Local MCP proxy → Databricks workspace: OAuth-backed MCP requests
- Launcher → Skills integration: configure skills
- Skills integration → Databricks workspace: Unity Catalog content
- Launcher → Installed agent CLIs: spawn with normal arguments
- Installed agent CLIs → Databricks workspace: Gateway model traffic
- Databricks integration → Databricks workspace: workspace APIs
- Managed authoring → Managed manifest: author manifest
- Managed manifest → Managed resolution: resolve and compare
- Budget policy → Managed manifest: spend tiers
- Managed resolution → Databricks workspace: atomically publish
- Usage & observability → Databricks workspace: Gateway activity and SQL usage