Skip to content

MCP registration command: appkit mcp register - #755

Open
MarioCadenas wants to merge 3 commits into
mainfrom
work/25-mcp-registration-command-appki
Open

MarioCadenas wants to merge 3 commits into
mainfrom
work/25-mcp-registration-command-appki

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

What

MCP registration command: appkit mcp register

Why

The check failed because the shell it runs in had no pnpm, not because of the code. That's fixed, and the check now passes when run exactly the way the board runs it.

  • Why it failed: finish.sh runs the check with plain sh -c on this machine, and that shell couldn't find pnpm. My earlier passing run only worked because I had put a temporary pnpm on PATH.
  • Fix: I ran corepack enable pnpm, the setup step the repo documents. It adds pnpm and pnpx to the Node folder under ~/.nvm. It's machine setup, not a repo change; corepack disable pnpm undoes it.
  • Verified: I re-ran the exact check command with plain sh -c, without my temporary PATH or registry setting. It exited 0: install, lint and format, knip, build, typecheck, and all 10 tests passed. The working tree is clean.
  • New commit: the board checks each commit only once, and the failure is recorded against fa3ee39. I added an empty commit, ed3ecd6, so the check runs again; it changes no code.

The mcp register / mcp unregister work itself is unchanged in fa3ee39. It has still not been run against a real workspace, and the text used to detect a workspace without App sources is still a guess. I updated the closing note with all of this.

Also noticed:

  • apps/dev-playground/client/package-lock.json: pnpm install sometimes rewrites it.
  • knip.json: has old "Remove from ignore" entries.

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

