Build full-stack Databricks applications using APX framework (FastAPI + React).
Build full-stack Databricks applications using APX framework (FastAPI + React).
Invoke when user requests:
Do NOT invoke if user specifies: Streamlit, Dash, Node.js, Shiny, Gradio, Flask, or other frameworks.
Before initializing, ask the user:
Project Name: "What would you like to name this app?" (e.g., cluster-manager, data-explorer)
Target Workspace: "Which Databricks workspace will this deploy to?"
app.yaml DATABRICKS_HOSTCore Features: Confirm understanding of the app's purpose
Option A)
Repository configured for use with APX.
1.. Verify APX MCP available: mcp-cli tools | grep apx
2. Verify shadcn MCP available: mcp-cli tools | grep shadcn
3. Confirm APX project (check pyproject.toml)
Option B) Install APX
brew install uv.brew tap oven-sh/bun
brew install bun
uvx --from git+https://github.com/databricks-solutions/apx.git apx init
Total time: 55-70 minutes
# Start APX development server
mcp-cli call apx/start '{}'
mcp-cli call apx/status '{}'
Create TodoWrite with tasks:
In src/{app_name}/backend/models.py:
Follow 3-model pattern:
EntityIn - Input validationEntityOut - Complete output with computed fieldsEntityListOut - Performance-optimized summarySee backend-patterns.md for complete code templates.
In src/{app_name}/backend/router.py:
Critical requirements:
response_model (enables OpenAPI generation)operation_id (becomes frontend hook name)listX, getX, createX, updateX, deleteXSee backend-patterns.md for complete CRUD templates.
mcp-cli call apx/dev_check '{}'
Fix any Python type errors reported by basedpyright.
Wait 5-10 seconds after backend changes for OpenAPI client regeneration.
# Get shadcn add command
mcp-cli call shadcn/get_add_command_for_items '{
"items": ["@shadcn/button", "@shadcn/card", "@shadcn/table",
"@shadcn/badge", "@shadcn/select", "@shadcn/skeleton"]
}'
Run the command from project root with --yes flag.
List page: src/{app_name}/ui/routes/_sidebar/{entity}.tsx
Detail page: src/{app_name}/ui/routes/_sidebar/{entity}.$id.tsx
See frontend-patterns.md for complete page templates.
In src/{app_name}/ui/routes/_sidebar/route.tsx, add new item to navItems array.
Use Chrome DevTools MCP for automated UI testing:
# Type check both backend and frontend
mcp__apx__dev_check
# Navigate browser to app
mcp__chrome-devtools__puppeteer_navigate --url "http://localhost:5173"
# Take screenshot for visual verification
mcp__chrome-devtools__puppeteer_screenshot
# Check for console errors
mcp__chrome-devtools__puppeteer_console_logs
# Test navigation clicks
mcp__chrome-devtools__puppeteer_click --selector "[data-testid='nav-item']"
# Verify data loaded
mcp__chrome-devtools__puppeteer_evaluate --script "document.querySelectorAll('table tbody tr').length"
# Test API endpoints
curl http://localhost:8000/api/{entities} | jq .
curl http://localhost:8000/api/{entities}/{id} | jq .
# Get frontend URL
mcp__apx__get_frontend_url
apx dev check)See automated-testing.md for complete testing patterns with Puppeteer and MCP servers.
CRITICAL: When to Rebuild
| Change Type | Rebuild Required |
|---|---|
Frontend code (.tsx, .ts, .css) | npm run build in ui/ |
Backend code (.py) | No build needed (Python) |
app.yaml environment variables | Redeploy required |
package.json dependencies | npm install && npm run build |
pyproject.toml dependencies | Redeploy (picks up on restart) |
Always rebuild frontend after UI changes:
# 1. Build frontend (REQUIRED for .tsx/.ts/.css changes!)
cd {app_name}/ui
npm run build
cd ../..
# 2. Deploy via DABs
databricks bundle deploy -t dev
# 3. Restart app to pick up changes
databricks apps stop {app-name}
databricks apps start {app-name}
Backend-only changes (Python files): No build step needed, but still requires redeploy:
# Deploy bundle (uploads Python files)
databricks bundle deploy -t dev
# Redeploy app to pick up Python changes
databricks apps deploy {app-name} --source-code-path {path}
See databricks-deployment.md for:
Automated log checking with APX MCP:
The APX MCP server can automatically check deployed application logs. Simply ask: "Please check the deployed app logs for <app-name>"
The APX MCP will retrieve logs and identify issues automatically, including:
[SYSTEM] (deployment) and [APP] (application) logsManual log checking (reference):
For direct CLI access:
databricks apps logs <app-name> --profile <profile-name>
Key patterns to look for:
Deployment successful - App deployed correctlyApp started successfully - Application is runningError: - Check stack traces for issuesCreate two markdown files:
README.md:
CODE_STRUCTURE.md:
listEntities → useListEntities()useXSuspense(selector())lib/api.ts or types/routeTree.gen.tsapx dev check succeeds)Deployed app not working: Ask to check deployed app logs (APX MCP will automatically retrieve and analyze them) or manually use databricks apps logs <app-name>
Python type errors: Use explicit casting for dict access, check Optional fields
TypeScript errors: Wait for OpenAPI regen, verify hook names match operation_ids
OpenAPI not updating: Check watcher status with apx dev status, restart if needed
Components not added: Run shadcn from project root with --yes flag
Transform your APX app into a Databricks Managed MCP Server to enable AI agents in the Databricks Playground to call your app's functionality.
routers/mcp.py with JSON-RPC 2.0 endpointmcp_router to app.pydatabricks api post /api/2.0/accounts/servicePrincipals/<SP_ID>/credentials/secretsis_mcp_connection 'true'See databricks-apx-mcp-server for complete implementation guide with templates.
MCP_TOOLS = [
{
"name": "list_items",
"description": "List all items with status and metrics. Use to get overview or filter by status.",
"inputSchema": {
"type": "object",
"properties": {
"status": {"type": "string", "enum": ["ACTIVE", "PENDING"]},
"limit": {"type": "integer", "default": 100}
}
}
}
]
Read these files only when actively writing that type of code or debugging issues.