The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Move MCP url to the top and update inline origins copy (#78102)
Phoomparin Manob041c02f5a5f
diff --git a/frontend/src/metabase/admin/ai/McpAppsSettings.tsx b/frontend/src/metabase/admin/ai/McpAppsSettings.tsxindex b7a3d2a7209..07b5f33b995 100644--- a/frontend/src/metabase/admin/ai/McpAppsSettings.tsx+++ b/frontend/src/metabase/admin/ai/McpAppsSettings.tsx@@ -3,10 +3,11 @@ import { jt, t } from "ttag";import { SettingsSection } from "metabase/admin/components/SettingsSection";import { SettingHeader } from "metabase/admin/settings/components/SettingHeader";+import { AdminSettingInput } from "metabase/admin/settings/components/widgets/AdminSettingInput";import { useAdminSetting } from "metabase/api/utils";import { ExternalLink } from "metabase/common/components/ExternalLink";import { useDocsUrl } from "metabase/common/hooks";-import { Box, Flex, Stack, Switch, Text, TextInput } from "metabase/ui";+import { Box, Flex, Stack, Switch, Text } from "metabase/ui";import { CursorInstallLink } from "./CursorInstallLink";import { McpServerUrlSection } from "./MCPServerUrlSection";@@ -79,6 +80,8 @@ export const McpAppsSettings = ({ id }: { id?: string }) => {</ExternalLink>)}`}>+ <McpServerUrlSection />+{isEnabled && (<Stack gap="lg"><CommonMcpClientsSection />@@ -86,7 +89,6 @@ export const McpAppsSettings = ({ id }: { id?: string }) => {<CustomMcpOriginsSection /></Stack>)}- <McpServerUrlSection /></SettingsSection>);};@@ -144,35 +146,16 @@ function CommonMcpClientsSection() {}function CustomMcpOriginsSection() {- const { value: savedValue, updateSetting } = useAdminSetting(- "mcp-apps-cors-custom-origins",- );-- const [localValue, setLocalValue] = useState(savedValue ?? "");-- const handleBlur = useCallback(() => {- if (localValue !== savedValue) {- updateSetting({- key: "mcp-apps-cors-custom-origins",- value: localValue,- });- }- }, [localValue, savedValue, updateSetting]);-return (<Box>- <SettingHeader- id="custom-mcp-origins"- title={t`Custom inline chart origins`}- description={t`Add custom origins for MCP clients that should display inline charts. Separate values with a space.`}- />- <TextInput- mt="md"- value={localValue}- onChange={(e) => setLocalValue(e.target.value)}- onBlur={handleBlur}+ <AdminSettingInput+ name="mcp-apps-cors-custom-origins"+ title={t`Allowed origins for custom MCP clients`}+ description={t`To display charts in your self-hosted MCP clients (like LibreChat and Open WebUI), add each MCP client's base URL (origin) here. Separate origins with a space.`}+ inputType="text"placeholder="https://*.example.com"/>+<Text c="text-disabled" fz="sm" mt="xs">{t`Changes will take effect within one minute.`}</Text>diff --git a/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx b/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsxindex 88b02b45de4..5e0e92235ac 100644--- a/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx+++ b/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx@@ -7,7 +7,7 @@ import {setupUpdateSettingEndpoint,} from "__support__/server-mocks";import { mockSettings } from "__support__/settings";-import { renderWithProviders, screen } from "__support__/ui";+import { renderWithProviders, screen, waitFor } from "__support__/ui";import { createMockState } from "metabase/redux/store/mocks";import { createMockSettings } from "metabase-types/api/mocks";@@ -86,19 +86,6 @@ describe("McpAppsSettings", () => {).toBeInTheDocument();});- it("should show custom inline chart origins copy", async () => {- await setup();-- expect(- await screen.findByText("Custom inline chart origins"),- ).toBeInTheDocument();- expect(- await screen.findByText(- "Add custom origins for MCP clients that should display inline charts. Separate values with a space.",- ),- ).toBeInTheDocument();- });-it("can toggle all MCP clients on", async () => {await setup();@@ -132,11 +119,23 @@ describe("McpAppsSettings", () => {).toBeInTheDocument();});- it("can update custom origins on blur", async () => {- await setup();+ it("updates custom inline chart origins on blur", async () => {+ await setup({ customOrigins: "https://librechat.example.com" });const input = await screen.findByPlaceholderText("https://*.example.com");- await userEvent.type(input, "https://my-app.example.com");++ await waitFor(() => {+ expect(input).toHaveValue("https://librechat.example.com");+ });++ await userEvent.clear(input);++ // MCP client custom origins are separated by spaces+ await userEvent.type(+ input,+ "https://librechat.example.com https://openwebui.example.com",+ );+await userEvent.tab();const puts = await findRequests("PUT");@@ -144,7 +143,10 @@ describe("McpAppsSettings", () => {const [{ url, body }] = puts;expect(url).toContain("/setting/mcp-apps-cors-custom-origins");- expect(body).toEqual({ value: "https://my-app.example.com" });++ expect(body).toEqual({+ value: "https://librechat.example.com https://openwebui.example.com",+ });});it("hides MCP client configuration when the MCP server is off", async () => {