Skip to content

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

BOT-1668: hide the MCP server URL when the MCP server is disabled (#81195)

Andrei Simionescu3d5011e1009d
diff --git a/frontend/src/metabase/admin/ai/McpAppsSettings.tsx b/frontend/src/metabase/admin/ai/McpAppsSettings.tsx
index 4bb3035ae66..9e314f5d849 100644
--- a/frontend/src/metabase/admin/ai/McpAppsSettings.tsx
+++ b/frontend/src/metabase/admin/ai/McpAppsSettings.tsx
@@ -80,14 +80,16 @@ export const McpAppsSettings = ({ id }: { id?: string }) => {
</ExternalLink>
)}`}
>
- <McpServerUrlSection />
-
- {isEnabled && (
+ {isEnabled ? (
<Stack gap="lg">
+ <McpServerUrlSection />
+
<CommonMcpClientsSection />
<CustomMcpOriginsSection />
</Stack>
+ ) : (
+ <></>
)}
</SettingsSection>
);
diff --git a/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx b/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx
index 5e0e92235ac..f6dace92a9c 100644
--- a/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx
+++ b/frontend/src/metabase/admin/ai/McpAppsSettings.unit.spec.tsx
@@ -13,6 +13,9 @@ import { createMockSettings } from "metabase-types/api/mocks";
import { McpAppsSettings } from "./McpAppsSettings";
+const SITE_URL = "https://metabase.example.com";
+const MCP_URL = `${SITE_URL}/api/metabase-mcp`;
+
const setup = async ({
commonOrigins = [],
customOrigins = "",
@@ -26,6 +29,7 @@ const setup = async ({
"mcp-enabled?": enabled,
"mcp-apps-cors-enabled-clients": commonOrigins,
"mcp-apps-cors-custom-origins": customOrigins,
+ "site-url": SITE_URL,
});
setupPropertiesEndpoints(settings);
@@ -38,7 +42,9 @@ const setup = async ({
}),
});
- await screen.findByText("MCP server");
+ if (enabled) {
+ await screen.findByText("MCP server");
+ }
};
describe("McpAppsSettings", () => {
@@ -149,12 +155,22 @@ describe("McpAppsSettings", () => {
});
});
- it("hides MCP client configuration when the MCP server is off", async () => {
+ it("keeps the toggle but hides the server URL and MCP client configuration when the MCP server is off", async () => {
await setup({ enabled: false });
+ expect(
+ await screen.findByRole("switch", { name: "MCP server" }),
+ ).toBeInTheDocument();
+ expect(screen.queryByDisplayValue(MCP_URL)).not.toBeInTheDocument();
expect(screen.queryByLabelText("Claude")).not.toBeInTheDocument();
expect(
screen.queryByPlaceholderText("https://*.example.com"),
).not.toBeInTheDocument();
});
+
+ it("shows the server URL when the MCP server is on", async () => {
+ await setup();
+
+ expect(await screen.findByDisplayValue(MCP_URL)).toBeInTheDocument();
+ });
});