Skip to content

Superset MCP integration + Guardian Connector skills - #7

Merged
luandro merged 9 commits into
masterfrom
librechat
Oct 15, 2026
Merged

luandro merged 9 commits into
masterfrom
librechat

Conversation

@luandro

@luandro luandro commented Oct 15, 2026

Copy link
Copy Markdown

What

Two things ship, both behind existing optional switches — an install that leaves
them at their defaults behaves exactly as before.

1. The Superset 6.1.0 MCP integration (scripts/superset_dashboard_ctl.py,
scripts/superset_mint_mcp_token.py, docs/librechat-integrations.md §1,
docs/production-runbook.md). A REST helper for the actions MCP 6.1.0 cannot
reach, plus a runbook for the access it needs.

2. Guardian Connector skills and starter prompts (off by default,
GC_SKILLS_ENABLED=0). The api app writes a deployment-skills directory and
seeds the matching prompt groups.

Verified, not assumed

Every Superset claim is checked against the 6.1.0 source tag, and
test/superset-e2e/ is the live stack that produced the evidence — 24 tools,
agent identity 16/0, cross-role ownership refused 3/0 in both directions,
REST helper 24/0, memory bounded (+2.5 MiB over 200 calls, returning to baseline
after restart).

tls_check.sh closes the one gap the docs admitted: the full helper suite now
passes over https://localhost:18443, which is the URL shape operators use.

Run it yourself: test/superset-e2e/run.sh (then --destroy, or teardown.sh).
Teardown asserts CLEAN — no containers, volumes, images or generated TLS keys.

Fixes carried in

Round 2 of an independent review found three defects the contract tests had
enshrined rather than caught. The ancestor chain is written ROOT-first (the
frontend's updateComponentParentsList descends from ROOT_ID, and
findTabIndexByComponentId walks it as a path — the old order broke tab
navigation). The dataset-dependants guard misread
{"charts": {"count": N, ...}} as a list and invented dependants, and a failed
lookup fell through to the DELETE; it now parses count/result and fails
closed. delete-chart could strip a chart from another user's dashboard via
dashboard_slices.slice_id ON DELETE CASCADE; it now reads the containing
dashboards and refuses.

Risk

Low, and bounded:

  • Both integrations are opt-in; empty vars leave the template byte-identical.
  • The GC provisioner never blocks startup — failures print
    GC_PROVISION_DEGRADED and chat starts.
  • No Superset object is written during registry deploy or rollback.

Before merge

CI runs the full suite: template byte-equality, validate_apps, the GC matrix,
and the Superset helper contract tests.

…lper

An independent audit of the apache/superset 6.1.0 tag showed several earlier
conclusions were wrong. Everything here was re-verified against the tag itself
(1176 .py files downloaded and grepped), not the "Next" docs, which describe 7.x.

Corrections to the documented model:
- there is no raise_for_editorship in 6.1.0: ownership is the only object-level
  boundary, and it is checked identically over MCP and REST
- there is no SOFT_DELETE: chart/dashboard/dataset deletes are permanent
- MCP_DISABLED_TOOLS does not exist in this tag, so it can never narrow the
  tool surface; the FAB role is the only control
- MCP_REQUIRED_SCOPES is a global JWT admission gate, not a per-tool one, so
  "mcp:read" does not make a token read-only
- 24 native tools, not 22; get_dashboard_data is not among them
- search results are not permission-filtered: a visible tool is not authorised
- default_user_resolver exists but is dead code; MCP_USER_RESOLVER is 7.x

scripts/superset_dashboard_ctl.py (new): narrow semantic REST helper for the
operations 6.1.0 MCP cannot do (rename/describe, tabs, detach a chart, native
filters, deletes). It preflights nothing and authorises nothing - Superset's
raise_for_ownership is the backstop - because the REST GETs expose no username
to compare against. It carries existing json_metadata through every layout write,
goes through json_metadata.positions so detaching a chart also updates the
dashboard_slices M2M, and verifies the result afterwards.

Verified against a live 6.1.0 stack (local Docker): role grants, ownership
denials, CSRF handshake, and every helper command. Two findings from that run are
now encoded as contract tests and documented: the CSRF token must be fetched
before the Cookie header is built (its response re-issues the session cookie),
and the cookie must be replayed by hand because Superset marks it Secure and
urllib drops Secure cookies over plain http://.

Memory: 800 read-only calls take the MCP process from 278 to 297 MiB, and a
restart returns it to 285 and re-traces the same curve - cache warm-up, not a
leak. Recorded in docs section 8 with what was NOT verified (HTTPS, RLS,
concurrent load).
…the e2e harness repeatable