MarioCadenas and others added 2 commits December 2, 2026 22:27
Register an AppKit app as a Unity Catalog MCP Service (config.source_app
-> the app's /mcp) through `databricks api`, so Unity Gateway serves it at
/ai-gateway/mcp-services/<catalog.schema.name>. Creates or updates the
service, grants EXECUTE on it and CAN_USE on the app per --grant, prints
the gateway URL, and explains when the workspace lacks App sources.
`unregister` deletes the service and leaves the app running.

Stopgap until Asset Bundles can declare an App-backed MCP Service; it
lives in commands/mcp/ so it can be deleted in one go.

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
No code change: the previous check failed with `pnpm: not found`
because corepack's pnpm shim was not enabled on the check machine.

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle size report

Compared against bundle-size-baseline.json (main).

@databricks/appkit

npm tarball (packed): 1.3 MB (-45 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.4 MB (-222 B) 501 KB (-19 B)
Type declarations 482 KB 174 KB
Source maps 2.7 MB (-35 B) 931 KB (-22 B)
Other 11 KB 3.7 KB
Total 4.6 MB (-257 B) 1.6 MB (-41 B)
Per-entry composition (own code — deps external (as shipped))
Entry Initial (gz) Lazy (gz) Total (gz) node_modules (min) Own code (min)
. 119 KB (+335 B) 2.4 KB (-1 B) 121 KB (+334 B) external 379 KB (+854 B)
./beta 119 KB (+346 B) 4.5 KB 123 KB (+346 B) external 357 KB (+854 B)
./testing 47 KB (+326 B) 38 KB 85 KB (+326 B) external 247 KB (+854 B)
./tsdown 630 B 0 B 630 B external 1.0 KB
./type-generator 31 KB 0 B 31 KB external 89 KB

Chunks:

Entry Chunk Load Size (gz)
. index.js initial 114 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

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AppKit PR bot

🔬 Run evals

Start an eval for this PR from the evals-monitor app: Go to Evals Monitor →

📦 Try this PR's app template

Scaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh auth login — and the Databricks CLI):

gh run download 46989832372 -R databricks/appkit -n appkit-template-0.106.0-pr.bb18e8e-work-25-mcp-registration-command-appki-755 -D appkit-pr-755 \
  && unzip -o "appkit-pr-755/appkit-template-0.106.0-pr.bb18e8e-work-25-mcp-registration-command-appki-755.zip" -d "appkit-pr-755" \
  && databricks apps init --template "appkit-pr-755"

The template pins @databricks/appkit and @databricks/appkit-ui to tarballs built from this branch, so the scaffolded app runs against this PR's code.

@MarioCadenas

Copy link
Copy Markdown
Collaborator Author

Review 1 · Fail · 1 critical, 1 major, 2 minor, 1 trivial, 1 pre-existing

Does the change do what the task asked? No. Gate: major and worse must be fixed.

6 findings (2 important, 3 nits, 1 pre-existing). 3 findings (2 important, 1 nit). The repository check passes, but re-registering can remove existing service rate limits and an accepted malformed unregister name can delete a different service. Bundle variable app names also reach the API unresolved. The brief mentions /xavier-review, /ponytail-review, and /security-review; those exact commands were unavailable here.

Important (required)

  • critical: Re-registering an existing MCP Service silently clears its rate limits. (packages/shared/src/cli/commands/mcp/register.ts)
    Proof: The installed CLI v1.28.0 update help says config replacement clears omitted optional fields; rate_limits is optional, and the PATCH body omits it.
  • major: Unregister accepts a fragment-suffixed name and deletes the service named before the fragment. (packages/shared/src/cli/commands/mcp/databricks-cli.ts and packages/shared/src/cli/commands/mcp/unregister.ts)
    Proof: Running the built CLI with main.default.my_app#oops against a localhost fake API printed success for that full input, while the server received DELETE /api/2.1/unity-catalog/mcp-services/main.default.my_app.

Nit (not required, below the gate)

  • minor: A valid interpolated app name in databricks.yml is sent literally instead of resolving to the deployed app name. (packages/shared/src/cli/commands/mcp/register.ts)
    Proof: With databricks.yml containing name: ${var.app_name}, the built CLI sent source_app.name as the literal string ${var.app_name} to a fake Databricks executable.
  • minor: Security: The app name read from an untrusted databricks.yml (or --app) is put unvalidated and unencoded into the databricks api patch /api/2.0/permissions/apps/${app} path, so a name like ../../sql/warehouses/<id>?x= sends the CAN_USE grant for the user's --grant principals to a different endpoint if the server collapses .. (the fqn is likewise interpolated raw, but parseFqn blocks .. and the fqn i (packages/shared/src/cli/commands/mcp/register.ts:122)
    Proof: Ran the real command via tsx with a fake databricks on PATH and a hostile databricks.yml in cwd: recorded argv was ["api","patch","/api/2.0/permissions/apps/../../sql/warehouses/abc123?x=","--json","{"access_control_list":[{"group_name":"users","permission_level":"CAN_USE"}]}",...]; the real Databricks CLI v1.28.0 sent that path verbatim (no .. normalisation) to a local stub server. Not shown: whether the Databricks front end normalises .., or whether the earlier create/patch with a bogus source_app.name fails first and aborts the grants.
  • trivial: Security: On Windows, the bare name databricks given to execFile is looked up in the current directory before PATH, so running the command inside an untrusted checkout that contains databricks.exe would run that binary. (packages/shared/src/cli/commands/mcp/databricks-cli.ts:16)

Pre-existing (not required, there before this change)

  • minor: Security: The CLI loads the cwd .env into process.env at startup, and the new databricks child process inherits it, so a .env planted in a checkout can steer the spawned CLI (e.g. HTTPS_PROXY plus SSL_CERT_FILE, or DATABRICKS_CONFIG_PROFILE/DATABRICKS_HOST to aim the grant or delete at another workspace). (packages/shared/src/cli/index.ts:2)
    Proof: Ran appkit mcp unregister a.b.c from a dir whose .env sets HTTPS_PROXY, SSL_CERT_FILE and DATABRICKS_HOST: the fake databricks recorded all three in its environment. With the real CLI, DATABRICKS_HOST alone did not send the profile token to the other host. import "dotenv/config" dates from af8ebbf (2026-02-25); this change only adds one more child that inherits it.

- Re-registering an existing MCP Service now carries over its
  include_tool_selectors and rate_limits; `update_mask=config` replaces
  the whole config, so they were silently cleared before.
- Service names are URL-encoded per part, so a `#` or `?` in the name
  can no longer truncate the path and hit a different service.
- App names must be lowercase letters, digits and hyphens, which stops
  path tricks in the permissions URL and unresolved `${var...}` names
  from databricks.yml (the error says to pass --app).

Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@MarioCadenas

Copy link
Copy Markdown
Collaborator Author

Review 2 · Pass · 1 trivial

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 round 2 changes preserve existing service rate limits and selectors, encode service names for API requests, and reject unresolved bundle app names with --app guidance; the repository gate passes. The exact /xavier-review, /ponytail-review, and /security-review commands were unavailable here.

Nit (not required, below the gate)

  • trivial: Security: On Windows, the bare name databricks given to execFile is looked up in the current directory before PATH, so running appkit mcp register/unregister inside an untrusted checkout that contains databricks.exe would run that binary. (packages/shared/src/cli/commands/mcp/databricks-cli.ts:16)
    Proof: Read databricks-cli.ts at f6688d6: lines 16 and 43 still call execFile("databricks", args, ...) with no absolute path or cwd. The fix commit only added encodeFqn/servicePath to this file. libuv's Windows search_path checks the current directory before PATH for a bare filename. Not run on Windows. The same bare-name pattern already exists in registry/config-writer.ts:291 and registry/workspace-picker.ts:213 (spawnSync("databricks", ...)).

@MarioCadenas
MarioCadenas marked this pull request as ready for review December 2, 2026 23:06
@MarioCadenas
MarioCadenas requested a review from a team as a code owner December 2, 2026 23:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant