Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6640e24
feat: add task manager for MCP session/task state
datasciencemonkey May 1, 2026
2b74453
feat: add MCP server with 5 tools for Genie Code integration
datasciencemonkey May 1, 2026
ce8e5d2
feat: mount MCP server at /mcp with CORS and PTY integration
datasciencemonkey May 1, 2026
0c7023f
test: add end-to-end MCP integration tests
datasciencemonkey May 1, 2026
958f57f
feat: add ASGI app with native MCP + Flask for Genie Code compatibility
datasciencemonkey May 1, 2026
a849a89
fix: call initialize_app() in ASGI entrypoint (was only in gunicorn h…
datasciencemonkey May 1, 2026
9adcba4
fix: enable stateless_http and json_response for Genie Code compatibi…
datasciencemonkey May 1, 2026
7aaf03e
fix: add workspace origin to MCP transport_security allowed_origins
datasciencemonkey May 2, 2026
4d86f70
fix: replace ASGI bridge with Flask-native MCP endpoint (restores Web…
datasciencemonkey May 2, 2026
28a8231
fix: skip security headers for /mcp (CSP was interfering with Genie C…
datasciencemonkey May 2, 2026
db5c1eb
fix: use native MCP SDK transport with CORSMiddleware per Genie Code …
datasciencemonkey May 2, 2026
d822de2
fix: improve tool descriptions to guide Genie Code polling workflow
datasciencemonkey May 2, 2026
ec47832
fix: improve prompt convention with explicit result.json instructions
datasciencemonkey May 2, 2026
24b6303
fix: find result.json in both root and results/ subdir
datasciencemonkey May 2, 2026
5af976e
fix: add exponential backoff polling instructions for Genie Code
datasciencemonkey May 2, 2026
0ba8f28
feat: add CoDA orchestrator instructions to Hermes config (sub-agents…
datasciencemonkey May 2, 2026
73f76c5
feat: add CoDA Constitution — no destructive actions on pre-existing …
datasciencemonkey May 2, 2026
b2497a5
feat: v2 MCP API — background execution + inbox pattern
datasciencemonkey May 3, 2026
58e30c2
docs: add v2 MCP background execution flow diagram and reference
datasciencemonkey May 3, 2026
e31dcb4
fix: switch from uvicorn to gunicorn to restore WebSocket support
datasciencemonkey May 3, 2026
a812e17
fix: update task_manager tests for v2 ephemeral session model
datasciencemonkey May 3, 2026
8d64393
fix: make all 10 failing tests pass deterministically
datasciencemonkey May 3, 2026
787251d
refactor: move setup scripts to setup/ and install scripts to scripts/
datasciencemonkey May 3, 2026
7f0d19c
refactor: move MCP modules to coda_mcp/ package
datasciencemonkey May 4, 2026
f91303e
docs: update README with new project structure and MCP server docs
datasciencemonkey May 4, 2026
de4f76f
fix: correct README inaccuracies found by feature audit
datasciencemonkey May 4, 2026
49e8488
fix: remove dead _check_origin() and chmod config files to 0o600
datasciencemonkey May 4, 2026
b447318
test: add coverage for content_filter_proxy, sync_to_workspace, and _…
datasciencemonkey May 4, 2026
b7642ee
fix: add PYTHONPATH to CLI reconfiguration subprocess env
datasciencemonkey May 4, 2026
0589fd6
test: add _configure_all_cli_auth PYTHONPATH regression test
datasciencemonkey May 4, 2026
3a80f0a
fix: switch to uvicorn for native MCP Streamable HTTP transport
datasciencemonkey May 4, 2026
43d24a6
feat: native ASGI WebSocket via python-socketio AsyncServer
datasciencemonkey May 4, 2026
f95bb8a
fix: use other_asgi_app parameter for socketio.ASGIApp
datasciencemonkey May 4, 2026
80f8816
fix: use polling-first transport order for Databricks proxy WS auth
datasciencemonkey May 4, 2026
5dfd2f4
fix: allow all CORS origins for Socket.IO on Databricks Apps
datasciencemonkey May 4, 2026
1a6d282
fix: await async enter_room/leave_room in ASGI Socket.IO handlers
datasciencemonkey May 4, 2026
95e8c7e
fix: strengthen MCP instructions to prevent Genie Code polling loop
datasciencemonkey May 4, 2026
8198c26
feat: add stdio MCP bridge for Claude Code OAuth auth
datasciencemonkey May 4, 2026
478b1a2
docs: add MCP client auth setup to README
datasciencemonkey May 4, 2026
1ce86bf
feat: add safety guardrails to CODA-TASK prompt envelope
datasciencemonkey May 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Claude Code on Databricks

Welcome! This environment comes pre-configured with 5 AI coding agents, 39 skills, and 2 MCP servers. Hermes Agent is available alongside Claude Code, Codex, Gemini CLI, and OpenCode — launch it with `hermes chat`.
Welcome! This environment comes pre-configured with 5 AI coding agents, 43 skills, and 3 MCP servers. Hermes Agent is available alongside Claude Code, Codex, Gemini CLI, and OpenCode — launch it with `hermes chat`.

## Skills (30 total)

Expand Down Expand Up @@ -39,6 +39,7 @@ From [obra/superpowers](https://github.com/obra/superpowers):

- **DeepWiki** - AI-powered documentation for any GitHub repository
- **Exa** - Web search and code context retrieval
- **CoDA** (exposed at `/mcp`) - Delegate coding tasks to AI agents via MCP. Any MCP client (Genie Code, Claude Desktop, Cursor) can call `coda_run`, `coda_inbox`, and `coda_get_result` to submit background tasks, check status, and retrieve results. See `docs/mcp-v2-background-execution.md`.

## Databricks CLI

Expand Down
138 changes: 118 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Use this template](https://img.shields.io/badge/Use%20this%20template-2ea44f?logo=github)](https://github.com/datasciencemonkey/coding-agents-databricks-apps/generate)
[![Deploy to Databricks](https://img.shields.io/badge/Deploy-Databricks%20Apps-FF3621?logo=databricks&logoColor=white)](docs/deployment.md)
[![Agents](https://img.shields.io/badge/Agents-5%20included-green)](#whats-inside)
[![Skills](https://img.shields.io/badge/Skills-39%20built--in-blue)](#-all-39-skills)
[![Skills](https://img.shields.io/badge/Skills-43%20built--in-blue)](#-all-43-skills)

> Run Claude Code, Codex, Gemini CLI, Hermes Agent, and OpenCode in your browser — zero setup, wired to your Databricks workspace.

Expand Down Expand Up @@ -57,7 +57,7 @@ This isn't just a terminal in the cloud. Running coding agents on Databricks giv
| ✂️ **Split Panes** | Run two sessions side by side with a draggable divider |
| 🌐 **WebSocket I/O** | Real-time terminal output over WebSocket — zero-latency, eliminates polling delay |
| 🔁 **HTTP Polling Fallback** | Automatic fallback via Web Worker when WebSocket is unavailable |
| 🚀 **Parallel Setup** | 7 agent setups run in parallel (~5x faster startup) |
| 🚀 **Parallel Setup** | 6 agent setups run in parallel (~5x faster startup) |
| 🔍 **Search** | Find anything in your terminal history (Ctrl+Shift+F) |
| 🎤 **Voice Input** | Dictate commands with your mic (Option+V) |
| 📋 **Image Paste** | Paste or drag-and-drop images into the terminal — saved to `~/uploads/`, path inserted automatically |
Expand All @@ -71,7 +71,7 @@ This isn't just a terminal in the cloud. Running coding agents on Databricks giv

## MLflow Tracing

Every Claude Code session is **automatically traced** to a Databricks MLflow experiment — zero configuration required.
Claude Code sessions can be **automatically traced** to a Databricks MLflow experiment. Tracing is disabled by default — set `MLFLOW_CLAUDE_TRACING_ENABLED=true` in your app environment to enable it.

### How it works

Expand Down Expand Up @@ -116,11 +116,11 @@ View them in the Databricks UI: **Workspace > Machine Learning > Experiments**.

### Configuration

Tracing is configured during app startup by `setup_mlflow.py`, which merges the following into `~/.claude/settings.json`:
Tracing is configured during app startup by `setup/setup_mlflow.py`, which merges the following into `~/.claude/settings.json`:

| Setting | Value | Purpose |
|---------|-------|---------|
| `MLFLOW_CLAUDE_TRACING_ENABLED` | `true` | Enables Claude Code tracing |
| `MLFLOW_CLAUDE_TRACING_ENABLED` | `false` | Claude Code tracing (disabled by default, set to `true` to enable) |
| `MLFLOW_TRACKING_URI` | `databricks` | Routes traces to Databricks backend |
| `MLFLOW_EXPERIMENT_NAME` | `/Users/{owner}/{app}` | Target experiment path |
| `OTEL_EXPORTER_OTLP_ENDPOINT` | `""` | Overrides container OTEL to prevent trace loss |
Expand Down Expand Up @@ -170,7 +170,7 @@ This template repo opens that vision up for every Databricks user — no IDE set
---

<details>
<summary><strong>🧠 All 39 Skills</strong></summary>
<summary><strong>🧠 All 43 Skills</strong></summary>

### Databricks Skills (25) — [ai-dev-kit](https://github.com/databricks-solutions/ai-dev-kit)

Expand All @@ -195,16 +195,100 @@ This template repo opens that vision up for every Databricks user — no IDE set
| Ship | finishing-branch, git-worktrees |
| Meta | dispatching-agents, writing-skills, using-superpowers |

### BDD Skills (4)

| Category | Skills |
|----------|--------|
| Testing | bdd-features, bdd-run, bdd-scaffold, bdd-steps |

</details>

<details>
<summary><strong>🔌 2 MCP Servers</strong></summary>
<summary><strong>🔌 MCP Servers</strong></summary>

### Built-in MCP Clients

| Server | What it does |
|--------|-------------|
| **DeepWiki** | Ask questions about any GitHub repo — gets AI-powered answers from the codebase |
| **Exa** | Web search and code context retrieval for up-to-date information |

### CoDA MCP Server (exposed at `/mcp`)

CoDA itself exposes an **MCP server** that any MCP-compatible client can connect to — delegate coding tasks to AI agents running on Databricks, without needing the terminal UI.

| Tool | Purpose |
|------|---------|
| `coda_run` | Fire-and-forget: submit a coding task, get back immediately |
| `coda_inbox` | Dashboard: see all running/completed/failed tasks at a glance |
| `coda_get_result` | Pull the full structured result of a completed task |

**Why this matters:** Any tool that speaks MCP can use your Databricks-hosted coding agents — no custom integration needed.

#### Example: Databricks Genie Code

Genie Code connects to CoDA's MCP endpoint and delegates coding work to agents running in the background:

```
User → Genie Code: "Build me a sales pipeline using the transactions table"

Genie Code calls coda_run(prompt="Build a sales pipeline...", email="user@company.com",
context='{"tables": ["sales.transactions"]}')

→ Returns immediately: {task_id: "task-abc", status: "running"}
→ User keeps chatting with Genie Code while the agent works

User → Genie Code: "How's my pipeline coming?"

Genie Code calls coda_inbox()
→ {tasks: [{task_id: "task-abc", status: "completed", summary: "Built pipeline.py..."}]}

Genie Code calls coda_get_result(task_id="task-abc", session_id="sess-123")
→ {summary: "Created pipeline.py with 3 stages", files_changed: ["pipeline.py"], ...}
```

#### Connecting MCP Clients (Claude Code, Claude Desktop, Cursor, etc.)

Databricks Apps use OAuth — not PATs — for authentication. A static `Authorization: Bearer <PAT>` header will get a `302` redirect to the OAuth login page. To connect any MCP client, use the **stdio bridge** (`tools/coda-bridge.py`) which injects fresh OAuth tokens automatically via `databricks auth token`.

**1. Copy the bridge script:**

```bash
mkdir -p ~/.claude/mcp-bridges
cp tools/coda-bridge.py ~/.claude/mcp-bridges/
```

**2. Add to your MCP client settings** (e.g. `~/.claude/settings.json`):

```json
"coda-mcp": {
"type": "stdio",
"command": "python3",
"args": ["/path/to/.claude/mcp-bridges/coda-bridge.py"],
"env": {
"CODA_MCP_URL": "https://your-app.databricksapps.com/mcp",
"DATABRICKS_PROFILE": "your-profile"
}
}
```

**3. Restart your MCP client.**

The bridge reads `CODA_MCP_URL` and `DATABRICKS_PROFILE` from environment — no hardcoded values. If you redeploy the app or switch workspaces, just update the `env` block.

**Prerequisites:** `databricks` CLI installed and authenticated (`databricks auth login -p <profile>`), Python 3.8+, no pip dependencies.

**Troubleshooting:** Bridge logs go to stderr. If you see `Auth failed (302)`, refresh your CLI session with `databricks auth login -p <profile>`. See [full setup guide](docs/mcp-client-setup.md) for details.

#### Task Chaining

Chain tasks by passing `previous_session_id` — the new agent reads the prior task's results for context:

```
coda_run(prompt="Add monitoring to the pipeline", previous_session_id="sess-123")
```

See [MCP v2 Design Doc](docs/mcp-v2-background-execution.md) for the full protocol reference.

</details>

Expand Down Expand Up @@ -238,7 +322,7 @@ This template repo opens that vision up for every Databricks user — no IDE set

1. Gunicorn starts, calls `initialize_app()` via `post_worker_init` hook
2. App serves the terminal UI with inline setup progress
3. Background thread runs setup: 5 sequential steps (git config, micro editor, GitHub CLI, Databricks CLI upgrade, content-filter proxy), then 6 agent setups (Claude, Codex, OpenCode, Gemini, Databricks CLI config, MLflow) run in parallel via `ThreadPoolExecutor`
3. Background thread runs setup: 5 sequential steps (git config, micro editor, GitHub CLI, Databricks CLI upgrade, content-filter proxy), then 6 agent setups (`setup/setup_claude.py`, `setup/setup_codex.py`, etc.) run in parallel via `ThreadPoolExecutor`
4. `/api/setup-status` endpoint reports progress to the UI
5. Once complete, the terminal becomes interactive

Expand All @@ -258,6 +342,7 @@ This template repo opens that vision up for every Databricks user — no IDE set
| `/api/resize` | POST | Resize terminal dimensions |
| `/api/upload` | POST | Upload file (clipboard image paste) |
| `/api/session/close` | POST | Close terminal session |
| `/mcp` | POST | MCP JSON-RPC endpoint (CoDA tools) |

### WebSocket Events (Socket.IO)

Expand Down Expand Up @@ -306,7 +391,7 @@ Production uses `workers=1` (PTY state is process-local), `threads=16` (concurre
coding-agents-databricks-apps/
├── app.py # Flask backend + PTY management + setup orchestration
├── app_state.py # Shared app state (setup progress, session registry)
├── app.yaml.template # Databricks Apps deployment config template
├── app.yaml # Databricks Apps deployment config (gunicorn)
├── cli_auth.py # Interactive PAT setup + CLI credential writer
├── content_filter_proxy.py # Proxy that sanitises empty-content blocks for OpenCode
├── gunicorn.conf.py # Gunicorn production server config
Expand All @@ -315,18 +400,27 @@ coding-agents-databricks-apps/
├── requirements.txt # Compiled from pyproject.toml (Dependabot compatibility)
├── requirements.lock # Hash-pinned lockfile (auto-regenerated by CI)
├── Makefile # Deploy, redeploy, status, and cleanup targets
├── setup_claude.py # Claude Code CLI + MCP configuration
├── setup_codex.py # Codex CLI configuration
├── setup_gemini.py # Gemini CLI configuration
├── setup_opencode.py # OpenCode configuration
├── setup_databricks.py # Databricks CLI configuration
├── setup_mlflow.py # MLflow tracing auto-configuration
├── setup_proxy.py # Content-filter proxy startup
├── sync_to_workspace.py # Post-commit hook: sync to Workspace
├── install_micro.sh # Micro editor installer
├── install_gh.sh # GitHub CLI installer (OS/arch-aware)
├── install_databricks_cli.sh # Databricks CLI upgrade script
├── utils.py # Utility functions (ensure_https)
├── utils.py # Utility functions (ensure_https, gateway discovery)
├── coda_mcp/ # MCP server package (CoDA — Coding Agents)
│ ├── __init__.py
│ ├── mcp_server.py # FastMCP tool definitions (coda_run, coda_inbox, coda_get_result)
│ ├── mcp_endpoint.py # Flask Blueprint: JSON-RPC /mcp endpoint
│ ├── mcp_asgi.py # ASGI bridge (optional, for native MCP SDK transport)
│ └── task_manager.py # Disk-based session/task state manager
├── setup/ # Agent setup scripts (run at boot)
│ ├── setup_claude.py # Claude Code CLI + MCP configuration
│ ├── setup_codex.py # Codex CLI configuration
│ ├── setup_gemini.py # Gemini CLI configuration
│ ├── setup_opencode.py # OpenCode configuration
│ ├── setup_hermes.py # Hermes Agent configuration
│ ├── setup_databricks.py # Databricks CLI configuration
│ ├── setup_mlflow.py # MLflow tracing auto-configuration
│ └── setup_proxy.py # Content-filter proxy startup
├── scripts/ # Shell scripts
│ ├── install_micro.sh # Micro editor installer
│ ├── install_gh.sh # GitHub CLI installer (OS/arch-aware)
│ └── install_databricks_cli.sh # Databricks CLI upgrade script
├── static/
│ ├── index.html # Terminal UI (xterm.js + split panes + WebSocket)
│ ├── favicon.svg # App favicon
Expand All @@ -340,8 +434,12 @@ coding-agents-databricks-apps/
│ └── workflows/
│ ├── dependency-audit.yml # Weekly CVE audit + lockfile drift check
│ └── update-lockfile.yml # Auto-regenerate requirements.lock on push
├── tools/
│ └── coda-bridge.py # Stdio-to-HTTP MCP bridge (OAuth token injection)
└── docs/
├── deployment.md # Full Databricks Apps deployment guide
├── mcp-client-setup.md # MCP client setup guide (bridge config)
├── mcp-v2-background-execution.md # MCP server design doc
├── prd/ # Product requirement documents
└── plans/ # Design documentation
```
Expand Down
Loading