Round 2 of an independent Codex audit found three real defects the contract tests
did not catch, plus a suite that largely asserted source text.

BLOCKERs:
- Ancestor chains were written innermost-parent-first. The frontend's
  updateComponentParentsList descends from ROOT_ID appending each id, so the
  stored order is ROOT-first; findTabIndexByComponentId walks it as a path. Every
  layout write was reversing it, which breaks tab navigation. Fixed, and the test
  that had enshrined the wrong order is corrected to the tag's contract.
- The dataset-dependants guard misread the response. related_objects answers
  {"charts": {"count": N, "result": [...]}}, so reading `charts` as a list got a
  truthy dict and invented dependants; and a 403/404/500 lookup fell through to
  the DELETE. Now parses count/result and fails closed.
- delete-chart could damage another user's object. dashboard_slices.slice_id is
  ON DELETE CASCADE, and DeleteChartCommand checks chart ownership only, so
  deleting an owned chart stripped it from any dashboard, including someone
  else's. It now reads the containing dashboards from the chart GET and refuses.

RISKs addressed:
- _verify now takes an expected chart set declared by the caller BEFORE the
  transform, so a transformation that loses a subtree cannot validate itself.
  It also checks ROOT reachability, valid ROOT-first chains, and the version
  marker.
- _attach_chart no longer silently reuses a CHART-<id> component that holds a
  different chart.
- Documentation overclaims corrected: a 403 is not always ownership, _verify
  inspects the stored layout rather than dashboard.slices, the description is
  refused (not "before any request"), and the live run did not cover
  delete-dashboard/delete-dataset. Section 8.5 records the three accepted
  residual risks as explicit policy.

Tests: the contract suite now exercises behaviour instead of matching strings -
the three BLOCKERs above each have a behavioural case that fails if the fix is
reverted, including fail-closed behaviour for every failed lookup.

Also adds test/superset-e2e: the harness used for the live verification, now
reproducible and teardown-safe, so a stale pgdata volume can no longer break the
next run.
…to end

Running the harness surfaced four defects in the harness itself, now fixed:

- seed.py created the Database without a sqlalchemy_uri, which dbs rejects
  (NOT NULL). It now points at the stack's own Postgres.
- seed.py left the dataset with no columns, so generate_chart rejected every
  column reference. It now calls fetch_metadata, and repairs an existing fixture
  that has no columns rather than skipping it.
- rest_checks.py depended on a fixture from an earlier run and on the empty
  argument guard firing before the description refusal. The fixture is now
  provisioned through the agent's MCP tools when none exists, the description
  check passes a title too so it exercises the refusal, and the dataset case
  asserts the ownership refusal that is the real property being tested.
- memory_check.py crashed in the restart window: RemoteDisconnected is not a
  URLError, so wait_ready() could not survive the process coming back up. It now
  catches the connection errors and retries.

Verified against the live stack: 24 MCP tools registered; the agent identity
passed 16 read/write/deny checks; cross-role ownership refused in both
directions; the REST helper passed 24 checks including the shared-chart delete
guard added for the round-2 audit. Memory: +3.9 MiB over 200 read-only calls,
returning to 279.5 MiB after restart and re-tracing the same curve - bounded
cache warm-up, not a leak.

Teardown verified clean: no containers, volumes, images or scratch files left.
Four defects in the harness itself, each found by running it and each now
prevented:

- The seed left the fixture table uncommitted when fetch_metadata ran.
  fetch_metadata inspects through the Database's own engine, so an uncommitted
  DDL is invisible to that connection: NoSuchTableError on a table the seed
  session could see. The table is committed before the inspect now.
- The dataset was registered with schema="public" and the connection's default
  catalog. On Postgres the default catalog is the *database* name, so the
  identifier resolved as `superset.public.e2e_frota` (InvalidSchemaName), and
  `schema='public'` on its own made the inspector raise NoSuchTableError. Both
  are None now, which is what the search_path already resolves to - verified
  against 6.1.0 by trying each combination.
- A stale seed.py could run silently: the copy used `|| true`, so a failed cp
  left the container executing the version baked into the image build. That
  happened and is why a fixture looked right locally but failed in the harness.
- A leftover pgdata volume was reused when its container still held it: the
  removal was swallowed, and `superset db upgrade` died with a duplicate key on
  ab_permission_id_seq. run.sh now removes the holder first and fails loudly
  rather than proceeding on a dirty database.

New: tls_check.sh. docs/librechat-integrations.md 8.4 lists HTTPS as not
verified, and the helper's CSRF/session handshake plus Superset's Referer check
are both TLS-sensitive, so the plain-http runs are not evidence for the URL
shape operators use. nginx terminates a self-signed cert in front of the stack
and the full REST helper suite runs against https, with the CSRF and Referer
outcomes asserted as real calls rather than string matches.

