Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(mcp): withhold Allow unless the consent page holds a served ceiling (#21254)

Vincent Huang919b74fdbb33
diff --git a/backend/api/auth/mcp_ceiling.go b/backend/api/auth/mcp_ceiling.go
index 8676c5083f..907a3479ac 100644
--- a/backend/api/auth/mcp_ceiling.go
+++ b/backend/api/auth/mcp_ceiling.go
@@ -4,9 +4,11 @@ import storepb "github.com/bytebase/bytebase/backend/generated-go/store"
// MCPCeilingVerdict is what a read of a workspace's MCP capability ceiling
// means to a caller deciding whether to proceed. Every reader of the setting
-// decides from it and says so with Refusal — the consent, the token endpoint,
-// the /mcp connection gate, the per-request gate, and the mode-contents read —
-// so no two can disagree about a workspace or describe it two ways.
+// decides from it — the consent, the token endpoint, the /mcp connection gate,
+// the per-request gate, and the mode-contents read — so no two can disagree
+// about a workspace. Every door but the mode-contents read says so with
+// Refusal; that one answers the policy verdicts in its response body and keeps
+// Refusal for the outage (BOT-106).
type MCPCeilingVerdict int
// Each value names what an admin would have to do about it, which is what the
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index 50a3112bc4..02dccafc3a 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -15622,7 +15622,10 @@ components:
nothing to get it by.
capability:
title: capability
- description: The ceiling in force for this workspace.
+ description: |-
+ The ceiling in force for this workspace. A value no row in modes serves,
+ CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+ the stored row and every MCP connection is refused.
$ref: '#/components/schemas/bytebase.v1.MCPSetting.Capability'
modes:
type: array
diff --git a/backend/api/v1/mcp_info.go b/backend/api/v1/mcp_info.go
index f8a0d6ba5d..6191551a8c 100644
--- a/backend/api/v1/mcp_info.go
+++ b/backend/api/v1/mcp_info.go
@@ -36,21 +36,21 @@ func (s *WorkspaceService) GetMCPInfo(ctx context.Context, _ *connect.Request[v1
return nil, connect.NewError(connect.CodeInternal, errors.New("no workspace on the request"))
}
settings, err := s.mcpSettingsForInfo(ctx, workspaceID)
- // Every verdict is decided here, not only the read failures. DISABLED is
- // the one refusing ceiling this still answers under, deliberately: an admin
- // looking at a workspace with MCP off is exactly who needs to see what the
- // other modes contain. A ceiling this build does not serve is different —
- // reporting it as "in force" would describe a state the build does not run,
- // beside a modes list with no row for it.
+ // Every verdict but an outage is answered, the refusing ceilings included:
+ // the mode contents never come from the stored row, so a workspace whose
+ // ceiling nothing serves still owes the repairing admin the comparison, and
+ // the consent page a policy to disclose (BOT-106). capability carries the
+ // refusal, as a value no row in modes serves.
switch verdict := auth.ClassifyMCPCeiling(settings, err); verdict {
- case auth.MCPCeilingServes, auth.MCPCeilingDisabled:
- case auth.MCPCeilingUnserved:
- return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New(verdict.Refusal()))
+ case auth.MCPCeilingServes, auth.MCPCeilingDisabled, auth.MCPCeilingUnserved:
default:
// The store error stays in the log. This method is served to MCP
// sessions and the tool layer renders a connect message into what the
// model reads, so a driver error text would leave the metadata
// database's shape in an agent's context.
+ //
+ // An outage has no ceiling to describe, and answering with an empty one
+ // would be indistinguishable from a row nobody can resolve.
slog.Error("failed to read the MCP setting", slog.String("workspace", workspaceID), log.BBError(err))
return nil, connect.NewError(connect.CodeUnavailable, errors.New(verdict.Refusal()))
}
diff --git a/backend/api/v1/mcp_info_test.go b/backend/api/v1/mcp_info_test.go
index f4897c28b4..6a10a36cc5 100644
--- a/backend/api/v1/mcp_info_test.go
+++ b/backend/api/v1/mcp_info_test.go
@@ -363,7 +363,8 @@ func TestGetMCPInfoHandler(t *testing.T) {
info, err := get(workspaceCtx())
require.NoError(t, err)
require.Equal(t, "workspaces/"+workspaceID, info.Workspace)
- require.Equal(t, v1pb.MCPSetting_READ_ONLY, info.Capability)
+ require.Equal(t, v1pb.MCPSetting_READ_ONLY, info.Capability,
+ "a new workspace is seeded READ_ONLY; only a workspace with no row at all falls back to READ_WRITE")
require.False(t, info.IgnoreMaskingExemptions)
// The list is the live registry's, not a fixture: every entry must be a
@@ -402,20 +403,63 @@ func TestGetMCPInfoHandler(t *testing.T) {
"an admin with MCP off is exactly who needs to see what the other modes contain")
})
- t.Run("an unknown capability fails closed", func(t *testing.T) {
+ // The two subtests below are BOT-106. Both ceilings refuse every MCP
+ // connection and both used to refuse this call whole, which took the mode
+ // comparison away from the admin repairing the row and left the consent
+ // page with no policy to disclose.
+ t.Run("a ceiling this build cannot read is described, not refused", func(t *testing.T) {
setCeiling(t, `{"capability":"READ_ONLYY"}`)
- _, err := get(workspaceCtx())
- require.Equal(t, connect.CodeFailedPrecondition, connect.CodeOf(err))
- require.Contains(t, err.Error(), "not one this build serves")
+ info, err := get(workspaceCtx())
+ require.NoError(t, err, "none of the mode contents come from the stored row")
+ require.Equal(t, v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, info.Capability,
+ "a ceiling nobody can resolve must not arrive as a mode, least of all the permissive one")
+ require.False(t, info.IgnoreMaskingExemptions,
+ "no MCP request runs under this ceiling, so the toggle carries neither the row's value nor a decision")
+ require.Len(t, info.Modes, 3, "the comparison this page exists for")
+ require.Equal(t, len(mcpServedMethods(protoregistry.GlobalFiles)), len(info.Methods))
+ require.NotEmpty(t, info.Engines)
})
- t.Run("a ceiling this build does not serve fails closed", func(t *testing.T) {
- // The reserved 2, or a value a newer release wrote. It parses, so
- // nothing but the verdict catches it.
+ // The subtest above covers a mistyped enum NAME, which unmarshals away to
+ // unset and is therefore describable. A wrong-TYPED value is different: it
+ // fails the whole unmarshal, so the generic setting read errors and there is
+ // no ceiling in the row to describe. The last two rows are why that is a
+ // property of the row and not of the capability — the capability is
+ // readable and a sibling field is not, and one failed unmarshal takes the
+ // whole row with it.
+ t.Run("a row that does not unmarshal is refused, not described", func(t *testing.T) {
+ for _, row := range []string{
+ `{"capability":{}}`,
+ `{"capability":true}`,
+ `{"capability":1.5}`,
+ `{"capability":[]}`,
+ `{"capability":"READ_ONLY","ignoreMaskingExemptions":[]}`,
+ `{"capability":"READ_ONLY","ignoreMaskingExemptions":"yes"}`,
+ } {
+ setCeiling(t, row)
+ _, err := get(workspaceCtx())
+ require.Error(t, err, "%s: no ceiling in the row to describe", row)
+ require.Equal(t, connect.CodeUnavailable, connect.CodeOf(err), row)
+ }
+ })
+
+ t.Run("a ceiling no mode serves is described by the value nobody serves", func(t *testing.T) {
+ // The reserved 2, or a value a newer release wrote. It parses, so the
+ // number is the answer and needs no field of its own: modes has no row
+ // for it, which is what tells a client this ceiling serves nothing.
setCeiling(t, `{"capability":2}`)
- _, err := get(workspaceCtx())
- require.Equal(t, connect.CodeFailedPrecondition, connect.CodeOf(err))
- require.Contains(t, err.Error(), "not one this build serves")
+ info, err := get(workspaceCtx())
+ require.NoError(t, err)
+ require.NotEqual(t, v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, info.Capability,
+ "it parsed; the number is the answer")
+ require.Equal(t, v1pb.MCPSetting_Capability(2), info.Capability)
+ // Len first: the loop below passes vacuously on an empty table, and an
+ // empty table is what turns every consent page into this same card.
+ require.Len(t, info.Modes, 3, "the comparison this page exists for")
+ for _, mode := range info.Modes {
+ require.NotEqual(t, v1pb.MCPSetting_Capability(2), mode.Capability)
+ }
+ require.NotEmpty(t, info.Engines)
})
t.Run("the gate's resolution wins over a second read", func(t *testing.T) {
diff --git a/backend/generated-go/v1/workspace_service.pb.go b/backend/generated-go/v1/workspace_service.pb.go
index e7cc01e7e0..6b206d0652 100644
--- a/backend/generated-go/v1/workspace_service.pb.go
+++ b/backend/generated-go/v1/workspace_service.pb.go
@@ -196,7 +196,9 @@ type MCPInfo struct {
// message's own resource name — MCPInfo is not a named resource and there is
// nothing to get it by.
Workspace string `protobuf:"bytes,1,opt,name=workspace,proto3" json:"workspace,omitempty"`
- // The ceiling in force for this workspace.
+ // The ceiling in force for this workspace. A value no row in modes serves,
+ // CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+ // the stored row and every MCP connection is refused.
Capability MCPSetting_Capability `protobuf:"varint,2,opt,name=capability,proto3,enum=bytebase.v1.MCPSetting_Capability" json:"capability,omitempty"`
// What each ceiling serves, including the one in force, so an admin can
// compare the choices rather than only read the current answer.
diff --git a/frontend/scripts/check-react-i18n.mjs b/frontend/scripts/check-react-i18n.mjs
index e5f579d2c8..318c3e38da 100644
--- a/frontend/scripts/check-react-i18n.mjs
+++ b/frontend/scripts/check-react-i18n.mjs
@@ -61,6 +61,13 @@ const DYNAMIC_PREFIXES = [
"settings.mcp.policy.unreadable.title",
"settings.mcp.policy.unserved.description",
"settings.mcp.policy.unserved.title",
+ // Built as `…undisclosed.${reason}.<suffix>` over a reason the consent page
+ // derives: title, description and line for all four, plus retry for the two
+ // that offer one. Listed per reason rather than as one subtree, which would
+ // also exempt the two sibling keys named literally.
+ "oauth2.consent.mcp.undisclosed.outdated.",
+ "oauth2.consent.mcp.undisclosed.unknown.",
+ "oauth2.consent.mcp.undisclosed.unserved.",
// Keys consumed by SHARED non-React `.ts` modules that translate via
// `@/lib/i18n` (the same react-i18next instance — vue-i18n is gone), but
// live OUTSIDE this checker's React-only scan, so they read as unused. They
diff --git a/frontend/src/components/mcp/MCPModeContentsSheet.tsx b/frontend/src/components/mcp/MCPModeContentsSheet.tsx
index 8b8b267267..c80d47d85b 100644
--- a/frontend/src/components/mcp/MCPModeContentsSheet.tsx
+++ b/frontend/src/components/mcp/MCPModeContentsSheet.tsx
@@ -36,10 +36,10 @@ interface Props {
readonly capability: MCPSetting_Capability;
/**
* Required, and every caller gates its trigger on having it. An optional one
- * would let a pending or refused GetMCPInfo render as a mode that serves
+ * would let a pending or failed GetMCPInfo render as a mode that serves
* nothing — "0 of 0" over a workspace whose ceiling this drawer exists to
- * explain. GetMCPInfo refuses outright under an invalid or unserved
- * ceiling (BOT-106), which is exactly when an admin opens this.
+ * explain. A broken ceiling is answered rather than refused (BOT-106), so
+ * the drawer is available on the repair path; an outage still is not.
*/
readonly info: MCPInfo;
readonly modeLabel: string;
diff --git a/frontend/src/components/mcp/mcpPolicy.test.ts b/frontend/src/components/mcp/mcpPolicy.test.ts
index 662733a7c6..5900fd6846 100644
--- a/frontend/src/components/mcp/mcpPolicy.test.ts
+++ b/frontend/src/components/mcp/mcpPolicy.test.ts
@@ -8,6 +8,7 @@ import {
MCPEngineEnforcement_Masking,
MCPEngineEnforcement_ReadOnlyDepth,
MCPEngineEnforcementSchema,
+ MCPInfoSchema,
MCPMethodSchema,
} from "@/types/proto-es/v1/workspace_service_pb";
import {
@@ -16,6 +17,7 @@ import {
groupMethodsByService,
isMCPMode,
methodsServedBy,
+ readConsentCeiling,
serviceOfMethod,
} from "./mcpPolicy";
@@ -186,3 +188,61 @@ describe("grouping", () => {
]);
});
});
+
+// The serving table every real response carries, one row per ceiling the gate
+// evaluates. DISABLED is a row rather than an omission: it is a mode that
+// decided to serve nothing, which is not the same as a mode nobody decided
+// about (backend/api/v1/mcp_gate.go, mcpServingClasses).
+const SERVED_MODES = [1, 3, 4];
+
+const infoWith = (fields: Partial<{ capability: number; modes: number[] }>) =>
+ create(MCPInfoSchema, {
+ capability: fields.capability ?? MCPSetting_Capability.READ_ONLY,
+ modes: (fields.modes ?? SERVED_MODES).map((capability) =>
+ create(MCPCapabilityModeSchema, { capability })
+ ),
+ });
+
+describe("readConsentCeiling", () => {
+ test("no response is the policy being unknown, not absent", () => {
+ expect(readConsentCeiling(undefined)).toEqual({ kind: "unknown" });
+ });
+
+ test("a served ceiling carries the response the disclosure needs", () => {
+ const info = infoWith({ capability: 4 });
+ expect(readConsentCeiling(info)).toEqual({ kind: "mode", info });
+ });
+
+ test("disabled is a policy, so it reaches its own screen", () => {
+ // Not undisclosed: an admin turned MCP off, which is a decision this page
+ // can name and the one refusing ceiling with a screen of its own.
+ const info = infoWith({ capability: 1 });
+ expect(readConsentCeiling(info)).toEqual({ kind: "mode", info });
+ });
+
+ test("an unresolvable stored value is unserved, like any value no mode serves", () => {
+ // The capability arrives unspecified when nothing could be resolved from
+ // the row. It has no row in modes either, and the remedy is the same as for
+ // a value that parsed but nothing serves, so it is one state.
+ expect(readConsentCeiling(infoWith({ capability: 0 }))).toEqual({
+ kind: "unserved",
+ });
+ });
+
+ test("a value with no row in the serving table is unserved", () => {
+ expect(readConsentCeiling(infoWith({ capability: 2 }))).toEqual({
+ kind: "unserved",
+ });
+ });
+
+ test("a served ceiling this bundle cannot name is outdated, not unserved", () => {
+ // The difference decides the instruction on screen: reload, or find an
+ // admin. The server serves this one, so there is nothing for an admin to
+ // repair.
+ expect(
+ readConsentCeiling(
+ infoWith({ capability: 5, modes: [...SERVED_MODES, 5] })
+ )
+ ).toEqual({ kind: "outdated" });
+ });
+});
diff --git a/frontend/src/components/mcp/mcpPolicy.ts b/frontend/src/components/mcp/mcpPolicy.ts
index 3e1f923d09..0b4168a1e7 100644
--- a/frontend/src/components/mcp/mcpPolicy.ts
+++ b/frontend/src/components/mcp/mcpPolicy.ts
@@ -155,3 +155,46 @@ export const modeFor = (
capability: MCPSetting_Capability
): MCPCapabilityMode | undefined =>
info?.modes.find((mode) => mode.capability === capability);
+
+/**
+ * What the consent page can truthfully tell someone about to approve a client.
+ *
+ * Only `mode` is a policy it can disclose. The other four are the ways it can
+ * fail to hold one, kept apart because the remedy differs: retry, reload, or
+ * ask an admin (BOT-106).
+ */
+export type ConsentCeiling =
+ /** Carries the response, so the disclosure cannot be rendered without it. */
+ | { kind: "mode"; info: MCPInfo }
+ /** GetMCPInfo failed or timed out. The policy is not known to be anything. */
+ | { kind: "unknown" }
+ /** No row in modes serves the stored value, CAPABILITY_UNSPECIFIED included. */
+ | { kind: "unserved" }
+ /** The server serves it and this bundle has no name for it. */
+ | { kind: "outdated" };
+
+/**
+ * Reads a GetMCPInfo response — or its absence — into that state.
+ *
+ * modes is the serving table the gate evaluates; MCP_CAPABILITY_CHOICES is the
+ * set this bundle has copy for. A ceiling a newer release added is in the first
+ * and not the second, which is the one case where reloading helps rather than
+ * finding an admin.
+ */
+export const readConsentCeiling = (
+ info: MCPInfo | undefined
+): ConsentCeiling => {
+ if (!info) {
+ return { kind: "unknown" };
+ }
+ // Covers a value nothing could resolve as well as one that resolved to a
+ // ceiling no mode serves: both arrive with no row in modes, and both leave an
+ // admin the same job.
+ if (!modeFor(info, info.capability)) {
+ return { kind: "unserved" };
+ }
+ if (!isMCPMode(info.capability)) {
+ return { kind: "outdated" };
+ }
+ return { kind: "mode", info };
+};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 74bc6663c4..b1e68d909a 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1599,10 +1599,31 @@
},
"see-contents": "See what this workspace's policy allows",
"title": "This session may",
+ "undisclosed": {
+ "line": {
+ "nothing-approved": "Nothing has been approved and nothing is connected"
+ },
+ "outdated": {
+ "description": "This workspace's MCP policy is newer than the page you have open, so what a session may do cannot be shown here.",
+ "line": "Reload to get the current policy before you approve anything",
+ "retry": "Reload",
+ "title": "This page is older than this workspace's MCP policy"
+ },
+ "policy-label": "Workspace policy",
+ "unknown": {
+ "description": "Bytebase could not read this workspace's MCP access policy just now.",
+ "line": "What this session would be allowed to do cannot be shown",
+ "retry": "Check again",
+ "title": "The MCP policy could not be checked"
+ },
+ "unserved": {
+ "description": "This workspace stores a policy value this Bytebase version does not serve. Every MCP connection is being refused.",
+ "line": "No AI session can connect until an admin picks a supported policy",
+ "title": "This workspace's MCP policy is not one this version serves"
+ }
+ },
"write-caution": "An AI session with write access makes real changes. Approve only on a machine you control."
},
- "permission-access": "Access your Bytebase account with your permissions",
- "permissions": "This application will be able to:",
"title": "Authorization Request",
"workspace-label": "Granting access to workspace"
}
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 03201d5aed..4a6732e789 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1599,10 +1599,31 @@
},
"see-contents": "Ver lo que permite la política de este espacio de trabajo",
"title": "Esta sesión puede",
+ "undisclosed": {
+ "line": {
+ "nothing-approved": "No se ha aprobado nada y no hay nada conectado"
+ },
+ "outdated": {
+ "description": "La política MCP de este espacio de trabajo es más reciente que la página que tiene abierta, así que aquí no se puede mostrar lo que una sesión puede hacer.",
+ "line": "Recargue para obtener la política actual antes de aprobar nada",
+ "retry": "Recargar",
+ "title": "Esta página es más antigua que la política MCP de este espacio de trabajo"
+ },
+ "policy-label": "Política del espacio de trabajo",
+ "unknown": {
+ "description": "Bytebase no ha podido leer la política de acceso MCP de este espacio de trabajo en este momento.",
+ "line": "No se puede mostrar lo que esta sesión tendría permitido hacer",
+ "retry": "Comprobar de nuevo",
+ "title": "No se pudo comprobar la política MCP"
+ },
+ "unserved": {
+ "description": "Este espacio de trabajo almacena un valor de política que esta versión de Bytebase no sirve. Se está rechazando toda conexión MCP.",
+ "line": "Ninguna sesión de IA puede conectarse hasta que un administrador elija una política admitida",
+ "title": "La política MCP de este espacio de trabajo no es una que sirva esta versión"
+ }
+ },
"write-caution": "Una sesión de IA con acceso de escritura hace cambios reales. Apruébela solo en una máquina que usted controle."
},
- "permission-access": "Acceder a tu cuenta de Bytebase con tus permisos",
- "permissions": "Esta aplicación podrá:",
"title": "Solicitud de autorización",
"workspace-label": "Concediendo acceso al workspace"
}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 16c8084490..38aed2a1af 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1599,10 +1599,31 @@
},
"see-contents": "このワークスペースのポリシーが許可する範囲を見る",
"title": "このセッションでできること",
+ "undisclosed": {
+ "line": {
+ "nothing-approved": "何も承認されておらず、何も接続されていません"
+ },
+ "outdated": {
+ "description": "このワークスペースの MCP ポリシーは、開いているページより新しいため、セッションに何が許可されるかをここでは表示できません。",
+ "line": "承認する前に再読み込みして最新のポリシーを取得してください",
+ "retry": "再読み込み",
+ "title": "このページはこのワークスペースの MCP ポリシーより古い状態です"
+ },
+ "policy-label": "ワークスペースポリシー",
+ "unknown": {
+ "description": "Bytebase は現在、このワークスペースの MCP アクセスポリシーを読み取れませんでした。",
+ "line": "このセッションに何が許可されるかを表示できません",
+ "retry": "再確認",
+ "title": "MCP ポリシーを確認できませんでした"
+ },
+ "unserved": {
+ "description": "このワークスペースには、この Bytebase バージョンが提供しないポリシー値が保存されています。すべての MCP 接続が拒否されています。",
+ "line": "管理者がサポートされたポリシーを選ぶまで、どの AI セッションも接続できません",
+ "title": "このワークスペースの MCP ポリシーはこのバージョンが提供するものではありません"
+ }
+ },
"write-caution": "書き込み権限のある AI セッションは実際に変更を加えます。自分が管理しているマシンでのみ承認してください。"
},
- "permission-access": "あなたの権限で Bytebase アカウントにアクセス",
- "permissions": "このアプリケーションは以下のことができます:",
"title": "認証リクエスト",
"workspace-label": "アクセスを許可するワークスペース"
}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index c1a81e428d..9f07ca7ce6 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1599,10 +1599,31 @@
},
"see-contents": "Xem những gì chính sách của không gian làm việc này cho phép",
"title": "Phiên này có thể",
+ "undisclosed": {
+ "line": {
+ "nothing-approved": "Chưa có gì được phê duyệt và chưa có gì được kết nối"
+ },
+ "outdated": {
+ "description": "Chính sách MCP của không gian làm việc này mới hơn trang bạn đang mở, nên không thể hiển thị ở đây những gì một phiên được phép làm.",
+ "line": "Hãy tải lại để lấy chính sách hiện tại trước khi phê duyệt bất kỳ điều gì",
+ "retry": "Tải lại",
+ "title": "Trang này cũ hơn chính sách MCP của không gian làm việc"
+ },
+ "policy-label": "Chính sách không gian làm việc",
+ "unknown": {
+ "description": "Bytebase hiện chưa đọc được chính sách truy cập MCP của không gian làm việc này.",
+ "line": "Không thể hiển thị những gì phiên này sẽ được phép làm",
+ "retry": "Kiểm tra lại",
+ "title": "Không kiểm tra được chính sách MCP"
+ },
+ "unserved": {
+ "description": "Không gian làm việc này lưu một giá trị chính sách mà phiên bản Bytebase này không phục vụ. Mọi kết nối MCP đang bị từ chối.",
+ "line": "Không phiên AI nào kết nối được cho tới khi quản trị viên chọn một chính sách được hỗ trợ",
+ "title": "Chính sách MCP của không gian làm việc này không được phiên bản này phục vụ"
+ }
+ },
"write-caution": "Phiên AI có quyền ghi sẽ tạo ra thay đổi thật. Chỉ phê duyệt trên máy bạn kiểm soát."
},
- "permission-access": "Truy cập tài khoản Bytebase của bạn với quyền hạn của bạn",
- "permissions": "Ứng dụng này sẽ có thể:",
"title": "Yêu cầu ủy quyền",
"workspace-label": "Cấp quyền truy cập vào workspace"
}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index c7c80ee065..1edf1a1b8f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1599,10 +1599,31 @@
},
"see-contents": "查看此工作区策略允许的范围",
"title": "此会话可以",
+ "undisclosed": {
+ "line": {
+ "nothing-approved": "尚未批准任何内容,也未建立任何连接"
+ },
+ "outdated": {
+ "description": "本工作空间的 MCP 策略比您打开的页面更新,因此这里无法显示会话被允许执行的操作。",
+ "line": "请先重新加载获取当前策略,再批准任何内容",
+ "retry": "重新加载",
+ "title": "此页面比本工作空间的 MCP 策略更旧"
+ },
+ "policy-label": "工作空间策略",
+ "unknown": {
+ "description": "Bytebase 目前无法读取本工作空间的 MCP 访问策略。",
+ "line": "无法显示本次会话将被允许执行的操作",
+ "retry": "重新检查",
+ "title": "无法确认 MCP 策略"
+ },
+ "unserved": {
+ "description": "本工作空间存储了此 Bytebase 版本不支持的策略值。所有 MCP 连接都在被拒绝。",
+ "line": "在管理员选择受支持的策略之前,任何 AI 会话都无法连接",
+ "title": "本工作空间的 MCP 策略不是此版本所支持的"
+ }
+ },
"write-caution": "具有写权限的 AI 会话会造成真实变更。请仅在你可控的机器上批准。"
},
- "permission-access": "使用您的权限访问您的 Bytebase 账户",
- "permissions": "此应用程序将能够:",
"title": "授权请求",
"workspace-label": "授权访问的工作空间"
}
diff --git a/frontend/src/routes/auth/MCPConsentUndisclosed.tsx b/frontend/src/routes/auth/MCPConsentUndisclosed.tsx
new file mode 100644
index 0000000000..ea525a404e
--- /dev/null
+++ b/frontend/src/routes/auth/MCPConsentUndisclosed.tsx
@@ -0,0 +1,96 @@
+import { ScrollText } from "lucide-react";
+import type { ReactNode } from "react";
+import { useTranslation } from "react-i18next";
+import { Alert } from "@/components/ui/alert";
+import { Button } from "@/components/ui/button";
+
+/** Why this page cannot say what approving would grant. */
+export type UndisclosedReason = "unknown" | "unserved" | "outdated";
+
+interface Props {
+ readonly reason: UndisclosedReason;
+ /** The workspace row, so a SaaS user can switch to one that permits MCP. */
+ readonly workspaceCard: ReactNode;
+ /** Omitted for the two reasons an admin has to fix. See retryFor. */
+ readonly onRetry?: () => void;
+ readonly retrying: boolean;
+ readonly onDismiss: () => void;
+ readonly dismissing: boolean;
+}
+
+/**
+ * The consent this page will not collect, because it cannot say what it is for.
+ *
+ * Every grant this server issues is an MCP grant and the workspace ceiling
+ * decides what one is worth, so with no ceiling to disclose there is no Allow:
+ * the disclosure is the consent (BOT-106).
+ *
+ * The button has to go rather than be left to fail. Only two of these four
+ * states also refuse the POST (backend/api/oauth2/consent_audit.go); a failed
+ * read here says nothing about the read the POST makes for itself.
+ */
+export function MCPConsentUndisclosed({
+ reason,
+ workspaceCard,
+ onRetry,
+ retrying,
+ onDismiss,
+ dismissing,
+}: Props) {
+ const { t } = useTranslation();
+ const key = `oauth2.consent.mcp.undisclosed.${reason}`;
+
+ return (
+ <div className="flex flex-col gap-6">
+ <div className="text-center flex flex-col gap-2">
+ <h1 className="text-xl font-semibold text-main">{t(`${key}.title`)}</h1>
+ <p className="text-control">{t(`${key}.description`)}</p>
+ </div>
+
+ {workspaceCard}
+
+ {/* The status, not a detail: this line is the whole reason there is no
+ Allow, and it arrives after the policy read settles. Alert carries
+ role="alert" so a screen reader announces it when it appears, which a
+ styled div cannot do. Placed beside the details panel rather than
+ inside it, the way MCPConsentCeiling places its write caution. */}
+ <Alert variant="error" description={t(`${key}.line`)} />
+
+ <div className="bg-control-bg rounded-sm p-4 flex flex-col gap-3">
+ <p className="text-sm text-control-light">
+ {t("oauth2.consent.mcp.undisclosed.policy-label")}
+ </p>
+ <ul className="text-sm text-main flex flex-col gap-2">
+ <li className="flex items-start gap-2">
+ <ScrollText className="mt-0.5 size-4 shrink-0 text-control-light" />
+ <span>
+ {t("oauth2.consent.mcp.undisclosed.line.nothing-approved")}
+ </span>
+ </li>
+ </ul>
+ </div>
+
+ <div className="flex gap-x-2">
+ <Button
+ appearance="outline"
+ size="lg"
+ className="flex-1"
+ disabled={dismissing || retrying}
+ onClick={onDismiss}
+ >
+ {t("common.close")}
+ </Button>
+ {onRetry && (
+ <Button
+ size="lg"
+ className="flex-1"
+ disabled={dismissing || retrying}
+ onClick={onRetry}
+ >
+ {t(`${key}.retry`)}
+ </Button>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx
index 0a168054ac..f8cb84219d 100644
--- a/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx
+++ b/frontend/src/routes/auth/OAuth2ConsentPage.test.tsx
@@ -159,6 +159,15 @@ const renderIntoContainer = (element: ReactElement) => {
};
};
+// Every real GetMCPInfo response carries one row per ceiling the gate serves.
+// The page reads that table to tell a policy it can disclose from one the
+// server refuses, so a fixture without it is not a response the server sends.
+const SERVED_MODES = [
+ { capability: 1 },
+ { capability: 3 },
+ { capability: 4 },
+];
+
const flushPromises = () =>
act(async () => {
await Promise.resolve();
@@ -180,8 +189,17 @@ beforeEach(async () => {
globalThis.fetch = mocks.fetchImpl as typeof fetch;
mocks.fetchImpl.mockReset();
mocks.getMCPInfo.mockReset();
- // Default: the ceiling read fails, which is the pre-1b-6 shape of the card.
- mocks.getMCPInfo.mockRejectedValue(new Error("no ceiling"));
+ // Default: a served read-only ceiling, the page's ordinary case. Allow
+ // renders only under one, so a failing default would leave every test that
+ // is not about the ceiling asserting against the undisclosed card.
+ mocks.getMCPInfo.mockResolvedValue({
+ capability: 3,
+ ignoreMaskingExemptions: false,
+ dataMaskingAvailable: true,
+ modes: SERVED_MODES,
+ methods: [],
+ engines: [],
+ });
({ OAuth2ConsentPage } = await import("./OAuth2ConsentPage"));
});
@@ -509,13 +527,13 @@ describe("OAuth2ConsentPage", () => {
code_challenge_method: "S256",
});
- const renderWithCeiling = async (info: unknown) => {
+ const renderWithCeiling = async (info: Record<string, unknown>) => {
mocks.currentRoute.value.query = consentQuery();
mocks.fetchImpl.mockResolvedValue({
ok: true,
json: async () => ({ client_name: "Acme" }),
});
- mocks.getMCPInfo.mockResolvedValue(info);
+ mocks.getMCPInfo.mockResolvedValue({ modes: SERVED_MODES, ...info });
const handle = renderIntoContainer(<OAuth2ConsentPage />);
handle.render();
await flushPromises();
@@ -547,7 +565,6 @@ describe("OAuth2ConsentPage", () => {
const { container, unmount } = await renderWithCeiling({
capability: 3,
ignoreMaskingExemptions: false,
- modes: [],
methods: [],
engines: [],
});
@@ -567,7 +584,6 @@ describe("OAuth2ConsentPage", () => {
capability: 4,
ignoreMaskingExemptions: true,
dataMaskingAvailable: true,
- modes: [],
methods: [],
engines: [],
});
@@ -586,7 +602,6 @@ describe("OAuth2ConsentPage", () => {
capability: 4,
ignoreMaskingExemptions: true,
dataMaskingAvailable: false,
- modes: [],
methods: [],
engines: [],
});
@@ -607,7 +622,6 @@ describe("OAuth2ConsentPage", () => {
capability: 1,
ignoreMaskingExemptions: false,
dataMaskingAvailable: true,
- modes: [],
methods: [],
engines: [],
});
@@ -640,7 +654,6 @@ describe("OAuth2ConsentPage", () => {
capability: 1,
ignoreMaskingExemptions: false,
dataMaskingAvailable: true,
- modes: [],
methods: [],
engines: [],
});
@@ -652,7 +665,6 @@ describe("OAuth2ConsentPage", () => {
const { container, unmount } = await renderWithCeiling({
capability: 1,
ignoreMaskingExemptions: false,
- modes: [],
methods: [],
engines: [],
});
@@ -666,22 +678,140 @@ describe("OAuth2ConsentPage", () => {
unmount();
});
- test("an unreadable ceiling leaves the card as it was", async () => {
- // GetMCPInfo refuses under a ceiling this build cannot read. The backend
- // still refuses the POST with its own page, so the card falls back rather
- // than blocking a consent on a read this page does not own.
+ // BOT-106, and the reason this is a blocker rather than a tidy-up. The page
+ // used to fall through to a generic "access your account" card with Allow
+ // live whenever GetMCPInfo failed for ANY reason. The two broken-ceiling
+ // cases were cosmetic — the POST refuses those anyway — but a transient
+ // failure is not: the POST reads the ceiling for itself, succeeds, and issues
+ // a grant against a card that never named the ceiling it was granting.
+ //
+ // A timeout arrives here the same way: the client throws, and the page cannot
+ // tell a deadline from a refusal, which is the whole point of failing closed.
+ test("a failed policy read offers no grant and can be retried", async () => {
mocks.currentRoute.value.query = consentQuery();
mocks.fetchImpl.mockResolvedValue({
ok: true,
json: async () => ({ client_name: "Acme" }),
});
+ mocks.getMCPInfo.mockRejectedValueOnce(new Error("deadline exceeded"));
+
const { container, render, unmount } = renderIntoContainer(
<OAuth2ConsentPage />
);
render();
await flushPromises();
- expect(container.textContent).toContain("oauth2.consent.permission-access");
+
+ expect(container.textContent).toContain(
+ "oauth2.consent.mcp.undisclosed.unknown.title"
+ );
+ // The hole: neither the grant button nor the form that carries it.
+ expect(container.textContent).not.toContain("common.allow");
+ expect(container.querySelector('form[method="POST"]')).toBeNull();
+
+ // The default mock resolves, so the retry reaches a ceiling and the page
+ // becomes the ordinary consent card — the failure was not terminal.
+ const retry = [...container.querySelectorAll("button")].find((b) =>
+ b.textContent?.includes("oauth2.consent.mcp.undisclosed.unknown.retry")
+ );
+ expect(retry).toBeDefined();
+ await act(async () => {
+ retry?.click();
+ });
+ await flushPromises();
+ expect(container.textContent).toContain("oauth2.consent.mcp.line.read");
expect(container.textContent).toContain("common.allow");
unmount();
});
+
+ test("a ceiling no mode serves says so and offers no grant", async () => {
+ const { container, unmount } = await renderWithCeiling({
+ // The reserved 2, or a ceiling a newer release wrote. It parses, so only
+ // its absence from the serving table catches it.
+ capability: 2,
+ ignoreMaskingExemptions: false,
+ dataMaskingAvailable: true,
+ methods: [],
+ engines: [],
+ });
+ expect(container.textContent).toContain(
+ "oauth2.consent.mcp.undisclosed.unserved.title"
+ );
+ expect(container.textContent).not.toContain("common.allow");
+ // The other state only an admin can fix, held to the same rule.
+ expect(container.textContent).not.toContain(
+ "oauth2.consent.mcp.undisclosed.unserved.retry"
+ );
+ unmount();
+ });
+
+ // The server serves this ceiling and this bundle has no word for it: a newer
+ // release's value against a page that was already open. Falling through to
+ // the read-only wording would understate what was approved, and telling the
+ // user to find an admin would send them after a policy that is working.
+ test("a ceiling this page cannot name asks for a reload, not a grant", async () => {
+ const { container, unmount } = await renderWithCeiling({
+ capability: 5,
+ ignoreMaskingExemptions: false,
+ dataMaskingAvailable: true,
+ modes: [...SERVED_MODES, { capability: 5 }],
+ methods: [],
+ engines: [],
+ });
+ expect(container.textContent).toContain(
+ "oauth2.consent.mcp.undisclosed.outdated.title"
+ );
+ expect(container.textContent).not.toContain("common.allow");
+
+ const reload = vi.fn();
+ Object.defineProperty(globalThis, "location", {
+ writable: true,
+ value: { ...globalThis.location, reload },
+ });
+ const retry = [...container.querySelectorAll("button")].find((b) =>
+ b.textContent?.includes("oauth2.consent.mcp.undisclosed.outdated.retry")
+ );
+ expect(retry).toBeDefined();
+ await act(async () => {
+ retry?.click();
+ });
+ await flushPromises();
+ // A reload, not a re-read: only a fresh bundle can name this ceiling, so
+ // refetching the policy would return the same value with no word for it.
+ expect(reload).toHaveBeenCalledTimes(1);
+ expect(mocks.getMCPInfo).toHaveBeenCalledTimes(1);
+ unmount();
+ });
+
+ // Same reasoning as the disabled screen: history leaves the OAuth client
+ // waiting on a callback that never comes, and these four states are the ones
+ // where the person has nothing else to do here.
+ test("dismissing an undisclosed policy denies the request", async () => {
+ const { container, unmount } = await renderWithCeiling({
+ capability: 0,
+ ignoreMaskingExemptions: false,
+ dataMaskingAvailable: true,
+ methods: [],
+ engines: [],
+ });
+
+ const submitted: HTMLFormElement[] = [];
+ const realSubmit = HTMLFormElement.prototype.submit;
+ HTMLFormElement.prototype.submit = function submit(this: HTMLFormElement) {
+ submitted.push(this);
+ };
+ try {
+ const close = [...container.querySelectorAll("button")].find((b) =>
+ b.textContent?.includes("common.close")
+ );
+ act(() => (close as HTMLButtonElement)?.click());
+ } finally {
+ HTMLFormElement.prototype.submit = realSubmit;
+ }
+
+ expect(mocks.routerBack).not.toHaveBeenCalled();
+ expect(submitted).toHaveLength(1);
+ const action = submitted[0].querySelector('input[name="action"]');
+ expect((action as HTMLInputElement)?.value).toBe("deny");
+ unmount();
+ });
});
diff --git a/frontend/src/routes/auth/OAuth2ConsentPage.tsx b/frontend/src/routes/auth/OAuth2ConsentPage.tsx
index eb657b438c..4d87205fe7 100644
--- a/frontend/src/routes/auth/OAuth2ConsentPage.tsx
+++ b/frontend/src/routes/auth/OAuth2ConsentPage.tsx
@@ -1,12 +1,13 @@
import { createContextValues } from "@connectrpc/connect";
-import { Building2, Check, Loader2 } from "lucide-react";
-import { useEffect, useRef, useState } from "react";
+import { Building2, Loader2 } from "lucide-react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { workspaceServiceClientConnect } from "@/api";
import { silentContextKey } from "@/api/context-key";
import { router } from "@/app/router";
import { AUTH_SIGNIN_MODULE } from "@/app/router/handles";
import { BytebaseLogo } from "@/components/BytebaseLogo";
+import { readConsentCeiling } from "@/components/mcp/mcpPolicy";
import { Button } from "@/components/ui/button";
import {
Select,
@@ -21,6 +22,8 @@ import { MCPSetting_Capability } from "@/types/proto-es/v1/setting_service_pb";
import type { MCPInfo } from "@/types/proto-es/v1/workspace_service_pb";
import { MCPConsentCeiling } from "./MCPConsentCeiling";
import { MCPConsentDisabled } from "./MCPConsentDisabled";
+import type { UndisclosedReason } from "./MCPConsentUndisclosed";
+import { MCPConsentUndisclosed } from "./MCPConsentUndisclosed";
const AUTHORIZE_URL = "/api/oauth2/authorize";
@@ -33,7 +36,11 @@ export function OAuth2ConsentPage() {
// What the workspace's MCP ceiling lets this session do. Every grant this
// server issues is an MCP grant, so the ceiling decides the POST too — this
// is the same answer, shown before the person presses Approve.
+ //
+ // Undefined is not "no policy": it is this page not holding one, which is
+ // the state Allow is withheld under.
const [mcpInfo, setMcpInfo] = useState<MCPInfo | undefined>(undefined);
+ const [retrying, setRetrying] = useState(false);
const loadWorkspace = useAppStore((state) => state.loadWorkspace);
const loadWorkspaceList = useAppStore((state) => state.loadWorkspaceList);
@@ -66,6 +73,30 @@ export function OAuth2ConsentPage() {
const resource = (query.resource as string) || "";
const scope = (query.scope as string) || "";
+ // Silent: the interceptor's toast names a status code, not a fix, and the
+ // card this feeds says the same thing in words the person can act on.
+ const readCeiling = useCallback(async (): Promise<MCPInfo | undefined> => {
+ try {
+ return await workspaceServiceClientConnect.getMCPInfo(
+ {},
+ {
+ contextValues: createContextValues().set(silentContextKey, true),
+ // The shared transport has no deadline. Without one a stalled read
+ // leaves the page on its spinner with no way forward and no way out.
+ timeoutMs: 10_000,
+ }
+ );
+ } catch {
+ return undefined;
+ }
+ }, []);
+
+ const retryCeiling = async () => {
+ setRetrying(true);
+ setMcpInfo(await readCeiling());
+ setRetrying(false);
+ };
+
const initRef = useRef(false);
useEffect(() => {
if (initRef.current) return;
@@ -114,30 +145,10 @@ export function OAuth2ConsentPage() {
setLoading(false);
return;
}
- // A ceiling this build cannot read refuses this call. That is the one
- // policy state the backend still has to be the first to say, so the card
- // falls back to its ceiling-free shape and the POST refuses with its own
- // page. Silent: the interceptor's toast would be the only thing on
- // screen about it, and it names a status code, not a fix.
- try {
- setMcpInfo(
- await workspaceServiceClientConnect.getMCPInfo(
- {},
- {
- contextValues: createContextValues().set(silentContextKey, true),
- // The shared transport has no deadline. This request only
- // enriches the card, so a stalled one must not leave the page on
- // its spinner with no Allow and no Deny.
- timeoutMs: 10_000,
- }
- )
- );
- } catch {
- setMcpInfo(undefined);
- }
+ setMcpInfo(await readCeiling());
setLoading(false);
})();
- }, []);
+ }, [readCeiling]);
// Prefetch workspace list on SaaS so the picker can render. This runs in
// its own effect keyed on `isSaaSMode` because actuator's serverInfo may
@@ -245,9 +256,29 @@ export function OAuth2ConsentPage() {
form.submit();
};
- // Four states share this slot. Early returns rather than a ternary chain,
- // so each is named where it is decided and the consent card reads as the
- // ordinary case it is.
+ // The way out of each state that has one. The two an admin has to repair get
+ // nothing: re-reading returns the same broken value, and a button that
+ // changes nothing reads as a promise that it might.
+ const retryFor = (reason: UndisclosedReason): (() => void) | undefined => {
+ switch (reason) {
+ case "unknown":
+ // Wrapped rather than passed: retryCeiling is async, and handing a
+ // Promise-returning function to a `() => void` prop floats the promise
+ // (SonarCloud S6544). readCeiling swallows its own failures, so there
+ // is no rejection to route anywhere.
+ return () => {
+ void retryCeiling();
+ };
+ case "outdated":
+ // Only a fresh bundle can name this ceiling. Re-reading the policy
+ // would return the same value this page has no word for.
+ return () => globalThis.location.reload();
+ default:
+ return undefined;
+ }
+ };
+
+ // Five branches share this slot and only the last offers a grant.
const consentBody = () => {
if (loading) {
return (
@@ -266,16 +297,31 @@ export function OAuth2ConsentPage() {
</div>
);
}
- if (mcpInfo?.capability === MCPSetting_Capability.DISABLED) {
+ // Allow renders only below this line, and only where the page holds a
+ // ceiling the server serves and this bundle can name (BOT-106).
+ const ceiling = readConsentCeiling(mcpInfo);
+ if (ceiling.kind !== "mode") {
+ return (
+ <MCPConsentUndisclosed
+ reason={ceiling.kind}
+ workspaceCard={workspaceCard}
+ onRetry={retryFor(ceiling.kind)}
+ retrying={retrying}
+ // Not goBack: history leaves the client waiting on a callback that
+ // never comes. A deny POST returns access_denied to the registered
+ // redirect_uri, which is the answer the OAuth client is blocked on.
+ onDismiss={deny}
+ dismissing={submitting}
+ />
+ );
+ }
+ if (ceiling.info.capability === MCPSetting_Capability.DISABLED) {
return (
<MCPConsentDisabled
workspaceTitle={
currentWorkspace?.title || currentWorkspace?.name || ""
}
workspaceCard={workspaceCard}
- // Not goBack: history leaves the client waiting on a callback that
- // never comes. A deny POST returns access_denied to the registered
- // redirect_uri, which is the answer the OAuth client is blocked on.
onDismiss={deny}
dismissing={submitting}
/>
@@ -292,28 +338,7 @@ export function OAuth2ConsentPage() {
</p>
</div>
{workspaceCard}
- {/* Only the two ceilings this bundle can describe. A value it
- cannot name — a newer release's, against a cached page — would
- otherwise fall through to the read-only wording and understate
- what was approved. It gets the same card as no policy data,
- which BOT-106 covers. */}
- {mcpInfo &&
- (mcpInfo.capability === MCPSetting_Capability.READ_ONLY ||
- mcpInfo.capability === MCPSetting_Capability.READ_WRITE) ? (
- <MCPConsentCeiling info={mcpInfo} />
- ) : (
- <div className="bg-control-bg rounded-sm p-4">
- <p className="text-sm text-control-light mb-2">
- {t("oauth2.consent.permissions")}
- </p>
- <ul className="text-sm text-main flex flex-col gap-1">
- <li className="flex items-center gap-2">
- <Check className="size-4 text-success" />
- {t("oauth2.consent.permission-access")}
- </li>
- </ul>
- </div>
- )}
+ <MCPConsentCeiling info={ceiling.info} />
<form method="POST" action={AUTHORIZE_URL}>
<input type="hidden" name="client_id" value={clientId} />
<input type="hidden" name="redirect_uri" value={redirectUri} />
diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
index 5ee9dc210c..24bb4f77f1 100644
--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
@@ -328,10 +328,9 @@ describe("MCPAccessPolicySection", () => {
unmount();
});
- // Codex, #21236: this warning used to be gated on GetMCPInfo, which refuses
- // outright under an unreadable or unserved ceiling (BOT-106) — the state an
- // admin is on this page to repair. Hiding it there lets them arm a toggle
- // that does nothing while believing they tightened masking.
+ // Codex, #21236: this warning used to be gated on GetMCPInfo, which can still
+ // fail through an outage. Hiding it there lets an admin arm a toggle that
+ // does nothing while believing they tightened masking.
test("says masking is unlicensed even when the mode data fails", async () => {
mocks.hasFeature.mockReturnValue(false);
mocks.getMCPInfo.mockRejectedValue(new Error("the ceiling cannot be read"));
@@ -350,11 +349,11 @@ describe("MCPAccessPolicySection", () => {
unmount();
});
- // Codex, #21236: the drawer's info is a required prop now, so a pending or
- // refused GetMCPInfo cannot render as a mode that serves nothing — "0 of 0"
- // over the workspace whose ceiling the drawer exists to explain. GetMCPInfo
- // refuses outright under an unreadable ceiling (BOT-106), which is the state
- // an admin is on this page to repair.
+ // Codex, #21236: the drawer's info is a required prop, so a pending or failed
+ // GetMCPInfo cannot render as a mode that serves nothing — "0 of 0" over the
+ // workspace whose ceiling the drawer exists to explain. Since BOT-106 that
+ // failure is an outage rather than a broken ceiling; the test below covers
+ // the ceiling case, which now answers.
test("no mode-contents drawer while the mode data is missing", async () => {
mocks.getMCPInfo.mockRejectedValue(new Error("the ceiling cannot be read"));
@@ -371,6 +370,55 @@ describe("MCPAccessPolicySection", () => {
unmount();
});
+ // BOT-106, the settings half. GetMCPInfo used to refuse whole under an
+ // unreadable ceiling, so the mode cards lost their "See what Read-only
+ // serves" links on the one page whose job is repairing that row — the admin
+ // who most needs to compare the modes was the only one who could not. None of
+ // the mode contents ever depended on the stored row, and the server now
+ // answers them under a broken ceiling, which is the response mocked here.
+ test("the mode-contents drawer is available while repairing a broken ceiling", async () => {
+ // Capability 0 with no row for it in modes is the broken state: nothing
+ // this build serves resolves from the stored row.
+ mocks.mcpSetting.value = {
+ capability: 0,
+ ignoreMaskingExemptions: false,
+ };
+ mocks.getMCPInfo.mockResolvedValue({
+ capability: 0,
+ ignoreMaskingExemptions: false,
+ dataMaskingAvailable: true,
+ modes: [{ capability: 1 }, { capability: 3 }, { capability: 4 }],
+ methods: [],
+ engines: [],
+ });
+
+ const { container, render, unmount } = renderIntoContainer(
+ <MCPAccessPolicySection />
+ );
+ render();
+ await flush();
+
+ // The repair banner, so this is the state under test and not a healthy row.
+ expect(container.textContent).toContain(
+ "settings.mcp.policy.unreadable.title"
+ );
+
+ clickText(container, "settings.mcp.policy.edit");
+ await flush();
+
+ const contents = [...container.querySelectorAll("button")].filter((b) =>
+ b.textContent?.includes("settings.mcp.policy.mode.contents")
+ );
+ // One per ceiling that serves something; DISABLED has no contents to show.
+ expect(contents).toHaveLength(2);
+
+ act(() => contents[0].click());
+ await flush();
+ expect(mocks.sheetProps.at(-1)?.open).toBe(true);
+
+ unmount();
+ });
+
// Codex, #21236: setSaving gated only the footer buttons. The request has
// already captured pick and ignoreMasking, so a card clicked after Save went
// out changed the visible draft and nothing else — then the success path
diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
index e1e10af384..8353f62bdd 100644
--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
@@ -63,10 +63,10 @@ export function MCPAccessPolicySection() {
const { t } = useTranslation();
const settingsByName = useAppStore((s) => s.settingsByName);
- // Read from the licence, not from GetMCPInfo. That request refuses outright
- // under an invalid or unserved ceiling (BOT-106), which is exactly when an
- // admin is on this page — and hiding this line there lets them arm a toggle
- // that does nothing while believing they tightened masking.
+ // Read from the licence, not from GetMCPInfo. That request can still fail —
+ // it answers under a broken ceiling now, but not through an outage — and
+ // hiding this line lets an admin arm a toggle that does nothing while
+ // believing they tightened masking.
const dataMaskingAvailable = useAppStore((s) =>
s.hasFeature(PlanFeature.FEATURE_DATA_MASKING)
);
@@ -93,9 +93,10 @@ export function MCPAccessPolicySection() {
// is re-read after a save rather than patched: the ceiling in force is part
// of the same answer.
//
- // Silent: a ceiling this build cannot read refuses this call, and the banner
- // below already says so in the words an admin can act on. The interceptor's
- // toast would put the same fact on screen twice, once as a status code.
+ // Silent: this read fails only on an outage now, and the card below already
+ // says the page could not be read in words an admin can act on. The
+ // interceptor's toast would put the same fact on screen twice, once as a
+ // status code.
// Both reads carry a generation, and the effect retires them on unmount. A
// response has no way of knowing it was overtaken, and the store it writes is
// shared: a read left flying by a visit the admin navigated away from would
diff --git a/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts b/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
index 9e957634bc..52b2f381aa 100644
--- a/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/workspace_service_pb.d.ts
@@ -50,7 +50,9 @@ export declare type MCPInfo = Message<"bytebase.v1.MCPInfo"> & {
workspace: string;
/**
- * The ceiling in force for this workspace.
+ * The ceiling in force for this workspace. A value no row in modes serves,
+ * CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+ * the stored row and every MCP connection is refused.
*
* @generated from field: bytebase.v1.MCPSetting.Capability capability = 2;
*/
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index 3e17d4e4ec..3c4a466fd1 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -16756,7 +16756,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/bytebase.v1.Subscription'
- /v1/subscription/checkoutSession/{session_id}:
+ /v1/subscription/checkoutSession/{sessionId}:
get:
tags:
- SubscriptionService
@@ -16764,7 +16764,7 @@ paths:
description: VerifyCheckoutSession verifies a Stripe Checkout Session status (SaaS only).
operationId: SubscriptionService_VerifyCheckoutSession
parameters:
- - name: session_id
+ - name: sessionId
in: path
description: |-
The same Stripe Checkout Session ID PurchaseResponse mints, arriving back
@@ -26748,7 +26748,10 @@ components:
readOnly: true
capability:
title: capability
- description: The ceiling in force for this workspace.
+ description: |-
+ The ceiling in force for this workspace. A value no row in modes serves,
+ CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+ the stored row and every MCP connection is refused.
readOnly: true
$ref: '#/components/schemas/bytebase.v1.MCPSetting.Capability'
modes:
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index ea77f2557d..3d5c4eccce 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -12855,7 +12855,7 @@ cannot describe the rules of the build before it.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| workspace | [string](#string) | | The workspace this describes. Format: workspaces/{workspace}. Not this message&#39;s own resource name — MCPInfo is not a named resource and there is nothing to get it by. |
-| capability | [MCPSetting.Capability](#bytebase-v1-MCPSetting-Capability) | | The ceiling in force for this workspace. |
+| capability | [MCPSetting.Capability](#bytebase-v1-MCPSetting-Capability) | | The ceiling in force for this workspace. A value no row in modes serves, CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from the stored row and every MCP connection is refused. |
| modes | [MCPCapabilityMode](#bytebase-v1-MCPCapabilityMode) | repeated | What each ceiling serves, including the one in force, so an admin can compare the choices rather than only read the current answer. |
| methods | [MCPMethod](#bytebase-v1-MCPMethod) | repeated | Every API method some ceiling serves. A mode serves a method when the method&#39;s class is one of that mode&#39;s served_classes, which is the ceiling rule the gate evaluates. Methods no ceiling serves are absent.
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 97bbbc1f92..623514965b 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -36464,7 +36464,9 @@ nothing to get it by. </p></td>
<td>capability</td>
<td><a href="#bytebase.v1.MCPSetting.Capability">MCPSetting.Capability</a></td>
<td></td>
- <td><p>The ceiling in force for this workspace. </p></td>
+ <td><p>The ceiling in force for this workspace. A value no row in modes serves,
+CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+the stored row and every MCP connection is refused. </p></td>
</tr>
<tr>
diff --git a/proto/v1/v1/workspace_service.proto b/proto/v1/v1/workspace_service.proto
index 6c0df55d93..eab858d2e1 100644
--- a/proto/v1/v1/workspace_service.proto
+++ b/proto/v1/v1/workspace_service.proto
@@ -149,7 +149,9 @@ message MCPInfo {
// nothing to get it by.
string workspace = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
- // The ceiling in force for this workspace.
+ // The ceiling in force for this workspace. A value no row in modes serves,
+ // CAPABILITY_UNSPECIFIED included, means no ceiling could be resolved from
+ // the stored row and every MCP connection is refused.
MCPSetting.Capability capability = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// What each ceiling serves, including the one in force, so an admin can