Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Use the application name in the MCP inline chart iframe (#83853)

Sébastien7bf959e1672f
diff --git a/frontend/src/metabase/embedding/mcp/McpExploreButton.tsx b/frontend/src/metabase/embedding/mcp/McpExploreButton.tsx
index 5cdd43530bf..b9c5c38cc9c 100644
--- a/frontend/src/metabase/embedding/mcp/McpExploreButton.tsx
+++ b/frontend/src/metabase/embedding/mcp/McpExploreButton.tsx
@@ -2,6 +2,8 @@ import type { App } from "@modelcontextprotocol/ext-apps/react";
import { t } from "ttag";
import { useSdkQuestionContext } from "embedding-sdk-bundle/components/private/SdkQuestion/context";
+import { useSelector } from "metabase/redux";
+import { getApplicationName } from "metabase/selectors/whitelabel";
import { UnstyledButton } from "metabase/ui";
import * as Urls from "metabase/urls";
@@ -12,6 +14,7 @@ interface McpExploreButtonProps {
export function McpExploreButton({ app, instanceUrl }: McpExploreButtonProps) {
const { question } = useSdkQuestionContext();
+ const applicationName = useSelector(getApplicationName);
async function handleExploreClicked() {
if (!instanceUrl || !question || !app) {
@@ -33,8 +36,7 @@ export function McpExploreButton({ app, instanceUrl }: McpExploreButtonProps) {
lh="normal"
p={0}
>
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- no whitelabel needed */}
- {t`Explore in Metabase`}
+ {t`Explore in ${applicationName}`}
</UnstyledButton>
);
}
diff --git a/frontend/src/metabase/embedding/mcp/McpExploreButton.unit.spec.tsx b/frontend/src/metabase/embedding/mcp/McpExploreButton.unit.spec.tsx
index 6b9fbf6c6c5..2639b9115ee 100644
--- a/frontend/src/metabase/embedding/mcp/McpExploreButton.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/mcp/McpExploreButton.unit.spec.tsx
@@ -1,5 +1,6 @@
import userEvent from "@testing-library/user-event";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupAlertsEndpoints,
setupCardEndpoints,
@@ -19,6 +20,8 @@ import {
createMockDataset,
createMockDatasetData,
createMockNumericColumn,
+ createMockSettings,
+ createMockTokenFeatures,
createMockUser,
} from "metabase-types/api/mocks";
import {
@@ -58,8 +61,24 @@ const QUERY_RESULT = createMockDataset({
}),
});
-function setup() {
- const { state } = setupSdkState({ currentUser: TEST_USER });
+function setup({ applicationName }: { applicationName?: string } = {}) {
+ const { state } = setupSdkState({
+ currentUser: TEST_USER,
+ ...(applicationName && {
+ settingValues: createMockSettings({
+ "enable-embedding-sdk": true,
+ "application-name": applicationName,
+ }),
+ tokenFeatures: createMockTokenFeatures({
+ embedding_sdk: true,
+ whitelabel: true,
+ }),
+ }),
+ });
+ if (applicationName) {
+ setupEnterpriseOnlyPlugin("whitelabel");
+ }
+
const app = { openLink: jest.fn() };
const instanceUrl = "https://metabase.example";
@@ -114,4 +133,12 @@ describe("McpExploreButton", () => {
});
});
});
+
+ it("uses the custom application name when white-labelled", async () => {
+ setup({ applicationName: "Acme Analytics" });
+
+ expect(
+ await screen.findByRole("button", { name: "Explore in Acme Analytics" }),
+ ).toBeInTheDocument();
+ });
});
diff --git a/frontend/src/metabase/embedding/mcp/utils/getMcpAppsUserAndSettingsFetchError.ts b/frontend/src/metabase/embedding/mcp/utils/getMcpAppsUserAndSettingsFetchError.ts
index 4e4f36e5b05..cf73292e40d 100644
--- a/frontend/src/metabase/embedding/mcp/utils/getMcpAppsUserAndSettingsFetchError.ts
+++ b/frontend/src/metabase/embedding/mcp/utils/getMcpAppsUserAndSettingsFetchError.ts
@@ -1,5 +1,3 @@
-/* eslint-disable metabase/no-literal-metabase-strings */
-
import { match } from "ts-pattern";
import { t } from "ttag";
@@ -35,6 +33,6 @@ export const getMcpAppsUserAndSettingsFetchErrorMessage = (
.with(
"network",
() =>
- t`Could not connect to Metabase. Make sure this MCP client is enabled in AI settings and that Metabase is reachable.`,
+ t`Could not connect to the server. Ask your MCP client to show this again.`,
)
.exhaustive();
diff --git a/frontend/src/metabase/embedding/mcp/utils/getMcpQueryFetchError.ts b/frontend/src/metabase/embedding/mcp/utils/getMcpQueryFetchError.ts
index f96737a1e73..c520e33a32c 100644
--- a/frontend/src/metabase/embedding/mcp/utils/getMcpQueryFetchError.ts
+++ b/frontend/src/metabase/embedding/mcp/utils/getMcpQueryFetchError.ts
@@ -1,5 +1,3 @@
-/* eslint-disable metabase/no-literal-metabase-strings */
-
import { match } from "ts-pattern";
import { t } from "ttag";
@@ -42,6 +40,6 @@ export const getMcpQueryFetchErrorMessage = (
.with(
"network",
() =>
- t`Could not load this visualization. Make sure Metabase is reachable, then ask your MCP client to show this again.`,
+ t`Could not load this visualization. Ask your MCP client to show this again.`,
)
.exhaustive();