The harness now passes end to end from a clean slate: 24 tools, agent 16/0,
cross-role 3/0, REST helper 24/0, memory bounded (+2.5 MiB over 200 calls).

Also adds docs/production-runbook.md: the preconditions, the two roles and their
boundaries, the smoke test that must run against the production Superset before
any user does, the deploy/rollback path, and the six limits to state at go/no-go.
Section 8.4 of the integrations guide said HTTPS was unverified. It no longer
is: tls_check.sh puts nginx in front of the e2e stack terminating a self-signed
cert and runs the full REST helper suite against https. The helper verifies the
certificate chain, so this also confirms it refuses a cert it cannot trust - the
correct behaviour in production, and the reason the harness needs the cert's CA
rather than an insecure skip.

Result: 24/24 over https, with the login handshake, the X-CSRFToken + Secure
cookie path and the Referer check asserted as real calls rather than string
matches. The doc now records what that proves and what it does not (a
publicly-trusted issuer and a real edge proxy).

The cert is a throwaway artefact, so certs/ is gitignored and always generated
at run time - a private key never belongs in the repository. teardown.sh removes
it, knows the TLS container, and its steps are renumbered (a step 3 had gone
missing). The last run also asserted CLEAN: no containers, volumes, images or
certs remaining.

Runbook updated to match: HTTPS moved from "unverified" to "covered locally",
with the honest boundary kept in the go/no-go list.
…pts at boot

Off by default, and reversible with one env value. The api app writes a skills
directory that LibreChat reads as deployment skills, and seeds the matching
starter prompt groups in MongoDB.

Content lives in one place per family:
- skills/gc/<family>/SKILL.md - the skill the model reads
- skills/gc/prompts/<family>.md - the starter prompts for that family
- scripts/librechat-boot.sh - the provisioner, generated by
  gc_skills_bundle.sh so the shipped command array is byte-identical to the
  source the tests read (asserted by sync_librechat_boot.js)

Boundaries, enforced or documented:
- gc_main always returns 0. A failure prints GC_PROVISION_DEGRADED with the
  named area and chat starts; it never blocks startup.
- No users row is created. The seeded prompts carry a fixed synthetic author id
  so LibreChat's first-user admin bootstrap (countUsers() === 0) still makes the
  first real account an ADMIN. Each group also gets an owner ACL row for that
  synthetic id so owner-scoped checks resolve.
- Skills describe the Superset tools; they grant nothing. Access is decided by
  the Superset role of the MCP process, and the docs say so.
- Starter prompts are public to every signed-in account, which is why the
  section tells the operator to set ALLOW_REGISTRATION=false first.
- Operator edits survive: an edited skill file is kept and reported rather than
  overwritten, and an edited prompt group is kept and reported as a conflict.

Local checks: cold seed creates 15 groups, repeat seed is a no-op, groups are
public with permBits 1, disable removes the unchanged managed groups, an
invalid switch still starts chat, and MongoDB down at boot still starts chat
after the 90-second wait. These run inside the existing
`node scripts/test_librechat_config.js` path, so CI covers them.

Not verified: production, a chat that completes a seeded prompt through the
model, and a live Superset write - all three need the deployment itself.
`package.json` requests yaml@1.10.3 but the lockfile pinned 1.10.2, so every CI
run failed at the install step before reaching a single test:
"lock file's yaml@1.10.2 does not satisfy yaml@1.10.3".

Verified by removing node_modules and running the exact CI command
(npm ci && node scripts/validate_apps.js && npx prettier --check && bash
scripts/test_librechat_config.sh): clean install, validate, format and the
config/GC suite all pass.
@socket-security

socket-security Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedyaml@​1.10.2 ⏵ 1.10.3100100 +210088100

View full report

CI failed with EACCES unlink '/tmp/gc-test-skills-*/.gc-state/seed.json' after
every GC check had already passed. The containers run as the image's user (root)
and write into bind-mounted tmpdirs, so on a non-root host the cleanup rmSync
hits files it does not own and throws, taking the run down with exit 1.

The first fix, injecting --user into every docker run, was wrong: the pinned
image writes to /app/api/logs and /app/skills, so running as a non-root uid
turned every check into EACCES. Reverted, and the real shape of the problem is
addressed instead - a leftover tmpdir is noise, not a failure of the behaviour
under test, so rmDir reports it and the run continues.

Verified locally with both halves: the static/boot checks and the live Mongo
seeding all pass, and a forced cleanup failure now prints a note instead of
aborting.
@luandro
luandro merged commit 6fa1881 into master Oct 15, 2026
4 checks passed
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