You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@
5
5
- Add `MB_SESSION_TOKEN` as an alternative authentication method for users without admin access to mint an API key; mutually exclusive with `MB_API_KEY` (#9)
6
6
- Document changelog update workflow in `AGENTS.md` and add a pull request template prompting contributors to update `CHANGELOG.md` for user-visible changes (#20)
7
7
- Move main package to `cmd/mb-cli` so `go install github.com/andreagrandi/mb-cli/cmd/mb-cli@latest` produces an `mb-cli` binary that matches the documented command name (#10)
8
+
- Expand PII redaction documentation with covered commands, semantic-type enrichment behavior, known gaps, and export opt-out instructions (#17)
9
+
- Enrich semantic types on non-parameterized `card run` results so PII columns from native saved questions are redacted consistently with the parameterized path (#17)
Copy file name to clipboardExpand all lines: README.md
+50-2Lines changed: 50 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,9 +263,57 @@ The dashboard and parameter workflows use these Metabase endpoints:
263
263
264
264
## PII Redaction
265
265
266
-
When AI agents use mb-cli directly (via shell commands), query results containing PII (emails, names, phone numbers) flow through stdout into the model's context. This feature prevents agents from seeing sensitive data by redacting PII columns before data leaves the client layer. Agents can still cross-reference records using IDs; for actual PII values, the user can check directly in Metabase.
266
+
When AI agents use mb-cli directly (via shell commands), query results containing PII (emails, names, phone numbers) flow through stdout into the model's context. mb-cli prevents that by replacing PII column values with `[REDACTED]` before data leaves the client layer. Agents can still cross-reference records using IDs; for actual PII values, the user can check directly in Metabase.
267
267
268
-
The approach leverages Metabase's own field semantic types (type/Email, type/Name, etc.). Redaction is ON by default — no configuration needed. Users must explicitly opt out with `MB_REDACT_PII=false` or `--redact-pii=false`. This is defense-in-depth: it makes the default path safe. An agent would have to actively choose to bypass it (a visible, auditable action).
268
+
Redaction is **ON by default**. Disabling it is a visible, auditable action: when the flag or env var is set to `false`, mb-cli prints `Warning: PII redaction is disabled` to stderr on every invocation.
269
+
270
+
### What gets redacted
271
+
272
+
Columns whose Metabase field semantic type is one of:
For native SQL results, Metabase does not always populate the semantic type on result columns. mb-cli fills it in by fetching field metadata from the source database and matching by column name. When two fields share a name and disagree, mb-cli picks the PII type (err on the side of caution).
277
+
278
+
### Where redaction applies
279
+
280
+
| Command | Redacted? |
281
+
|---------|-----------|
282
+
|`query sql`| Yes (with column-name enrichment) |
283
+
|`query filter` (MBQL) | Yes |
284
+
|`card run` (with or without `--param`) | Yes (with column-name enrichment) |
|`field values`| Yes, when the field's semantic type is PII |
288
+
289
+
Schema and metadata commands (`database metadata`, `table metadata`, `field get`, etc.) return field definitions, not data, so there is nothing to redact.
290
+
291
+
### Limits and known gaps
292
+
293
+
- Redaction relies on Metabase semantic types. A column holding PII without a semantic type (or with a custom type not in the list above) will not be redacted. Set semantic types in Metabase to close that gap.
294
+
- Derived columns from joins, aggregations, or `CASE` expressions may lose the upstream semantic type. Native SQL enrichment matches by column name only — alias derived columns to match a known PII field name if you want them caught.
295
+
- Free-form `type/Description` fields are not treated as PII; if you store names or emails in description-style columns, set their semantic type explicitly.
296
+
- Redaction operates on result rows, not column headers. Column names like `email` remain visible — values are replaced.
297
+
298
+
### Export behavior
299
+
300
+
When redaction is enabled, the `--export` flag on `query sql` and `query filter` is **blocked** with this error:
301
+
302
+
```
303
+
export is not supported when PII redaction is enabled (use JSON or table format instead)
304
+
```
305
+
306
+
Raw export bytes (CSV/XLSX/JSON straight from Metabase) cannot be post-processed reliably for redaction, so the safe default is to refuse the operation. To export, explicitly opt out of redaction for that invocation:
The `--redact-pii` flag wins if set; otherwise `MB_REDACT_PII` is consulted; otherwise the default is `true`. Any value other than the literal string `false` is treated as enabled.
0 commit comments