@lightdash-tools/mcp 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -22
- package/dist/audit/server-profile.d.ts +13 -0
- package/dist/audit/server-profile.js +28 -0
- package/dist/audit/server-profile.test.js +21 -0
- package/dist/auth/oauth-broker/pending-store.test.d.ts +1 -1
- package/dist/auth/oauth-broker/pending-store.test.js +1 -1
- package/dist/auth/request-state-key.d.ts +2 -2
- package/dist/auth/request-state-key.js +2 -2
- package/dist/auth/resource-server/lightdash-oauth-middleware.d.ts +1 -1
- package/dist/auth/resource-server/lightdash-oauth-middleware.js +1 -1
- package/dist/auth/resource-server/lightdash-oauth-middleware.test.js +14 -14
- package/dist/auth/resource-server/oauth-protected-resource.d.ts +6 -6
- package/dist/auth/resource-server/oauth-protected-resource.js +8 -8
- package/dist/auth/resource-server/token-scopes.d.ts +1 -1
- package/dist/auth/resource-server/token-scopes.js +1 -1
- package/dist/auth/resource-server/www-authenticate.test.js +11 -11
- package/dist/bin.js +54 -58
- package/dist/config/env.d.ts +3 -1
- package/dist/config/env.js +4 -2
- package/dist/config/load-mcp-config.js +8 -36
- package/dist/config/load-mcp-config.test.js +8 -2
- package/dist/config/normalize-url.d.ts +1 -1
- package/dist/config/normalize-url.js +1 -1
- package/dist/config/normalize-url.test.js +16 -16
- package/dist/config/obsolete-env.d.ts +5 -0
- package/dist/config/obsolete-env.js +48 -0
- package/dist/config/obsolete-env.test.js +22 -0
- package/dist/config/runtime.js +1 -1
- package/dist/governance/available-projects.d.ts +1 -1
- package/dist/governance/available-projects.js +1 -1
- package/dist/governance/mcp-post-factory-context.d.ts +15 -0
- package/dist/governance/mcp-post-factory-context.js +22 -0
- package/dist/governance/mcp-post-factory-context.test.js +34 -0
- package/dist/http.integration.test.js +11 -15
- package/dist/index.d.ts +5 -1
- package/dist/index.js +29 -16
- package/dist/policy/content-reader.d.ts +10 -5
- package/dist/policy/content-reader.js +23 -9
- package/dist/policy/content-reader.test.js +4 -3
- package/dist/policy/envelope.d.ts +4 -2
- package/dist/policy/envelope.js +2 -2
- package/dist/policy/envelope.test.d.ts +1 -0
- package/dist/policy/envelope.test.js +28 -0
- package/dist/profiles/ai-agent-ops/v1/index.d.ts +6 -0
- package/dist/profiles/ai-agent-ops/v1/index.js +20 -0
- package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/loop-engineering.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/release-gate.md +1 -1
- package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.js +4 -4
- package/dist/profiles/content-developer/v1/index.d.ts +8 -0
- package/dist/profiles/content-developer/v1/index.js +22 -0
- package/dist/{personas → profiles}/content-developer/v1/prompts.js +6 -6
- package/dist/{personas → profiles}/content-developer/v1/prompts.test.js +61 -6
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/chart-types.md +31 -16
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/core.md +9 -5
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboard-design.md +3 -3
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/dashboards.md +12 -7
- package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.js +4 -2
- package/dist/profiles/content-governance/v1/index.d.ts +7 -0
- package/dist/profiles/content-governance/v1/index.js +21 -0
- package/dist/{personas → profiles}/content-governance/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/core.md +2 -2
- package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.js +4 -4
- package/dist/profiles/content-reader/v1/index.d.ts +6 -0
- package/dist/profiles/content-reader/v1/index.js +20 -0
- package/dist/{personas → profiles}/content-reader/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/core.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/discover.md +1 -1
- package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.js +2 -2
- package/dist/profiles/data-analyst/v1/index.d.ts +6 -0
- package/dist/profiles/data-analyst/v1/index.js +20 -0
- package/dist/profiles/data-analyst/v1/prompts.d.ts +5 -0
- package/dist/profiles/data-analyst/v1/prompts.js +41 -0
- package/dist/profiles/data-analyst/v1/prompts.test.d.ts +4 -0
- package/dist/profiles/data-analyst/v1/prompts.test.js +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/core.md +41 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/explore.md +26 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks/index.md +8 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.d.ts +10 -0
- package/dist/profiles/data-analyst/v1/resources/playbooks.js +33 -0
- package/dist/profiles/index.d.ts +24 -0
- package/dist/profiles/index.js +73 -0
- package/dist/profiles/index.test.d.ts +1 -0
- package/dist/profiles/index.test.js +121 -0
- package/dist/{personas → profiles}/lib/playbook-resources.d.ts +8 -7
- package/dist/{personas → profiles}/lib/playbook-resources.js +15 -15
- package/dist/profiles/organization-audit/v1/index.d.ts +6 -0
- package/dist/profiles/organization-audit/v1/index.js +20 -0
- package/dist/{personas → profiles}/organization-audit/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.js +2 -2
- package/dist/profiles/profile.membership.test.d.ts +1 -0
- package/dist/profiles/profile.membership.test.js +36 -0
- package/dist/profiles/semantic-layer/v1/index.d.ts +6 -0
- package/dist/profiles/semantic-layer/v1/index.js +19 -0
- package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.js +2 -2
- package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.js +2 -2
- package/dist/profiles/types.d.ts +18 -0
- package/dist/{personas → profiles}/types.js +1 -1
- package/dist/protocol-contract.test.js +48 -3
- package/dist/server/capabilities.d.ts +6 -6
- package/dist/server/capabilities.js +11 -10
- package/dist/server/capabilities.test.js +8 -9
- package/dist/server/server.js +7 -7
- package/dist/stdio.process.test.js +61 -7
- package/dist/tools/ai-agents/agents.d.ts +1 -1
- package/dist/tools/ai-agents/agents.js +1 -1
- package/dist/tools/ai-agents/evaluations.d.ts +1 -1
- package/dist/tools/ai-agents/evaluations.js +1 -1
- package/dist/tools/ai-agents/helpers.d.ts +2 -3
- package/dist/tools/ai-agents/helpers.js +2 -4
- package/dist/tools/ai-agents/threads.d.ts +1 -1
- package/dist/tools/ai-agents/threads.js +1 -1
- package/dist/tools/composition/explain-content.js +3 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.test.js +16 -10
- package/dist/tools/lib/schema-fields.d.ts +2 -0
- package/dist/tools/lib/schema-fields.js +4 -1
- package/dist/tools/lib/stable-stringify.d.ts +1 -1
- package/dist/tools/lib/stable-stringify.js +1 -1
- package/dist/tools/organization/invariants.test.d.ts +1 -1
- package/dist/tools/organization/invariants.test.js +5 -5
- package/dist/tools/project/developer-content-preview.d.ts +1 -1
- package/dist/tools/project/developer-content-preview.js +1 -1
- package/dist/tools/project/developer-content-shared.d.ts +1 -1
- package/dist/tools/project/developer-content-shared.js +1 -1
- package/dist/tools/project/developer-get-chart-as-code.test.js +1 -1
- package/dist/tools/project/invariants.test.d.ts +1 -1
- package/dist/tools/project/invariants.test.js +8 -8
- package/dist/tools/project/parameters.js +8 -3
- package/dist/tools/project/projects.d.ts +1 -4
- package/dist/tools/project/projects.js +32 -12
- package/dist/tools/project/projects.test.js +30 -7
- package/dist/tools/project/reader-content.js +6 -3
- package/dist/tools/project/reader-execution.js +4 -2
- package/dist/tools/project/reader-export-chart-image.js +1 -1
- package/dist/tools/project/reader-export-chart-image.test.js +2 -2
- package/dist/tools/project/spaces.js +12 -4
- package/dist/tools/project/spaces.test.d.ts +1 -0
- package/dist/tools/project/spaces.test.js +47 -0
- package/dist/tools/query/bounded-saved-query.d.ts +4 -3
- package/dist/tools/query/bounded-saved-query.js +3 -5
- package/dist/tools/query/lifecycle.js +10 -8
- package/dist/tools/query/query-ledger.d.ts +2 -1
- package/dist/tools/query/reader-tool-helpers.d.ts +4 -2
- package/dist/tools/query/reader-tool-helpers.js +7 -2
- package/dist/tools/query/run-metric-query.d.ts +6 -0
- package/dist/tools/query/run-metric-query.js +94 -0
- package/dist/tools/query/run-metric-query.test.d.ts +4 -0
- package/dist/tools/query/run-metric-query.test.js +116 -0
- package/dist/tools/registry.d.ts +8 -8
- package/dist/tools/registry.js +10 -6
- package/dist/tools/semantic/explores.js +43 -17
- package/dist/tools/semantic/metrics.js +22 -8
- package/dist/tools/semantic/query.js +25 -17
- package/dist/tools/shared.d.ts +1 -1
- package/dist/tools/shared.js +5 -5
- package/dist/tools/shared.test.js +4 -4
- package/dist/transports/streamable-http.js +46 -36
- package/dist/transports/streamable-http.test.js +9 -9
- package/package.json +5 -5
- package/dist/audit/server-persona.d.ts +0 -10
- package/dist/audit/server-persona.js +0 -19
- package/dist/governance/client-capabilities-cache.d.ts +0 -44
- package/dist/governance/client-capabilities-cache.js +0 -142
- package/dist/governance/client-capabilities-cache.test.js +0 -148
- package/dist/personas/ai-agent-ops/v1/index.d.ts +0 -8
- package/dist/personas/ai-agent-ops/v1/index.js +0 -41
- package/dist/personas/content-developer/v1/index.d.ts +0 -10
- package/dist/personas/content-developer/v1/index.js +0 -52
- package/dist/personas/content-governance/v1/index.d.ts +0 -9
- package/dist/personas/content-governance/v1/index.js +0 -29
- package/dist/personas/content-reader/v1/index.d.ts +0 -8
- package/dist/personas/content-reader/v1/index.js +0 -38
- package/dist/personas/index.d.ts +0 -23
- package/dist/personas/index.js +0 -78
- package/dist/personas/index.test.js +0 -124
- package/dist/personas/organization-audit/v1/index.d.ts +0 -8
- package/dist/personas/organization-audit/v1/index.js +0 -42
- package/dist/personas/persona.parity.test.js +0 -30
- package/dist/personas/semantic-layer/v1/index.d.ts +0 -8
- package/dist/personas/semantic-layer/v1/index.js +0 -32
- package/dist/personas/types.d.ts +0 -19
- /package/dist/{governance/client-capabilities-cache.test.d.ts → audit/server-profile.test.d.ts} +0 -0
- /package/dist/{personas/index.test.d.ts → config/obsolete-env.test.d.ts} +0 -0
- /package/dist/{personas/persona.parity.test.d.ts → governance/mcp-post-factory-context.test.d.ts} +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/evaluation.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/ai-agent-ops/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/content-move.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-developer/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/charts.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/dashboards.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-governance/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/compare.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/explain-run.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/content-reader/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/access.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/content.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/deliveries.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/organization-audit/v1/resources/playbooks.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.js +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/prompts.test.d.ts +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/compose-compile.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/core.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/explore.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks/index.md +0 -0
- /package/dist/{personas → profiles}/semantic-layer/v1/resources/playbooks.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
# [@lightdash-tools/mcp](https://www.npmjs.com/package/@lightdash-tools/mcp) <!-- markdown-link-check-disable-line -->
|
|
2
2
|
|
|
3
|
-
MCP server for Lightdash with **
|
|
3
|
+
MCP server for Lightdash with **profile-scoped** surfaces. One package, seven profiles: explore/compile, org audit, saved-content reads, chart/dashboard authoring, soft-delete governance, AI-agent ops, and ad-hoc Explore queries. Uses [`@lightdash-tools/client`](https://www.npmjs.com/package/@lightdash-tools/client) for API access. <!-- markdown-link-check-disable-line -->
|
|
4
4
|
|
|
5
5
|
Developing this package? See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
6
6
|
|
|
7
|
-
## Choose a
|
|
7
|
+
## Choose a profile
|
|
8
8
|
|
|
9
|
-
|
|
|
9
|
+
| Profile | Use when | HTTP path | Stdio | Catalog |
|
|
10
10
|
| :------------------- | :--------------------------------------- | :--------------------------- | :------------------- | :--------------------------------------------------------------- |
|
|
11
11
|
| `semantic-layer` | Explore metrics, compile queries | `/semantic-layer/v1/mcp` | **default** | — |
|
|
12
|
-
| `organization-audit` | Read-only org governance | `/organization-audit/v1/mcp` | `organization-audit` | [inventory](../../docs/organization-audit
|
|
13
|
-
| `content-reader` | Discover and run saved content | `/content-reader/v1/mcp` | `content-reader` | [inventory](../../docs/content-reader
|
|
14
|
-
| `content-developer` | Author charts/dashboards (preview gate) | `/content-developer/v1/mcp` | `content-developer` | [inventory](../../docs/content-developer
|
|
15
|
-
| `content-governance` | Soft-delete / promote (form elicitation) | `/content-governance/v1/mcp` | `content-governance` | [inventory](../../docs/content-governance
|
|
16
|
-
| `ai-agent-ops` | Thin AI-agent APIs + product eval runs | `/ai-agent-ops/v1/mcp` | `ai-agent-ops` | [inventory](../../docs/ai-agent-ops
|
|
12
|
+
| `organization-audit` | Read-only org governance | `/organization-audit/v1/mcp` | `organization-audit` | [inventory](../../docs/profiles/organization-audit/inventory.md) |
|
|
13
|
+
| `content-reader` | Discover and run saved content | `/content-reader/v1/mcp` | `content-reader` | [inventory](../../docs/profiles/content-reader/inventory.md) |
|
|
14
|
+
| `content-developer` | Author charts/dashboards (preview gate) | `/content-developer/v1/mcp` | `content-developer` | [inventory](../../docs/profiles/content-developer/inventory.md) |
|
|
15
|
+
| `content-governance` | Soft-delete / promote (form elicitation) | `/content-governance/v1/mcp` | `content-governance` | [inventory](../../docs/profiles/content-governance/inventory.md) |
|
|
16
|
+
| `ai-agent-ops` | Thin AI-agent APIs + product eval runs | `/ai-agent-ops/v1/mcp` | `ai-agent-ops` | [inventory](../../docs/profiles/ai-agent-ops/inventory.md) |
|
|
17
|
+
| `data-analyst` | Unsaved Explore metric queries | `/data-analyst/v1/mcp` | `data-analyst` | [inventory](../../docs/profiles/data-analyst/inventory.md) |
|
|
17
18
|
|
|
18
19
|
Tool names are prefixed with `lightdash_`. MCP display names are shortened where needed for client length limits (e.g. `lightdash-mcp-content`).
|
|
19
20
|
|
|
@@ -23,7 +24,7 @@ Tool names are prefixed with `lightdash_`. MCP display names are shortened where
|
|
|
23
24
|
|
|
24
25
|
```bash
|
|
25
26
|
npx @lightdash-tools/mcp # semantic-layer (default)
|
|
26
|
-
npx @lightdash-tools/mcp content-reader # other
|
|
27
|
+
npx @lightdash-tools/mcp content-reader # other profiles by name
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
Required env: `LIGHTDASH_URL`, `LIGHTDASH_API_KEY`. Logs go to **stderr**; stdout is JSON-RPC only ([stdio transport](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio)).
|
|
@@ -45,7 +46,7 @@ Example Cursor / Claude Desktop config:
|
|
|
45
46
|
}
|
|
46
47
|
```
|
|
47
48
|
|
|
48
|
-
Or install globally: `npm install -g @lightdash-tools/mcp`, then `lightdash-mcp [
|
|
49
|
+
Or install globally: `npm install -g @lightdash-tools/mcp`, then `lightdash-mcp [profile]`.
|
|
49
50
|
|
|
50
51
|
### Streamable HTTP (remote)
|
|
51
52
|
|
|
@@ -54,19 +55,19 @@ export LIGHTDASH_URL="https://app.lightdash.cloud"
|
|
|
54
55
|
export LIGHTDASH_TOOLS_MCP_PUBLIC_URL="https://lightdash-mcp.example.com"
|
|
55
56
|
export LIGHTDASH_TOOLS_OAUTH_CLIENT_ID="..."
|
|
56
57
|
export LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET="..."
|
|
57
|
-
npx @lightdash-tools/mcp
|
|
58
|
+
npx @lightdash-tools/mcp http
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
Profile MCP endpoints accept **POST** only ([Streamable HTTP 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http); no protocol sessions). Default listen port: `3100` (`LIGHTDASH_TOOLS_MCP_HTTP_PORT`).
|
|
61
62
|
|
|
62
|
-
- Hosted OAuth (Cursor URL-only): [docs/cursor-
|
|
63
|
-
- Operator guide: [docs/mcp-oauth
|
|
63
|
+
- Hosted OAuth (Cursor URL-only): [docs/operators/cursor-claude.md](../../docs/operators/cursor-claude.md)
|
|
64
|
+
- Operator guide: [docs/operators/mcp-oauth.md](../../docs/operators/mcp-oauth.md)
|
|
64
65
|
|
|
65
66
|
Local Compose smoke: `docker compose -f docker-compose.dev.yml --profile semantic-layer up --build` → `http://localhost:8080/semantic-layer/v1/mcp`.
|
|
66
67
|
|
|
67
68
|
## Configuration
|
|
68
69
|
|
|
69
|
-
Prefer `LIGHTDASH_TOOLS_*` env from the parent process. Avoid plaintext `.env` when agents can read files; if needed, use [dotenvx](https://dotenvx.com/). See [docs/secrets
|
|
70
|
+
Prefer `LIGHTDASH_TOOLS_*` env from the parent process. Avoid plaintext `.env` when agents can read files; if needed, use [dotenvx](https://dotenvx.com/). See [docs/operators/secrets.md](../../docs/operators/secrets.md).
|
|
70
71
|
|
|
71
72
|
### Stdio
|
|
72
73
|
|
|
@@ -82,9 +83,9 @@ Do **not** set OAuth client secrets for stdio. MCP ignores CLI `SAFETY_MODE` / `
|
|
|
82
83
|
| :-------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- |
|
|
83
84
|
| `LIGHTDASH_URL`, `LIGHTDASH_TOOLS_MCP_PUBLIC_URL`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_ID`, `LIGHTDASH_TOOLS_OAUTH_CLIENT_SECRET` | port, `ALLOWED_ORIGINS`, `ALLOWED_PROJECT_UUIDS`, token cache TTL |
|
|
84
85
|
|
|
85
|
-
On Cloud Run / hosted HTTP, leave `LIGHTDASH_TOOLS_AUDIT_LOG` unset — tool audits are stderr JSON (`channel: "audit"`) → Cloud Logging. See [cloud-run
|
|
86
|
+
On Cloud Run / hosted HTTP, leave `LIGHTDASH_TOOLS_AUDIT_LOG` unset — tool audits are stderr JSON (`channel: "audit"`) → Cloud Logging. See [cloud-run.md](../../docs/operators/cloud-run.md).
|
|
86
87
|
|
|
87
|
-
Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients connect with URL only to a
|
|
88
|
+
Register Lightdash redirect URI: `{PUBLIC_URL}/oauth/callback`. Clients connect with URL only to a profile path above. Protocol: [MCP Authorization 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization).
|
|
88
89
|
|
|
89
90
|
### Content-developer / content-governance signing
|
|
90
91
|
|
|
@@ -103,7 +104,7 @@ Governance soft-delete needs client form elicitation; missing capability → `EL
|
|
|
103
104
|
|
|
104
105
|
Obsolete vars (`AUTH_MODE`, `EXPERIMENTAL_*`, `DANGEROUSLY_*`, `INSECURE_DEV`, `MCP_STORE`, `MCP_REDIS_URL`, free-form `MCP_PATH`) are **rejected**. See [ADR-0019](../../docs/adr/0019-mcp-stateless-protocol-core-without-redis-ephemeral-store.md).
|
|
105
106
|
|
|
106
|
-
##
|
|
107
|
+
## Profiles at a glance
|
|
107
108
|
|
|
108
109
|
### `semantic-layer`
|
|
109
110
|
|
|
@@ -127,7 +128,11 @@ Soft-delete charts/dashboards and elicitation-gated dashboard promote. Permanent
|
|
|
127
128
|
|
|
128
129
|
### `ai-agent-ops`
|
|
129
130
|
|
|
130
|
-
Thin AI-agent inventory, readiness, thread reads, and product evaluation suite/run APIs. No agent CRUD or thread generate on MCP. Server name: `lightdash-mcp-aops`. Loop engineering: [docs/ai-agent-ops
|
|
131
|
+
Thin AI-agent inventory, readiness, thread reads, and product evaluation suite/run APIs. No agent CRUD or thread generate on MCP. Server name: `lightdash-mcp-aops`. Loop engineering: [docs/profiles/ai-agent-ops/loop.md](../../docs/profiles/ai-agent-ops/loop.md).
|
|
132
|
+
|
|
133
|
+
### `data-analyst`
|
|
134
|
+
|
|
135
|
+
Unsaved Explore-style metric queries (`run_metric_query`) with explore discovery and optional `compile_query`. Bounded rows; no chart save. Server name: `lightdash-mcp-analyst`.
|
|
131
136
|
|
|
132
137
|
## Safety
|
|
133
138
|
|
|
@@ -136,7 +141,7 @@ Thin AI-agent inventory, readiness, thread reads, and product evaluation suite/r
|
|
|
136
141
|
- **Redaction:** emails masked unless `includeEmail=true`; scheduler destinations redacted unless `revealDestinations=true`; warehouse/dbt connection secrets never on MCP ([ADR-0011](../../docs/adr/0011-mcp-tool-response-sensitivity-classes.md)).
|
|
137
142
|
- **Project scope:** optional HTTP pin `X-Lightdash-Project`, else tool `projectUuid`; optional ceiling `LIGHTDASH_TOOLS_ALLOWED_PROJECT_UUIDS`.
|
|
138
143
|
|
|
139
|
-
|
|
144
|
+
Profile tool allowlists are the capability surface — not CLI safety-mode.
|
|
140
145
|
|
|
141
146
|
## Upstream API failures
|
|
142
147
|
|
|
@@ -169,8 +174,8 @@ Intentional API upgrades still go through the pinned OpenAPI sync (`config/light
|
|
|
169
174
|
## Further reading
|
|
170
175
|
|
|
171
176
|
- Architecture / contributing — [CONTRIBUTING.md](./CONTRIBUTING.md)
|
|
172
|
-
- OAuth operator guide — [docs/mcp-oauth
|
|
173
|
-
- Cursor hosted OAuth — [docs/cursor-
|
|
177
|
+
- OAuth operator guide — [docs/operators/mcp-oauth.md](../../docs/operators/mcp-oauth.md)
|
|
178
|
+
- Cursor hosted OAuth — [docs/operators/cursor-claude.md](../../docs/operators/cursor-claude.md)
|
|
174
179
|
- Architecture decisions — [docs/adr/](../../docs/adr/)
|
|
175
180
|
- MCP transports — [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports)
|
|
176
181
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind an MCP server instance to a profile id for audit attribution and
|
|
3
|
+
* profile-aware tool registration (envelopes, get_project capabilities).
|
|
4
|
+
* Call once in registerCapabilities before registering tools; registerToolSafe
|
|
5
|
+
* and tool registrars read it via getServerProfile / requireServerProfile.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProfileId } from '@lightdash-tools/common';
|
|
8
|
+
/** Associate a profile id with an MCP server (call before registering tools). */
|
|
9
|
+
export declare function bindServerProfile(server: object, profileId: ProfileId): void;
|
|
10
|
+
/** Profile id bound to this server, if any. */
|
|
11
|
+
export declare function getServerProfile(server: object): ProfileId | undefined;
|
|
12
|
+
/** Fail closed when a registrar runs without bindServerProfile. */
|
|
13
|
+
export declare function requireServerProfile(server: object, toolId: string): ProfileId;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Bind an MCP server instance to a profile id for audit attribution and
|
|
4
|
+
* profile-aware tool registration (envelopes, get_project capabilities).
|
|
5
|
+
* Call once in registerCapabilities before registering tools; registerToolSafe
|
|
6
|
+
* and tool registrars read it via getServerProfile / requireServerProfile.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.bindServerProfile = bindServerProfile;
|
|
10
|
+
exports.getServerProfile = getServerProfile;
|
|
11
|
+
exports.requireServerProfile = requireServerProfile;
|
|
12
|
+
const serverProfile = new WeakMap();
|
|
13
|
+
/** Associate a profile id with an MCP server (call before registering tools). */
|
|
14
|
+
function bindServerProfile(server, profileId) {
|
|
15
|
+
serverProfile.set(server, profileId);
|
|
16
|
+
}
|
|
17
|
+
/** Profile id bound to this server, if any. */
|
|
18
|
+
function getServerProfile(server) {
|
|
19
|
+
return serverProfile.get(server);
|
|
20
|
+
}
|
|
21
|
+
/** Fail closed when a registrar runs without bindServerProfile. */
|
|
22
|
+
function requireServerProfile(server, toolId) {
|
|
23
|
+
const profile = getServerProfile(server);
|
|
24
|
+
if (!profile) {
|
|
25
|
+
throw new Error(`profileId is required to register ${toolId}`);
|
|
26
|
+
}
|
|
27
|
+
return profile;
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const server_profile_js_1 = require("./server-profile.js");
|
|
5
|
+
(0, vitest_1.describe)('server-profile', () => {
|
|
6
|
+
(0, vitest_1.it)('bindServerProfile / getServerProfile round-trip', () => {
|
|
7
|
+
const server = {};
|
|
8
|
+
(0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBeUndefined();
|
|
9
|
+
(0, server_profile_js_1.bindServerProfile)(server, 'content-developer');
|
|
10
|
+
(0, vitest_1.expect)((0, server_profile_js_1.getServerProfile)(server)).toBe('content-developer');
|
|
11
|
+
});
|
|
12
|
+
(0, vitest_1.it)('requireServerProfile returns the bound id', () => {
|
|
13
|
+
const server = {};
|
|
14
|
+
(0, server_profile_js_1.bindServerProfile)(server, 'content-reader');
|
|
15
|
+
(0, vitest_1.expect)((0, server_profile_js_1.requireServerProfile)(server, 'list_spaces')).toBe('content-reader');
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)('requireServerProfile throws when unbound', () => {
|
|
18
|
+
const server = {};
|
|
19
|
+
(0, vitest_1.expect)(() => (0, server_profile_js_1.requireServerProfile)(server, 'list_spaces')).toThrow(/profileId is required/);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY } from '../config/env.js';
|
|
6
6
|
export declare const PREVIEW_TOKEN_KEY_PURPOSE = "content-developer preview tokens are enabled";
|
|
7
7
|
export declare const DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE = "content-governance destructive tools are enabled";
|
|
8
|
-
/** HTTP ships all
|
|
8
|
+
/** HTTP ships all profiles; preview + destructive elicitation share one signing key. */
|
|
9
9
|
export declare const HTTP_SIGNED_STATE_KEY_PURPOSE = "HTTP MCP exposes content-developer preview tokens and content-governance destructive tools";
|
|
10
10
|
/** Resolve the HMAC signing key (configured env or test fallback). */
|
|
11
11
|
export declare function resolveRequestStateKey(purpose: string): string;
|
|
@@ -14,6 +14,6 @@ export declare function resolveRequestStateKey(purpose: string): string;
|
|
|
14
14
|
* Vitest/NODE_ENV=test may use a deterministic fallback (checked via resolve).
|
|
15
15
|
*/
|
|
16
16
|
export declare function assertRequestStateKeyConfigured(purpose: string): void;
|
|
17
|
-
/** Fail fast when HTTP starts with
|
|
17
|
+
/** Fail fast when HTTP starts with profiles that require signed preview/destructive tokens. */
|
|
18
18
|
export declare function assertHttpSignedStateKeyConfigured(): void;
|
|
19
19
|
export { ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY };
|
|
@@ -13,7 +13,7 @@ Object.defineProperty(exports, "ENV_LIGHTDASH_TOOLS_MCP_REQUEST_STATE_KEY", { en
|
|
|
13
13
|
const TEST_FALLBACK_KEY = 'lightdash-tools-dev-request-state-key!!';
|
|
14
14
|
exports.PREVIEW_TOKEN_KEY_PURPOSE = 'content-developer preview tokens are enabled';
|
|
15
15
|
exports.DESTRUCTIVE_REQUEST_STATE_KEY_PURPOSE = 'content-governance destructive tools are enabled';
|
|
16
|
-
/** HTTP ships all
|
|
16
|
+
/** HTTP ships all profiles; preview + destructive elicitation share one signing key. */
|
|
17
17
|
exports.HTTP_SIGNED_STATE_KEY_PURPOSE = 'HTTP MCP exposes content-developer preview tokens and content-governance destructive tools';
|
|
18
18
|
function isTestRuntime() {
|
|
19
19
|
return process.env.VITEST === 'true' || process.env.NODE_ENV === 'test';
|
|
@@ -43,7 +43,7 @@ function resolveRequestStateKey(purpose) {
|
|
|
43
43
|
function assertRequestStateKeyConfigured(purpose) {
|
|
44
44
|
resolveRequestStateKey(purpose);
|
|
45
45
|
}
|
|
46
|
-
/** Fail fast when HTTP starts with
|
|
46
|
+
/** Fail fast when HTTP starts with profiles that require signed preview/destructive tokens. */
|
|
47
47
|
function assertHttpSignedStateKeyConfigured() {
|
|
48
48
|
assertRequestStateKeyConfigured(exports.HTTP_SIGNED_STATE_KEY_PURPOSE);
|
|
49
49
|
}
|
|
@@ -15,7 +15,7 @@ export interface OAuthAuthFailure {
|
|
|
15
15
|
headers?: Record<string, string>;
|
|
16
16
|
}
|
|
17
17
|
export type OAuthAuthResult = OAuthAuthFailure | OAuthAuthSuccess;
|
|
18
|
-
/** Builds the standard missing-Bearer challenge for a
|
|
18
|
+
/** Builds the standard missing-Bearer challenge for a profile MCP path. */
|
|
19
19
|
export declare function buildBearerRequiredFailure(config: McpHttpConfig, mcpPath: string): OAuthAuthFailure;
|
|
20
20
|
export declare function authenticateLightdashOAuth(req: IncomingMessage, config: McpHttpConfig, mcpPath: string): Promise<OAuthAuthResult>;
|
|
21
21
|
export declare function writeOAuthAuthFailure(res: ServerResponse, failure: OAuthAuthFailure): void;
|
|
@@ -10,7 +10,7 @@ const oauth_protected_resource_js_1 = require("./oauth-protected-resource.js");
|
|
|
10
10
|
const token_scopes_js_1 = require("./token-scopes.js");
|
|
11
11
|
const token_validation_error_js_1 = require("./token-validation-error.js");
|
|
12
12
|
const www_authenticate_js_1 = require("./www-authenticate.js");
|
|
13
|
-
/** Builds the standard missing-Bearer challenge for a
|
|
13
|
+
/** Builds the standard missing-Bearer challenge for a profile MCP path. */
|
|
14
14
|
function buildBearerRequiredFailure(config, mcpPath) {
|
|
15
15
|
const resourceMetadataUrl = (0, oauth_protected_resource_js_1.getProtectedResourceMetadataPathUrl)(config, mcpPath);
|
|
16
16
|
const scope = config.requiredScopes.join(' ');
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const test_mcp_http_config_js_1 = require("../../config/test-mcp-http-config.js");
|
|
5
|
-
const index_js_1 = require("../../
|
|
6
|
-
const index_js_2 = require("../../
|
|
5
|
+
const index_js_1 = require("../../profiles/organization-audit/v1/index.js");
|
|
6
|
+
const index_js_2 = require("../../profiles/semantic-layer/v1/index.js");
|
|
7
7
|
const lightdash_oauth_middleware_js_1 = require("./lightdash-oauth-middleware.js");
|
|
8
8
|
const lightdash_token_validation_js_1 = require("./lightdash-token-validation.js");
|
|
9
9
|
const token_validation_error_js_1 = require("./token-validation-error.js");
|
|
@@ -25,7 +25,7 @@ function createRequest(authorization) {
|
|
|
25
25
|
}
|
|
26
26
|
(0, vitest_1.describe)('authenticateLightdashOAuth', () => {
|
|
27
27
|
(0, vitest_1.it)('returns 401 with WWW-Authenticate resource_metadata when token is missing', async () => {
|
|
28
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(), baseConfig, index_js_2.
|
|
28
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
29
29
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
30
30
|
if (result.ok)
|
|
31
31
|
return;
|
|
@@ -38,8 +38,8 @@ function createRequest(authorization) {
|
|
|
38
38
|
(0, vitest_1.expect)(result.wwwAuthenticate).toContain('https://mcp.example.com/.well-known/oauth-protected-resource/semantic-layer/v1/mcp');
|
|
39
39
|
(0, vitest_1.expect)(result.wwwAuthenticate).not.toContain('scope=');
|
|
40
40
|
});
|
|
41
|
-
(0, vitest_1.it)('points resource_metadata at the requested
|
|
42
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(), baseConfig, index_js_1.
|
|
41
|
+
(0, vitest_1.it)('points resource_metadata at the requested profile path', async () => {
|
|
42
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(), baseConfig, index_js_1.ORGANIZATION_AUDIT_PROFILE_PATH);
|
|
43
43
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
44
44
|
if (result.ok)
|
|
45
45
|
return;
|
|
@@ -49,7 +49,7 @@ function createRequest(authorization) {
|
|
|
49
49
|
(0, vitest_1.it)('returns 401 without echoing the bearer token when validation fails', async () => {
|
|
50
50
|
vitest_1.vi.mocked(lightdash_token_validation_js_1.validateLightdashAccessToken).mockRejectedValue(new token_validation_error_js_1.TokenValidationError('invalid_token', 'Invalid or expired Lightdash access token'));
|
|
51
51
|
const token = 'secret-oauth-token';
|
|
52
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.
|
|
52
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
53
53
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
54
54
|
if (result.ok)
|
|
55
55
|
return;
|
|
@@ -61,7 +61,7 @@ function createRequest(authorization) {
|
|
|
61
61
|
});
|
|
62
62
|
(0, vitest_1.it)('returns 503 when Lightdash upstream is unavailable', async () => {
|
|
63
63
|
vitest_1.vi.mocked(lightdash_token_validation_js_1.validateLightdashAccessToken).mockRejectedValue(new token_validation_error_js_1.TokenValidationError('upstream_unavailable', 'Lightdash is temporarily unavailable'));
|
|
64
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer token'), baseConfig, index_js_2.
|
|
64
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer token'), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
65
65
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
66
66
|
if (result.ok)
|
|
67
67
|
return;
|
|
@@ -74,7 +74,7 @@ function createRequest(authorization) {
|
|
|
74
74
|
});
|
|
75
75
|
(0, vitest_1.it)('returns 503 with Retry-After when upstream is rate limited', async () => {
|
|
76
76
|
vitest_1.vi.mocked(lightdash_token_validation_js_1.validateLightdashAccessToken).mockRejectedValue(new token_validation_error_js_1.TokenValidationError('upstream_unavailable', 'Lightdash is temporarily unavailable', 60));
|
|
77
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer token'), baseConfig, index_js_2.
|
|
77
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer token'), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
78
78
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
79
79
|
if (result.ok)
|
|
80
80
|
return;
|
|
@@ -87,7 +87,7 @@ function createRequest(authorization) {
|
|
|
87
87
|
email: 'user@example.com',
|
|
88
88
|
});
|
|
89
89
|
const token = jwtWithScope('mcp:read mcp:write');
|
|
90
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.
|
|
90
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
91
91
|
(0, vitest_1.expect)(result).toEqual({
|
|
92
92
|
ok: true,
|
|
93
93
|
accessToken: token,
|
|
@@ -101,7 +101,7 @@ function createRequest(authorization) {
|
|
|
101
101
|
userUuid: 'user-uuid-1',
|
|
102
102
|
email: 'user@example.com',
|
|
103
103
|
});
|
|
104
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer opaque-token'), baseConfig, index_js_2.
|
|
104
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer opaque-token'), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
105
105
|
(0, vitest_1.expect)(result).toEqual({
|
|
106
106
|
ok: true,
|
|
107
107
|
accessToken: 'opaque-token',
|
|
@@ -117,7 +117,7 @@ function createRequest(authorization) {
|
|
|
117
117
|
const header = Buffer.from(JSON.stringify({ alg: 'none', typ: 'JWT' })).toString('base64url');
|
|
118
118
|
const payload = Buffer.from(JSON.stringify({ sub: 'user-uuid-1' })).toString('base64url');
|
|
119
119
|
const token = `${header}.${payload}.signature`;
|
|
120
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.
|
|
120
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
121
121
|
(0, vitest_1.expect)(result.ok).toBe(true);
|
|
122
122
|
if (!result.ok)
|
|
123
123
|
return;
|
|
@@ -129,7 +129,7 @@ function createRequest(authorization) {
|
|
|
129
129
|
email: 'user@example.com',
|
|
130
130
|
});
|
|
131
131
|
const scopedConfig = Object.assign(Object.assign({}, baseConfig), { requiredScopes: ['mcp:read'] });
|
|
132
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer opaque-token'), scopedConfig, index_js_2.
|
|
132
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest('Bearer opaque-token'), scopedConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
133
133
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
134
134
|
if (result.ok)
|
|
135
135
|
return;
|
|
@@ -146,7 +146,7 @@ function createRequest(authorization) {
|
|
|
146
146
|
const payload = Buffer.from(JSON.stringify({ scope: 'mcp:write' })).toString('base64url');
|
|
147
147
|
const token = `${header}.${payload}.signature`;
|
|
148
148
|
const scopedConfig = Object.assign(Object.assign({}, baseConfig), { requiredScopes: ['mcp:read'] });
|
|
149
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), scopedConfig, index_js_2.
|
|
149
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`Bearer ${token}`), scopedConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
150
150
|
(0, vitest_1.expect)(result.ok).toBe(false);
|
|
151
151
|
if (result.ok)
|
|
152
152
|
return;
|
|
@@ -160,7 +160,7 @@ function createRequest(authorization) {
|
|
|
160
160
|
email: 'user@example.com',
|
|
161
161
|
});
|
|
162
162
|
const token = jwtWithScope('mcp:read mcp:write');
|
|
163
|
-
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`bearer ${token}`), baseConfig, index_js_2.
|
|
163
|
+
const result = await (0, lightdash_oauth_middleware_js_1.authenticateLightdashOAuth)(createRequest(`bearer ${token}`), baseConfig, index_js_2.SEMANTIC_LAYER_PROFILE_PATH);
|
|
164
164
|
(0, vitest_1.expect)(result.ok).toBe(true);
|
|
165
165
|
if (!result.ok)
|
|
166
166
|
return;
|
|
@@ -8,17 +8,17 @@ export interface OAuthProtectedResourceMetadata {
|
|
|
8
8
|
scopes_supported: string[];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* Builds MCP OAuth protected-resource metadata for a
|
|
12
|
-
* Callers must pass an explicit
|
|
11
|
+
* Builds MCP OAuth protected-resource metadata for a profile MCP path.
|
|
12
|
+
* Callers must pass an explicit profile path (root PRM uses `config.mcpPath`).
|
|
13
13
|
*/
|
|
14
14
|
export declare function buildOAuthProtectedResourceMetadata(config: McpHttpConfig, mcpPath: string): OAuthProtectedResourceMetadata;
|
|
15
15
|
export declare function getProtectedResourceMetadataUrl(config: McpHttpConfig): string;
|
|
16
|
-
/** Path-specific PRM URL for a
|
|
16
|
+
/** Path-specific PRM URL for a profile MCP endpoint. */
|
|
17
17
|
export declare function getProtectedResourceMetadataPathUrl(config: McpHttpConfig, mcpPath: string): string;
|
|
18
18
|
/**
|
|
19
|
-
* Resolves the
|
|
20
|
-
* Root PRM maps to the default
|
|
21
|
-
* is served only for shipped
|
|
19
|
+
* Resolves the profile MCP path for a PRM well-known request.
|
|
20
|
+
* Root PRM maps to the default profile (`config.mcpPath`); path-specific PRM
|
|
21
|
+
* is served only for shipped profile paths.
|
|
22
22
|
*/
|
|
23
23
|
export declare function resolveProtectedResourceMcpPath(path: string, config: McpHttpConfig): string | undefined;
|
|
24
24
|
/** Well-known OAuth Authorization Server Metadata URL for an AS origin. */
|
|
@@ -9,13 +9,13 @@ exports.getAuthorizationServerMetadataUrl = getAuthorizationServerMetadataUrl;
|
|
|
9
9
|
const env_js_1 = require("../../config/env.js");
|
|
10
10
|
const normalize_url_js_1 = require("../../config/normalize-url.js");
|
|
11
11
|
const public_url_js_1 = require("../../config/public-url.js");
|
|
12
|
-
const index_js_1 = require("../../
|
|
12
|
+
const index_js_1 = require("../../profiles/index.js");
|
|
13
13
|
const OAUTH_PROTECTED_RESOURCE_CONTEXT = 'OAuth protected resource metadata';
|
|
14
14
|
/** Well-known OAuth protected-resource metadata root path. */
|
|
15
15
|
exports.OAUTH_PROTECTED_RESOURCE_ROOT = '/.well-known/oauth-protected-resource';
|
|
16
16
|
/**
|
|
17
|
-
* Builds MCP OAuth protected-resource metadata for a
|
|
18
|
-
* Callers must pass an explicit
|
|
17
|
+
* Builds MCP OAuth protected-resource metadata for a profile MCP path.
|
|
18
|
+
* Callers must pass an explicit profile path (root PRM uses `config.mcpPath`).
|
|
19
19
|
*/
|
|
20
20
|
function buildOAuthProtectedResourceMetadata(config, mcpPath) {
|
|
21
21
|
const publicUrl = (0, public_url_js_1.requirePublicUrl)(config, OAUTH_PROTECTED_RESOURCE_CONTEXT);
|
|
@@ -34,16 +34,16 @@ function buildOAuthProtectedResourceMetadata(config, mcpPath) {
|
|
|
34
34
|
function getProtectedResourceMetadataUrl(config) {
|
|
35
35
|
return `${(0, public_url_js_1.requirePublicUrl)(config, OAUTH_PROTECTED_RESOURCE_CONTEXT)}${exports.OAUTH_PROTECTED_RESOURCE_ROOT}`;
|
|
36
36
|
}
|
|
37
|
-
/** Path-specific PRM URL for a
|
|
37
|
+
/** Path-specific PRM URL for a profile MCP endpoint. */
|
|
38
38
|
function getProtectedResourceMetadataPathUrl(config, mcpPath) {
|
|
39
39
|
const publicUrl = (0, public_url_js_1.requirePublicUrl)(config, OAUTH_PROTECTED_RESOURCE_CONTEXT);
|
|
40
40
|
const resourcePath = (0, normalize_url_js_1.normalizeMcpPath)(mcpPath).replace(/^\//, '');
|
|
41
41
|
return `${publicUrl}${exports.OAUTH_PROTECTED_RESOURCE_ROOT}/${resourcePath}`;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Resolves the
|
|
45
|
-
* Root PRM maps to the default
|
|
46
|
-
* is served only for shipped
|
|
44
|
+
* Resolves the profile MCP path for a PRM well-known request.
|
|
45
|
+
* Root PRM maps to the default profile (`config.mcpPath`); path-specific PRM
|
|
46
|
+
* is served only for shipped profile paths.
|
|
47
47
|
*/
|
|
48
48
|
function resolveProtectedResourceMcpPath(path, config) {
|
|
49
49
|
var _a;
|
|
@@ -58,7 +58,7 @@ function resolveProtectedResourceMcpPath(path, config) {
|
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
const resourcePath = `/${path.slice(prefix.length)}`;
|
|
61
|
-
return (_a = (0, index_js_1.
|
|
61
|
+
return (_a = (0, index_js_1.getProfileByPath)(resourcePath)) === null || _a === void 0 ? void 0 : _a.path;
|
|
62
62
|
}
|
|
63
63
|
/** Well-known OAuth Authorization Server Metadata URL for an AS origin. */
|
|
64
64
|
function getAuthorizationServerMetadataUrl(authorizationServerOrigin) {
|
|
@@ -6,7 +6,7 @@ export interface ExtractTokenScopesOptions {
|
|
|
6
6
|
* Extracts OAuth scopes from JWT claims when present.
|
|
7
7
|
*
|
|
8
8
|
* For `lightdash-oauth`, Lightdash access tokens are typically opaque and this returns
|
|
9
|
-
* `undefined` — MCP-local scope enforcement is skipped and authorization relies on the
|
|
9
|
+
* `undefined` — MCP-local scope enforcement is skipped and authorization relies on the profile
|
|
10
10
|
* tool surface plus Lightdash RBAC (ADR-0006 / ADR-0008). Do not treat decoded JWT scopes as
|
|
11
11
|
* validated Lightdash OAuth authorization unless Lightdash formally issues resource-bound JWT
|
|
12
12
|
* access tokens.
|
|
@@ -54,7 +54,7 @@ function scopesWhenUnknown(scopesSupported, grantAllWhenUnknown) {
|
|
|
54
54
|
* Extracts OAuth scopes from JWT claims when present.
|
|
55
55
|
*
|
|
56
56
|
* For `lightdash-oauth`, Lightdash access tokens are typically opaque and this returns
|
|
57
|
-
* `undefined` — MCP-local scope enforcement is skipped and authorization relies on the
|
|
57
|
+
* `undefined` — MCP-local scope enforcement is skipped and authorization relies on the profile
|
|
58
58
|
* tool surface plus Lightdash RBAC (ADR-0006 / ADR-0008). Do not treat decoded JWT scopes as
|
|
59
59
|
* validated Lightdash OAuth authorization unless Lightdash formally issues resource-bound JWT
|
|
60
60
|
* access tokens.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const test_mcp_http_config_js_1 = require("../../config/test-mcp-http-config.js");
|
|
5
|
-
const index_js_1 = require("../../
|
|
6
|
-
const index_js_2 = require("../../
|
|
7
|
-
const index_js_3 = require("../../
|
|
5
|
+
const index_js_1 = require("../../profiles/content-reader/v1/index.js");
|
|
6
|
+
const index_js_2 = require("../../profiles/organization-audit/v1/index.js");
|
|
7
|
+
const index_js_3 = require("../../profiles/semantic-layer/v1/index.js");
|
|
8
8
|
const oauth_protected_resource_js_1 = require("./oauth-protected-resource.js");
|
|
9
9
|
const www_authenticate_js_1 = require("./www-authenticate.js");
|
|
10
10
|
const baseConfig = (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
|
|
@@ -18,23 +18,23 @@ const baseConfig = (0, test_mcp_http_config_js_1.makeTestMcpHttpConfig)({
|
|
|
18
18
|
});
|
|
19
19
|
(0, vitest_1.describe)('buildOAuthProtectedResourceMetadata', () => {
|
|
20
20
|
(0, vitest_1.it)('includes resource and MCP host as authorization_servers', () => {
|
|
21
|
-
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_3.
|
|
21
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_3.SEMANTIC_LAYER_PROFILE_PATH);
|
|
22
22
|
(0, vitest_1.expect)(metadata).toEqual({
|
|
23
|
-
resource: `https://mcp.example.com${index_js_3.
|
|
23
|
+
resource: `https://mcp.example.com${index_js_3.SEMANTIC_LAYER_PROFILE_PATH}`,
|
|
24
24
|
authorization_servers: ['https://mcp.example.com'],
|
|
25
25
|
bearer_methods_supported: ['header'],
|
|
26
26
|
scopes_supported: ['mcp:read', 'mcp:write'],
|
|
27
27
|
});
|
|
28
28
|
(0, vitest_1.expect)((0, oauth_protected_resource_js_1.getAuthorizationServerMetadataUrl)(metadata.authorization_servers[0])).toBe('https://mcp.example.com/.well-known/oauth-authorization-server');
|
|
29
29
|
});
|
|
30
|
-
(0, vitest_1.it)('builds
|
|
31
|
-
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_2.
|
|
32
|
-
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_2.
|
|
30
|
+
(0, vitest_1.it)('builds profile-specific resource metadata for organization-audit', () => {
|
|
31
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_2.ORGANIZATION_AUDIT_PROFILE_PATH);
|
|
32
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_2.ORGANIZATION_AUDIT_PROFILE_PATH}`);
|
|
33
33
|
(0, vitest_1.expect)(metadata.authorization_servers).toEqual(['https://mcp.example.com']);
|
|
34
34
|
});
|
|
35
|
-
(0, vitest_1.it)('builds
|
|
36
|
-
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_1.
|
|
37
|
-
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_1.
|
|
35
|
+
(0, vitest_1.it)('builds profile-specific resource metadata for content-reader', () => {
|
|
36
|
+
const metadata = (0, oauth_protected_resource_js_1.buildOAuthProtectedResourceMetadata)(baseConfig, index_js_1.CONTENT_READER_PROFILE_PATH);
|
|
37
|
+
(0, vitest_1.expect)(metadata.resource).toBe(`https://mcp.example.com${index_js_1.CONTENT_READER_PROFILE_PATH}`);
|
|
38
38
|
(0, vitest_1.expect)(metadata.authorization_servers).toEqual(['https://mcp.example.com']);
|
|
39
39
|
});
|
|
40
40
|
});
|