Repository navigation
feat(appkit): expose named analytics queries as tools - #756
MarioCadenas wants to merge 3 commits into
Conversation
…gen keys - `:name` inside `/* ... */` is no longer read as a parameter or replaced during DESCRIBE. - Typegen keeps `x.obo.sql` when `x.sql` also exists, matching the runtime, and warns instead of emitting the key twice. - Query keys that aren't valid identifiers (e.g. `my-query`) are quoted in the generated declarations. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
`plugins.analytics.queries({ only })` turns each `config/queries/*.sql`
file into a `query.<name>` tool in the `toolkit()` entry shape, so agents
(and the upcoming MCP plugin) can use them.
- `-- @description` and `-- @PARAM name TYPE [description]` comments are
read at runtime and give the tool its description and JSON Schema; every
parameter is required and untyped ones are strings.
- `.sql` tools run as the app even inside a caller scope; `.obo.sql` tools
run as the caller and are refused without one (except the existing dev
fallback).
- Every query tool is `effect: "read"`; files that fail the read-only SQL
check are refused. Results are capped at 100 rows with a note.
- New `analytics.runQuery(name, params?, signal?)` runs a named query in
process and returns its rows. The HTTP route's JSON path and the tools
share its execution core, cache keys unchanged.
- Docs: "Named queries as tools" in the analytics plugin page.
Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 1.4 MB (+8.1 KB) | 504 KB (+2.8 KB) |
| Type declarations | 483 KB (+1.1 KB) | 174 KB (+277 B) |
| Source maps | 2.7 MB (+17 KB) | 936 KB (+5.6 KB) |
| Other | 11 KB | 3.7 KB |
| Total | 4.6 MB (+26 KB) | 1.6 MB (+8.7 KB) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
120 KB (+2.0 KB) | 2.4 KB | 123 KB (+2.0 KB) | external | 384 KB (+5.1 KB) |
./beta |
119 KB (+372 B) | 4.5 KB | 123 KB (+372 B) | external | 357 KB (+932 B) |
./testing |
47 KB (+326 B) | 39 KB (+149 B) | 85 KB (+475 B) | external | 247 KB (+1.2 KB) |
./tsdown |
630 B | 0 B | 630 B | external | 1.0 KB |
./type-generator |
31 KB (+179 B) | 0 B | 31 KB (+179 B) | external | 90 KB (+350 B) |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 116 KB |
. |
utils.js |
initial | 4.6 KB |
. |
remote-tunnel-manager.js |
lazy | 2.4 KB |
./beta |
beta.js |
initial | 92 KB |
./beta |
stream-manager.js |
initial | 5.9 KB |
./beta |
define-schema.js |
initial | 5.8 KB |
./beta |
service-context.js |
initial | 4.3 KB |
./beta |
modular.js |
initial | 3.6 KB |
./beta |
databricks.js |
initial | 3.3 KB |
./beta |
wide-event-emitter.js |
initial | 2.8 KB |
./beta |
client.js |
initial | 645 B |
./beta |
index.js |
initial | 20 B |
./beta |
index.js |
lazy | 4.0 KB |
./beta |
supervisor-api.js |
lazy | 201 B |
./beta |
databricks.js |
lazy | 187 B |
./beta |
index.js |
lazy | 124 B |
./testing |
manifest.js |
initial | 34 KB |
./testing |
index.js |
initial | 10 KB |
./testing |
wide-event-emitter.js |
initial | 2.9 KB |
./testing |
index.js |
lazy | 34 KB |
./testing |
remote-tunnel-manager.js |
lazy | 2.4 KB |
./testing |
utils.js |
lazy | 1.8 KB |
./tsdown |
index.js |
initial | 630 B |
./type-generator |
index.js |
initial | 31 KB |
@databricks/appkit-ui
npm tarball (packed): 396 KB — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 433 KB | 147 KB |
| Type declarations | 251 KB | 93 KB |
| Source maps | 843 KB | 283 KB |
| CSS | 16 KB | 3.2 KB |
| Total | 1.5 MB | 527 KB |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
5.3 KB | 49 KB | 55 KB | 208 KB | 14 KB |
./js/beta |
2.4 KB | 0 B | 2.4 KB | 0 B | 5.3 KB |
./react |
442 KB | 49 KB | 490 KB | 1.4 MB | 181 KB |
./react/beta |
13 KB | 0 B | 13 KB | 25 KB | 13 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 5.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 2.4 KB |
./react |
index.js |
initial | 439 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 13 KB |
|
Review 1 · Pass · 1 minor Does the change do what the task asked? Yes. Gate: major and worse must be fixed. 1 finding (1 nit): nothing needs fixing. No findings: nothing needs fixing. The change meets the approved plan in the paths reviewed. The required check passed, including 81 test files and 1905 tests; I found no confirmed faults. Nit (not required, below the gate)
|
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 47083618341 -R databricks/appkit -n appkit-template-0.106.0-pr.456e64c-work-26-named-analytics-queries-as-mcp-756 -D appkit-pr-756 \
&& unzip -o "appkit-pr-756/appkit-template-0.106.0-pr.456e64c-work-26-named-analytics-queries-as-mcp-756.zip" -d "appkit-pr-756" \
&& databricks apps init --template "appkit-pr-756"The template pins |
|
Review 2 · Pass · 2 minor, 3 pre-existing Does the change do what the task asked? No. Gate: major and worse must be fixed. 5 findings (2 nits, 3 pre-existing): nothing needs fixing. 1 finding (1 nit): nothing needs fixing. The named-query tools, identity paths, docs, and required repository check work as planned, but the new timestamp tool schema accepts impossible calendar values and sends them to the warehouse. This is a minor input-validation fault. The brief names /xavier-review and /security-review, which are unavailable here; /ponytail-review was available and used. Nit (not required, below the gate)
Pre-existing (not required, there before this change)
|
|
Review 3 · Pass · 2 pre-existing Does the change do what the task asked? Yes. Gate: major and worse must be fixed. 2 findings (2 pre-existing): nothing needs fixing. No findings: nothing needs fixing. The change meets the approved plan in the paths reviewed, and the required repository check passed. I found no new confirmed fault. The brief names /xavier-review and /security-review, which are unavailable here; I used /ponytail-review. Pre-existing (not required, there before this change)
|
What
Named analytics queries as MCP tools
Why
I've fixed the check failure. It was never the code: the check stopped at
sh: 1: pnpm: not found, because this wiped machine had nopnpmwhere the turn-end hook looks for it.corepack enable pnpm. It adds apnpmshim to the nvm node folder, which is on the hook's PATH.corepack disable pnpmremoves it.chore: re-run the check now that pnpm is on the check shell's PATH, to make it run again. did the same for the same problem.The board had taken away the earlier closing note, so I rewrote it in full with this fix added.
Also noticed:
NPM_CONFIG_REGISTRYsetting. Apnpm installthat has to download anything would go to the blocked public registry. Today's check didn't need to, because everything was already installed.How it was verified
pnpm install --frozen-lockfile && pnpm run check && pnpm run knip && pnpm build && pnpm run typecheck && pnpm vitest run --changed "$(git merge-base HEAD origin/main)"passed.Screenshots
None
Notes
None