Skip to content

MCP plugin core: serve app tools at /mcp - #757

Draft
MarioCadenas wants to merge 5 commits into
mainfrom
work/24-mcp-plugin-core-serve-app-tool
Draft

MarioCadenas wants to merge 5 commits into
mainfrom
work/24-mcp-plugin-core-serve-app-tool

Conversation

@MarioCadenas

Copy link
Copy Markdown
Collaborator

What

MCP plugin core: serve app tools at /mcp

Why

plan step: the plan is written again to /home/mario.cadenas/.paddock-task/appkit-24/plan/plan.md and is waiting for approval. Nothing in the repo has been changed.

It is the recovered plan, checked against current main (e7d16bb, the same commit it was written against). One wrong line reference was fixed: the agents plugins-map builder is at agents.ts:773-794. The pinned MCP SDK versions are still on the registry. The 'Decisions to confirm' section is kept as it was, including decision 7, the Lakebase stopgap.

To confirm when approving:

  1. The two proposed decisions: tokens and scopes, and the error, limit and Origin handling.
  2. The Lakebase stopgap: Lakebase tools inside mcp() run as the App with a startup warning, and runAs: "user" stops startup, until a workspace test shows an Apps-forwarded user token can mint a Lakebase credential.
  3. Keeping mcp({ name }) needs a small factory, because AppKit replaces a plugin config's name with the plugin key.
  4. runAs, scopes and the Lakebase stopgap take effect in mcp() only. In-app agents ignore them.

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 5 commits December 3, 2026 10:03
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>
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>
Adding the MCP SDK re-sorted unrelated entries in package.json. Restore
the original order and keep only the two new exact pins.

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>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle size report

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

@databricks/appkit

npm tarball (packed): 1.4 MB (+10 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).

dist raw gzip
JS (runtime) 1.4 MB (+11 KB) 506 KB (+4.5 KB)
Type declarations 485 KB (+2.5 KB) 175 KB (+1.2 KB)
Source maps 2.8 MB (+21 KB) 939 KB (+8.0 KB)
Other 11 KB 3.7 KB
Total 4.6 MB (+34 KB) 1.6 MB (+14 KB)
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 121 KB (+2.3 KB) 4.5 KB (+2 B) 125 KB (+2.3 KB) external 363 KB (+6.1 KB)
./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 94 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 202 B
./beta databricks.js lazy 187 B
./beta index.js lazy 125 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 3, 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 47090558129 -R databricks/appkit -n appkit-template-0.106.0-pr.0f294ef-work-24-mcp-plugin-core-serve-app-tool-757 -D appkit-pr-757 \
  && unzip -o "appkit-pr-757/appkit-template-0.106.0-pr.0f294ef-work-24-mcp-plugin-core-serve-app-tool-757.zip" -d "appkit-pr-757" \
  && databricks apps init --template "appkit-pr-757"

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, 1 minor, 2 trivial

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

5 findings (2 important, 3 nits). 2 findings (2 important). The MCP endpoint and documentation cover the planned shape, but two verified faults prevent this change from meeting the task: scope-error responses can disclose exception text, and filtering can mutate a provider's cached toolkit. The full acceptance command failed twice in an unchanged database watcher test, while the new MCP tests and docs build passed. The brief's example /xavier-review and /security-review commands were unavailable here.

Important (required)

  • critical: A tool exception containing 'required scopes:' can expose arbitrary trailing exception text to MCP callers. (packages/appkit/src/plugins/mcp/tools.ts:209)
    Proof: A local App-run developer-tool probe threw Error('required scopes: sql PRIVATE TOKEN'); the MCP result was 'Tool "leak" requires user_api_scopes: sql PRIVATE TOKEN.'
  • major: MCP setup removes write tools from a third-party provider's cached toolkit record, breaking later agent use of that record. (packages/appkit/src/plugins/mcp/tools.ts:113)
    Proof: A local probe with a provider returning a cached record showed keys ['sample.read', 'sample.write'] before MCP resolution and only ['sample.read'] afterward.

Nit (not required, below the gate)

  • minor: Security: originGuard compares the Origin with the request's own Host or X-Forwarded-Host, both of which the attacker controls, so a DNS-rebinding page against a local dev server (binds 0.0.0.0 by default) passes the check. It can then call selected runAs:'app' tools with the developer's credentials, and a dummy x-forwarded-access-token skips the dev-OBO loopback check. (packages/appkit/src/plugins/mcp/http.ts:18)
    Proof: Vitest probe in $TMPDIR/sec-review/mcp.probe.test.ts: a node:http POST /mcp with Host 'rebind.attacker.example:PORT' and Origin 'http://rebind.attacker.example:PORT' returned 200 and the tool ran. Read dev-obo-middleware.ts:54-57: when x-forwarded-access-token is present it returns before isLocalRequest. Production behind the Databricks Apps proxy is not affected.
  • trivial: Security: When a tool fails, the text the missing-scope regex captures from the upstream error message is sent back to the MCP client (before this change it went only to the LLM), so any upstream wording in that span reaches the caller. (packages/appkit/src/plugins/mcp/tools.ts:214)
    Proof: Read getRequiredScopes in packages/appkit/src/core/agent/scope-error.ts and its use at tools.ts:209-214. The caller only sees errors from their own request.
  • trivial: Security: Lakebase toolkit tools always run as the App service principal (runAs:'user' is refused), so once a developer opts the tool in, any MCP caller who can reach the App gets the SP's read-only database access. (packages/appkit/src/plugins/mcp/tools.ts:94)
    Proof: Read toolkitIdentity at tools.ts:90-97 and lakebase.ts:251-290 (read-only wrapper, opt-in exposure). This is a documented stopgap with a startup warning, and it mirrors how the agents path already runs Lakebase as the SP.

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