Guide · Amazon QuickSight · Embedding & Multi-Tenant Isolation
Embedding QuickSight Dashboards in MCP Server UIs — GenerateEmbedUrlForAnonymousUser, Embedding SDK v2, Multi-Tenant RLS
QuickSight embedding lets you serve analytics directly inside your MCP server web interface — no AWS console access required for end users, no API credentials exposed to the browser. The architecture is a two-call pattern: your server generates a time-limited, signed embed URL using GenerateEmbedUrlForAnonymousUserCommand or GenerateEmbedUrlForRegisteredUserCommand, then the browser's QuickSight Embedding SDK v2 renders the dashboard in an iframe using that URL. For multi-tenant MCP server platforms, row-level security (RLS) datasets combined with QuickSight namespaces ensure each tenant sees only their own data — from the same embedded dashboard URL — with zero per-tenant deployment cost.
TL;DR
Anonymous embed (no login required) uses GenerateEmbedUrlForAnonymousUserCommand — requires the Capacity Pricing add-on. Registered-user embed uses GenerateEmbedUrlForRegisteredUserCommand after the user is registered with RegisterUserCommand. Both return a one-time URL valid for 5 minutes that you pass to the Embedding SDK's embedDashboard() method on the browser. Set AllowedDomains to your production domain to prevent URL reuse from unauthorized origins. For multi-tenancy, combine QuickSight namespaces (one per tenant) with an RLS dataset (maps username to tenant-specific row filters) so the same dashboard serves all tenants safely.
Two embed modes: anonymous vs registered
| Mode | Command | Requires | Best for |
|---|---|---|---|
| Anonymous | GenerateEmbedUrlForAnonymousUserCommand |
Enterprise edition + Capacity Pricing add-on | Public-facing dashboards, no login wall, pay per reader session |
| Registered user | GenerateEmbedUrlForRegisteredUserCommand |
Enterprise edition; user registered via RegisterUserCommand |
Internal tools, authenticated portals, per-user personalization |
Capacity Pricing is a QuickSight add-on that bills by session rather than by seat — $250/month for 500 reader sessions (overages at $0.30/session). For MCP server platforms where the number of end users is unpredictable, Capacity Pricing eliminates the need to pre-provision reader seats for every potential viewer.
Anonymous embed — server-side URL generation
The embed URL generation happens on your server (Node.js, Lambda, etc.) using the AWS SDK. The URL is valid for up to 15 minutes and is consumed exactly once:
import { QuickSightClient, GenerateEmbedUrlForAnonymousUserCommand } from "@aws-sdk/client-quicksight";
const qs = new QuickSightClient({ region: "us-east-1" });
const ACCOUNT_ID = process.env.AWS_ACCOUNT_ID;
export async function getAnonymousEmbedUrl(dashboardId, tenantId) {
const result = await qs.send(new GenerateEmbedUrlForAnonymousUserCommand({
AwsAccountId: ACCOUNT_ID,
Namespace: `tenant-${tenantId}`, // namespace isolates the session
SessionLifetimeInMinutes: 600, // 10 hours; max 600
AllowedDomains: ["https://app.alivemcp.com", "https://staging.alivemcp.com"],
AuthorizedResourceArns: [
`arn:aws:quicksight:us-east-1:${ACCOUNT_ID}:dashboard/${dashboardId}`,
],
ExperienceConfiguration: {
Dashboard: {
InitialDashboardId: dashboardId,
// Optional: disable top nav UI
FeatureConfigurations: {
StatePersistence: { Enabled: true },
SharedView: { Enabled: false },
},
},
},
// Session tags become available as column-level filter variables in RLS
SessionTags: [
{ Key: "tenant_id", Value: tenantId },
],
}));
return result.EmbedUrl;
}
The Namespace parameter scopes the anonymous session to a specific QuickSight namespace. Even if the dashboard is shared with users across all namespaces, the session-level namespace constrains which RLS rows apply. This is the primary mechanism for tenant isolation in anonymous embed scenarios.
The SessionTags allow you to pass runtime filter values into the session. Combined with a tag-based RLS policy (a tag named tenant_id as the filter column in the RLS rules dataset), each anonymous session automatically sees only the rows matching their tenant ID — without any changes to the dashboard itself.
Registered user embed — registration and URL generation
For authenticated portals where users log in before seeing dashboards, register each user once with RegisterUserCommand and generate embed URLs with GenerateEmbedUrlForRegisteredUserCommand:
import {
RegisterUserCommand,
GenerateEmbedUrlForRegisteredUserCommand
} from "@aws-sdk/client-quicksight";
// Step 1: Register the user (idempotent — safe to call on every login)
async function ensureUserRegistered(email, namespace) {
try {
await qs.send(new RegisterUserCommand({
AwsAccountId: ACCOUNT_ID,
Namespace: namespace,
Email: email,
IdentityType: "QUICKSIGHT", // or "IAM" for federated identity
UserRole: "READER", // "READER" | "AUTHOR" | "ADMIN"
IamArn: undefined, // only needed for IAM identity type
}));
} catch (err) {
if (err.name !== "ResourceExistsException") throw err;
// User already registered — that's fine
}
}
// Step 2: Generate the embed URL for this registered user
async function getRegisteredEmbedUrl(email, namespace, dashboardId) {
await ensureUserRegistered(email, namespace);
const { EmbedUrl } = await qs.send(new GenerateEmbedUrlForRegisteredUserCommand({
AwsAccountId: ACCOUNT_ID,
SessionLifetimeInMinutes: 600,
AllowedDomains: ["https://app.alivemcp.com"],
UserArn: `arn:aws:quicksight:us-east-1:${ACCOUNT_ID}:user/${namespace}/${email}`,
ExperienceConfiguration: {
Dashboard: {
InitialDashboardId: dashboardId,
FeatureConfigurations: {
StatePersistence: { Enabled: true },
},
},
},
}));
return EmbedUrl;
}
Registered users with READER role can interact with dashboards (apply filters, drill down, export CSV if enabled) but cannot edit analyses or create new visuals. AUTHOR role users get full analysis edit access and are billed at the author per-seat rate ($18/month for Enterprise).
Browser-side: QuickSight Embedding SDK v2
Once your server returns an embed URL to the browser, use the official Embedding SDK to render the dashboard. Install it in your frontend:
npm install @amazon-quicksight/embedding-sdk
import { createEmbeddingContext } from "@amazon-quicksight/embedding-sdk";
// Call your server to get the embed URL
const response = await fetch("/api/quicksight-embed-url", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ dashboardId: "mcp-uptime-dashboard" }),
});
const { embedUrl } = await response.json();
// Create embedding context (once per page)
const embeddingContext = await createEmbeddingContext({
onChange: (changeEvent, metadata) => {
// Handle state changes: loading, errors, navigation
if (changeEvent.eventName === "FRAME_LOADED") {
console.log("Dashboard loaded, metadata:", metadata);
}
},
});
// Embed the dashboard into a container element
const containerDiv = document.getElementById("dashboard-container");
const embeddedDashboard = await embeddingContext.embedDashboard({
url: embedUrl,
container: containerDiv,
scrolling: "no",
height: "700px",
width: "100%",
resizeHeightOnSizeChangedEvent: true,
});
The embedding context is a singleton — create it once and reuse it across multiple embeds on the same page (dashboard + Q bar + visual). The embedDashboard call renders an iframe inside the container div and handles authentication automatically using the signed URL.
Interacting with the embedded dashboard programmatically
The embeddedDashboard object exposes methods to control the dashboard from JavaScript — apply filters, navigate sheets, trigger refreshes — without user clicks:
// Apply a filter from outside the iframe
await embeddedDashboard.setParameters([
{ Name: "region", Values: ["us-east-1"] },
{ Name: "status", Values: ["DEGRADED", "DOWN"] },
]);
// Navigate to a specific sheet
await embeddedDashboard.navigateToDashboard("mcp-uptime-dashboard", {
pageIndex: 1, // 0-indexed sheet number
});
// Listen for user filter changes inside the dashboard
embeddedDashboard.on("PARAMETERS_CHANGED", (params) => {
// Sync the URL query string so users can share filtered views
const qs = new URLSearchParams(params.changedParameters.map(p =>
[p.name, p.values[0]]
));
window.history.replaceState(null, "", "?" + qs.toString());
});
// Listen for content loading completion
embeddedDashboard.on("CONTENT_LOADED", (payload) => {
console.log("Sheet count:", payload.sheets.length);
});
The PARAMETERS_CHANGED event enables deep linking — when the user changes a filter inside the embedded dashboard, you can update the page URL so they can share or bookmark the filtered state. On page load, extract those parameters from the URL and apply them via setParameters to restore the state.
Embedding the Amazon Q natural-language search bar
Enterprise + Q edition users can embed the natural-language query interface alongside (or instead of) a dashboard:
import { createEmbeddingContext } from "@amazon-quicksight/embedding-sdk";
const { EmbedUrl: qUrl } = await qs.send(
new GenerateEmbedUrlForRegisteredUserCommand({
AwsAccountId: ACCOUNT_ID,
SessionLifetimeInMinutes: 600,
AllowedDomains: ["https://app.alivemcp.com"],
UserArn: userArn,
ExperienceConfiguration: {
QSearchBar: {
InitialTopicId: "mcp-metrics-topic", // QuickSight Q topic ID
},
},
})
);
const embeddedQBar = await embeddingContext.embedQSearchBar({
url: qUrl,
container: document.getElementById("q-bar-container"),
height: "56px",
width: "100%",
withIframePlaceholder: true,
});
When a user asks a natural-language question, the Q bar generates a visual and optionally navigates the connected dashboard to show the answer. This is particularly powerful for MCP server admin interfaces where non-engineers need to explore operational data without learning QuickSight's visual builder.
Multi-tenant embed architecture with namespaces and RLS
For a SaaS platform serving multiple customers on the same dashboard, combine three mechanisms:
- QuickSight namespace per tenant — creates an isolated user and permission boundary.
- Anonymous session tags — pass the tenant ID into the session at embed URL generation time.
- Tag-based RLS dataset — the RLS rules table uses a
tenant_idcolumn mapped to a QuickSight session tag, automatically filtering every query to that tenant's rows.
// 1. Provision tenant (run once during tenant signup)
async function provisionTenant(tenantId) {
// Create namespace
await qs.send(new CreateNamespaceCommand(qsParams({
Namespace: `tenant-${tenantId}`,
IdentityStore: "QUICKSIGHT",
})));
// Wait for namespace (poll DescribeNamespaceCommand)
// ...
// Share dashboard with this namespace
await qs.send(new UpdateDashboardPermissionsCommand(qsParams({
DashboardId: "mcp-uptime-dashboard",
GrantPermissions: [{
Principal: `arn:aws:quicksight:us-east-1:${ACCOUNT_ID}:namespace/tenant-${tenantId}`,
Actions: ["quicksight:DescribeDashboard", "quicksight:QueryDashboard"],
}],
})));
}
// 2. Generate embed URL with session tag for tenant isolation
async function getTenantEmbedUrl(tenantId) {
return getAnonymousEmbedUrl("mcp-uptime-dashboard", tenantId);
// getAnonymousEmbedUrl already passes SessionTags: [{ Key: "tenant_id", Value: tenantId }]
}
// 3. RLS dataset (run once; refresh when tenant list changes)
// Rules CSV in S3:
// TagKey,TagValue,endpoint_owner_tenant_id
// tenant_id,acme,acme
// tenant_id,globex,globex
// (every row is tenant_id=X grants access to rows where endpoint_owner_tenant_id=X)
With tag-based RLS, the filter is enforced server-side by QuickSight — users cannot bypass it by modifying the embed URL or iframe source. The session tag is cryptographically bound to the signed embed URL and cannot be forged by the browser.
AllowedDomains — preventing URL reuse
The AllowedDomains parameter prevents embed URLs from being loaded on unauthorized domains. QuickSight enforces this at the iframe origin level — if the host page's domain is not in the allowlist, the iframe refuses to render:
// Correct: include scheme and exact domain (no trailing slash, no wildcard subdomain)
AllowedDomains: [
"https://app.alivemcp.com",
"https://staging.alivemcp.com",
"http://localhost:3000", // local dev
]
Do not omit AllowedDomains in production. Without it, any page that obtains the embed URL (from a leaked log, a shared link, or a compromised browser extension) can load your dashboard in its own iframe — exposing your tenant's data to an unauthorized context.
Key gotchas
- Anonymous embed requires Capacity Pricing — not just Enterprise: Even with Enterprise edition, calling
GenerateEmbedUrlForAnonymousUserCommandreturnsUnsupportedPricingPlanExceptionwithout Capacity Pricing enabled. Enable it in the QuickSight management console under "Manage QuickSight" → "Capacity Pricing". - Embed URLs are single-use and expire in 5 minutes: Generate the URL as late as possible — when the user actually navigates to the page, not at login. Caching embed URLs across page loads will produce expired-URL errors after a few minutes.
- SessionLifetimeInMinutes is the iframe session duration, not the URL validity: The URL itself expires in 5 minutes (from generation to first use). Once the iframe loads, the session stays active for
SessionLifetimeInMinutes(up to 600 minutes). Generate a new URL when users revisit the page; the existing session persists untilSessionLifetimeInMinuteselapses. - Namespace must exist before generating anonymous embed URLs:
GenerateEmbedUrlForAnonymousUserCommandvalidates that the namespace exists. If you provision tenants asynchronously, add a readiness check before the first embed URL generation. - setParameters requires parameters defined in the dashboard: You cannot inject arbitrary parameters via
setParametersfrom outside the iframe — the parameter names must match parameters configured in the dashboard definition. Add a "Dashboard Parameters" section in QuickSight when building the analysis. - Tag-based RLS requires session tags enabled on the dataset: The dataset must reference a tag in its RLS rules table (
TagKeycolumn) for tag-based filtering to work. Without this, session tags are ignored and all rows are visible.
Continue in this series
- QuickSight overview for MCP servers — SDK quick start, account subscription, five-layer hierarchy, IAM setup
- Data sources and SPICE datasets — CreateDataSourceCommand, all source types, VPC connections, ImportMode, row-level security
- Analyses and dashboard publishing — CreateAnalysisCommand, CreateDashboardCommand, versioning, assets-as-code, themes
Related guides: CloudWatch metrics for MCP servers · IAM setup for MCP server tools · Amazon Forecast for MCP servers