Skip to content

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

refactor: simplify MCP capability handling (#21259)

ecmadaoda0072ec9ae4
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index 59a961ac79..ab291f5790 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -528,30 +528,6 @@ func MCPClassIsRefused(class v1pb.MCPMethodClass) bool {
}
}
-// MCPCeilingServesAnything reports whether a workspace capability ceiling
-// serves any method class at all, which is what the /mcp connection gate needs
-// to decide whether a session may open.
-//
-// It lives here for the same reason MCPClassIsRefused does: the serving table
-// is in backend/api/v1 with the code that evaluates it, the connection gate is
-// in backend/api/mcp, and the two must not disagree about which ceilings this
-// build serves. TestLintCeilingAdmissionMatchesTheServingTable holds this
-// function against that table over the whole enum, so a mode that starts or
-// stops serving a class cannot leave the connection gate stale.
-//
-// Everything this build cannot interpret is refused: UNSPECIFIED is a zero
-// value nobody resolved, and a stored number no release ever wrote — the
-// reserved 2, or anything from a newer build — is a ceiling nobody decided
-// about. Both fall to the default.
-func MCPCeilingServesAnything(capability storepb.MCPSetting_Capability) bool {
- switch capability {
- case storepb.MCPSetting_READ_WRITE, storepb.MCPSetting_READ_ONLY:
- return true
- default:
- return false
- }
-}
-
// MCPMethodClassOfProcedure resolves the MCP classification for a connect
// procedure path such as "/bytebase.v1.AuthService/Login". Callers that only
// decide what to ADVERTISE may treat an error as "not classified"; the
diff --git a/backend/api/auth/mcp_ceiling.go b/backend/api/auth/mcp_ceiling.go
index 29af971d9d..8676c5083f 100644
--- a/backend/api/auth/mcp_ceiling.go
+++ b/backend/api/auth/mcp_ceiling.go
@@ -1,11 +1,6 @@
package auth
-import (
- "github.com/pkg/errors"
-
- storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/store"
-)
+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
@@ -21,11 +16,8 @@ const (
MCPCeilingServes MCPCeilingVerdict = iota
// An admin turned MCP off. Raising the ceiling fixes it.
MCPCeilingDisabled
- // The stored value is one this build cannot interpret — a mistyped enum
- // name, a wrong-typed row. An admin has to write the setting again.
- MCPCeilingUnreadable
- // The value parsed but no mode this build has serves it: the reserved 2, or
- // a ceiling a newer release wrote. An admin has to choose a known value.
+ // No mode this build has serves the parsed value: the reserved 2 or
+ // UNSPECIFIED. An admin has to choose a known value.
MCPCeilingUnserved
// The read itself failed. The only one of these a retry may fix.
MCPCeilingUnavailable
@@ -35,7 +27,7 @@ const (
// is what makes a refusal an audited outcome.
func (v MCPCeilingVerdict) IsPolicy() bool {
switch v {
- case MCPCeilingDisabled, MCPCeilingUnreadable, MCPCeilingUnserved:
+ case MCPCeilingDisabled, MCPCeilingUnserved:
return true
default:
return false
@@ -46,20 +38,21 @@ func (v MCPCeilingVerdict) IsPolicy() bool {
// verdict its caller acts on. Everything this build cannot act on refuses; what
// the split decides is the message and the audit row. A value nobody can
// interpret never succeeds on retry; an outage may.
-func ClassifyMCPCeiling(capability storepb.MCPSetting_Capability, err error) MCPCeilingVerdict {
+func ClassifyMCPCeiling(settings *storepb.MCPSetting, err error) MCPCeilingVerdict {
if err != nil {
- if errors.Is(err, store.ErrMCPCapabilityUnreadable) {
- return MCPCeilingUnreadable
- }
return MCPCeilingUnavailable
}
- if capability == storepb.MCPSetting_DISABLED {
- return MCPCeilingDisabled
+ if settings == nil {
+ return MCPCeilingUnavailable
}
- if !MCPCeilingServesAnything(capability) {
+ switch settings.Capability {
+ case storepb.MCPSetting_DISABLED:
+ return MCPCeilingDisabled
+ case storepb.MCPSetting_READ_ONLY, storepb.MCPSetting_READ_WRITE:
+ return MCPCeilingServes
+ default:
return MCPCeilingUnserved
}
- return MCPCeilingServes
}
// Refusal is what a door tells the caller it is refusing: what is wrong with
@@ -80,9 +73,6 @@ func (v MCPCeilingVerdict) Refusal() string {
case MCPCeilingDisabled:
return "a workspace admin has turned MCP access off for this workspace. " +
"Ask them to raise the MCP ceiling in the workspace settings"
- case MCPCeilingUnreadable:
- return "this workspace's stored MCP capability ceiling is not one this build understands. " +
- "Ask a workspace admin to set the MCP ceiling again in the workspace settings"
case MCPCeilingUnserved:
return "this workspace's stored MCP capability ceiling is not one this build serves. " +
"Ask a workspace admin to set the MCP ceiling to a supported value in the workspace settings"
@@ -94,9 +84,17 @@ func (v MCPCeilingVerdict) Refusal() string {
}
}
-// PolicyMCPCeilingVerdicts is every verdict that is a decision about the
-// workspace rather than an outage, which is what decides whether a refusal is
-// recorded. Refusal covers the outage too; this list does not.
-func PolicyMCPCeilingVerdicts() []MCPCeilingVerdict {
- return []MCPCeilingVerdict{MCPCeilingDisabled, MCPCeilingUnreadable, MCPCeilingUnserved}
+// Heading returns the short title for a refusal. Empty for MCPCeilingServes,
+// which refuses nothing.
+func (v MCPCeilingVerdict) Heading() string {
+ switch v {
+ case MCPCeilingDisabled:
+ return "MCP access is turned off"
+ case MCPCeilingUnserved:
+ return "This workspace's MCP setting is not one this version supports"
+ case MCPCeilingUnavailable:
+ return "MCP settings are temporarily unavailable"
+ default:
+ return ""
+ }
}
diff --git a/backend/api/auth/mcp_ceiling_test.go b/backend/api/auth/mcp_ceiling_test.go
index d69f259f12..9ec690ae9f 100644
--- a/backend/api/auth/mcp_ceiling_test.go
+++ b/backend/api/auth/mcp_ceiling_test.go
@@ -8,7 +8,6 @@ import (
"github.com/stretchr/testify/require"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/store"
)
// TestClassifyMCPCeiling pins the one split three doors depend on.
@@ -20,85 +19,46 @@ import (
// what makes the distinction about the message and the audit row rather than
// about access.
func TestClassifyMCPCeiling(t *testing.T) {
- unreadable := errors.Wrapf(store.ErrMCPCapabilityUnreadable, "READ_ONLYY is not a value this build understands")
-
tests := []struct {
- name string
- capability storepb.MCPSetting_Capability
- err error
- want MCPCeilingVerdict
- policy bool
+ name string
+ settings *storepb.MCPSetting
+ err error
+ want MCPCeilingVerdict
+ policy bool
}{
- {"read-write serves", storepb.MCPSetting_READ_WRITE, nil, MCPCeilingServes, false},
- {"read-only serves", storepb.MCPSetting_READ_ONLY, nil, MCPCeilingServes, false},
- {"disabled", storepb.MCPSetting_DISABLED, nil, MCPCeilingDisabled, true},
- {"the reserved number", storepb.MCPSetting_Capability(2), nil, MCPCeilingUnserved, true},
- {"a value from a newer build", storepb.MCPSetting_Capability(99), nil, MCPCeilingUnserved, true},
- // The store resolves an absent setting to READ_WRITE and an explicit
- // unset to the unreadable error, so a zero value arriving here was
- // resolved by nobody.
- {"nobody resolved it", storepb.MCPSetting_CAPABILITY_UNSPECIFIED, nil, MCPCeilingUnserved, true},
- {"a stored value nobody can read", storepb.MCPSetting_CAPABILITY_UNSPECIFIED, unreadable, MCPCeilingUnreadable, true},
- // The error wins over the value, whatever the value happens to be.
- {"an unreadable value that parsed to something", storepb.MCPSetting_READ_WRITE, unreadable, MCPCeilingUnreadable, true},
- {"the read failed", storepb.MCPSetting_CAPABILITY_UNSPECIFIED, errors.New("connection refused"), MCPCeilingUnavailable, false},
- {"the read failed on a permissive workspace", storepb.MCPSetting_READ_WRITE, errors.New("connection refused"), MCPCeilingUnavailable, false},
+ {"read-write serves", &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE}, nil, MCPCeilingServes, false},
+ {"read-only serves", &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_ONLY}, nil, MCPCeilingServes, false},
+ {"disabled", &storepb.MCPSetting{Capability: storepb.MCPSetting_DISABLED}, nil, MCPCeilingDisabled, true},
+ {"unspecified", &storepb.MCPSetting{Capability: storepb.MCPSetting_CAPABILITY_UNSPECIFIED}, nil, MCPCeilingUnserved, true},
+ {"the reserved number", &storepb.MCPSetting{Capability: storepb.MCPSetting_Capability(2)}, nil, MCPCeilingUnserved, true},
+ {"a value from a newer build", &storepb.MCPSetting{Capability: storepb.MCPSetting_Capability(99)}, nil, MCPCeilingUnserved, true},
+ {"nobody resolved it", nil, nil, MCPCeilingUnavailable, false},
+ {"the read failed", nil, errors.New("connection refused"), MCPCeilingUnavailable, false},
+ {"the read failed on a permissive workspace", &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE}, errors.New("connection refused"), MCPCeilingUnavailable, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- got := ClassifyMCPCeiling(tt.capability, tt.err)
+ got := ClassifyMCPCeiling(tt.settings, tt.err)
require.Equal(t, tt.want, got)
require.Equal(t, tt.policy, got.IsPolicy())
})
}
}
-// TestMCPCeilingVerdictAdmissionMatchesTheServesPredicate holds the classifier
-// against the predicate the serving table already pins: exactly one verdict may
-// admit work, and it must be the one MCPCeilingServesAnything agrees with over
-// the whole enum. A mode that starts or stops serving a class cannot leave one
-// of them stale.
-func TestMCPCeilingVerdictAdmissionMatchesTheServesPredicate(t *testing.T) {
- values := storepb.MCPSetting_Capability(0).Descriptor().Values()
- for i := range values.Len() {
- capability := storepb.MCPSetting_Capability(values.Get(i).Number())
- admits := ClassifyMCPCeiling(capability, nil) == MCPCeilingServes
- require.Equal(t, MCPCeilingServesAnything(capability), admits,
- "%v must admit work in exactly one of the two", capability)
- }
-}
-
-// TestPolicyVerdictsAreExactlyTheAuditedOnes holds the list every door renders
-// wording from against the predicate that decides whether a refusal is
-// recorded. A verdict in one and not the other would either be refused with no
-// sentence or audited as a decision nobody made.
-func TestPolicyVerdictsAreExactlyTheAuditedOnes(t *testing.T) {
- policy := map[MCPCeilingVerdict]bool{}
- for _, v := range PolicyMCPCeilingVerdicts() {
- require.True(t, v.IsPolicy(), "%v is listed as policy but does not report as one", v)
- policy[v] = true
- }
- for _, v := range []MCPCeilingVerdict{
- MCPCeilingServes, MCPCeilingDisabled, MCPCeilingUnreadable, MCPCeilingUnserved, MCPCeilingUnavailable,
- } {
- require.Equal(t, v.IsPolicy(), policy[v], "%v disagrees between the list and the predicate", v)
- }
-}
-
// TestEveryVerdictThatRefusesHasWording holds the one wording table against the
// verdicts that reach a caller. It replaces a per-door version of this check
// that each door carried: while the sentences were per-door, coverage was all a
// lint could hold them to — the wording itself was free to drift, and it did.
//
-// The list spans all five values, not PolicyMCPCeilingVerdicts, because an
-// outage is refused too and its sentence is the one nobody would otherwise
-// exercise. Only Serves is silent.
+// The list spans every refusing value, including an outage. Only Serves is
+// silent.
func TestEveryVerdictThatRefusesHasWording(t *testing.T) {
for _, v := range []MCPCeilingVerdict{
- MCPCeilingDisabled, MCPCeilingUnreadable, MCPCeilingUnserved, MCPCeilingUnavailable,
+ MCPCeilingDisabled, MCPCeilingUnserved, MCPCeilingUnavailable,
} {
refusal := v.Refusal()
require.NotEmpty(t, refusal, "%v reaches a caller and must say what is wrong", v)
+ require.NotEmpty(t, v.Heading(), "%v reaches a caller and must have a heading", v)
// Composed into a larger error at every door but the consent page, so
// it starts lowercase and ends unterminated.
@@ -113,16 +73,14 @@ func TestEveryVerdictThatRefusesHasWording(t *testing.T) {
}
require.Empty(t, MCPCeilingServes.Refusal(), "serving refuses nothing")
+ require.Empty(t, MCPCeilingServes.Heading(), "serving has no refusal heading")
}
-// TestRefusalsDistinguishTheThreeStoredStates pins that the three policy
-// verdicts do not collapse into one message. They have different fixes — turn
-// MCP back on, rewrite a value nobody can read, choose a value this build
-// serves — and a door that said "disabled" for all three would send two of them
-// to the wrong control.
-func TestRefusalsDistinguishTheThreeStoredStates(t *testing.T) {
+// TestRefusalsDistinguishTheStoredStates pins that the policy verdicts do not
+// collapse into one message.
+func TestRefusalsDistinguishTheStoredStates(t *testing.T) {
seen := map[string]MCPCeilingVerdict{}
- for _, v := range PolicyMCPCeilingVerdicts() {
+ for _, v := range []MCPCeilingVerdict{MCPCeilingDisabled, MCPCeilingUnserved} {
refusal := v.Refusal()
if other, dup := seen[refusal]; dup {
require.Failf(t, "verdicts share wording", "%v and %v say the same thing", other, v)
@@ -130,6 +88,5 @@ func TestRefusalsDistinguishTheThreeStoredStates(t *testing.T) {
seen[refusal] = v
}
require.Contains(t, MCPCeilingDisabled.Refusal(), "turned MCP access off")
- require.Contains(t, MCPCeilingUnreadable.Refusal(), "not one this build understands")
require.Contains(t, MCPCeilingUnserved.Refusal(), "not one this build serves")
}
diff --git a/backend/api/mcp/connection_audit.go b/backend/api/mcp/connection_audit.go
index ea51476f1c..9a9adcf075 100644
--- a/backend/api/mcp/connection_audit.go
+++ b/backend/api/mcp/connection_audit.go
@@ -22,7 +22,7 @@ import (
func (s *Server) refuseByCeiling(c *echo.Context, delegated auth.DelegatedMCPCredential) error {
ctx := c.Request().Context()
settings, err := s.store.GetMCPSettingsUncached(ctx, delegated.WorkspaceID)
- verdict := auth.ClassifyMCPCeiling(settings.Capability, err)
+ verdict := auth.ClassifyMCPCeiling(settings, err)
if verdict == auth.MCPCeilingServes {
return nil
}
diff --git a/backend/api/mcp/connection_audit_test.go b/backend/api/mcp/connection_audit_test.go
index 81c4add1b7..fbbb158eb9 100644
--- a/backend/api/mcp/connection_audit_test.go
+++ b/backend/api/mcp/connection_audit_test.go
@@ -19,7 +19,6 @@ import (
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/store"
)
// TestMCPConnectionDenialEmission pins which refusals at /mcp become audit rows
@@ -94,18 +93,6 @@ func TestMCPConnectionDenialEmission(t *testing.T) {
require.Empty(t, row.McpDelegation.GetCorrelationId())
})
- t.Run("an unreadable ceiling writes a row that names the typo, not the policy", func(t *testing.T) {
- st := newTestServerStore()
- st.capabilityErr = errors.Wrapf(store.ErrMCPCapabilityUnreadable, "READ_ONLYY is not a value this build understands")
- srv := newServer(t, st)
-
- require.Equal(t, http.StatusForbidden, connect(t, srv, mcpToken(t, secret, tokenOptions{})))
-
- require.Len(t, st.auditRows, 1)
- require.Contains(t, st.auditRows[0].Status.GetMessage(), "not one this build understands",
- "an admin fixes a broken stored value by rewriting it, not by turning MCP back on")
- })
-
t.Run("a ceiling this build does not serve writes its own row", func(t *testing.T) {
st := newTestServerStore()
// The reserved number 2, or a ceiling a newer release wrote.
@@ -299,18 +286,14 @@ func mcpToken(t *testing.T, secret string, opts tokenOptions) string {
// the ceiling refusals that can reach a tool, rather than restating its phrase
// list somewhere it would drift.
//
-// Only these two reach it. A 403 is what the predicate is consulted for, and
-// the per-request gate answers CodePermissionDenied for exactly these; an
+// Only this verdict reaches it. A 403 is what the predicate is consulted for,
+// and the per-request gate answers CodePermissionDenied for it; an
// outage answers CodeUnavailable, and DISABLED is refused at this door before
// any tool call and by the serving table at the per-request one. A refusal it
// stops recognizing gets "request a project role" appended — advice that cannot
// lift a workspace setting.
func TestCeilingRefusalsAreRecognizedAsPolicy(t *testing.T) {
- for _, verdict := range []auth.MCPCeilingVerdict{
- auth.MCPCeilingUnreadable,
- auth.MCPCeilingUnserved,
- } {
- require.True(t, IsPolicyRefusal(verdict.Refusal()),
- "%v reaches a tool as a 403 and must carry its own way out", verdict)
- }
+ verdict := auth.MCPCeilingUnserved
+ require.True(t, IsPolicyRefusal(verdict.Refusal()),
+ "%v reaches a tool as a 403 and must carry its own way out", verdict)
}
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yaml
index b49cb4d706..ddb77b2363 100644
--- a/backend/api/mcp/gen/openapi.yaml
+++ b/backend/api/mcp/gen/openapi.yaml
@@ -15613,9 +15613,7 @@ components:
nothing to get it by.
capability:
title: capability
- description: |-
- The ceiling in force for this workspace. A workspace that never configured
- MCP resolves to READ_WRITE.
+ description: The ceiling in force for this workspace.
$ref: '#/components/schemas/bytebase.v1.MCPSetting.Capability'
modes:
type: array
@@ -15759,34 +15757,6 @@ components:
masking policy, and it does nothing on the engines Bytebase does not mask.
It narrows what an agent reads through the paths Bytebase masks; it is not
a confidentiality boundary.
- capabilityUnreadable:
- type: boolean
- title: capability_unreadable
- description: |-
- True when the row carries a capability key that this build cannot resolve
- to a ceiling. An enum name a newer release wrote is the legitimate trigger,
- during a rolling upgrade; a hand-edited token reaches the same state.
- False for every readable row, including one that was never configured.
-
- The capability field cannot carry this on its own: the unmarshaler discards
- an enum name it does not know, so an unreadable row and a never-configured
- one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
- first and served at READ_WRITE for the second. A client reading only the
- capability shows the most permissive ceiling over a workspace where every
- MCP connection is being refused.
-
- A row protojson cannot parse at all is NOT this state. There is no ceiling
- in it to describe, so the read fails instead, and repairing it needs an
- operator rather than this field.
-
- The stored token itself is deliberately not returned. Telling a typo apart
- from a value a newer release wrote would only pay off if this enum grew,
- and it has not: its one reserved slot held a tier removed before any
- release shipped it.
-
- Set the row right by writing value.mcp.capability. Any other path is
- refused while this is true, because the merge that saved it would erase the
- value nobody could read.
title: MCPSetting
additionalProperties: false
description: |-
@@ -15801,10 +15771,9 @@ components:
- READ_ONLY
- READ_WRITE
description: |-
- Capability is the ceiling: a session runs at this level or lower. An absent
- MCP setting resolves to READ_WRITE, so a workspace that never configured
- MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
- omit the update mask path to leave the ceiling unset.
+ Capability is the ceiling: a session runs at this level or lower.
+ Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+ path to leave the current ceiling unchanged.
bytebase.v1.MaskingExemptionPolicy:
type: object
properties:
diff --git a/backend/api/mcp/server.go b/backend/api/mcp/server.go
index c5dfd03676..e240157b09 100644
--- a/backend/api/mcp/server.go
+++ b/backend/api/mcp/server.go
@@ -51,7 +51,7 @@ type Server struct {
type serverStore interface {
GetWorkspaceID(context.Context) (string, error)
GetWorkspaceProfileSetting(context.Context, string) (*storepb.WorkspaceProfileSetting, error)
- GetMCPSettingsUncached(context.Context, string) (store.MCPSettings, error)
+ GetMCPSettingsUncached(context.Context, string) (*storepb.MCPSetting, error)
DeleteOAuth2RefreshTokensByUserAndClient(context.Context, string, string) error
// CreateAuditLog records the connection denials this package emits itself.
// They happen in echo middleware, outside both connect chains, so the audit
diff --git a/backend/api/mcp/server_killswitch_test.go b/backend/api/mcp/server_killswitch_test.go
index 75cc39acea..be8424d5b1 100644
--- a/backend/api/mcp/server_killswitch_test.go
+++ b/backend/api/mcp/server_killswitch_test.go
@@ -24,45 +24,11 @@ import (
_ "github.com/bytebase/bytebase/backend/plugin/db/pg"
)
-// TestMCPConnectionAllowed pins the rule the connection gate decides from:
-// READ_WRITE and READ_ONLY admit a connection, and everything else fails
-// closed — DISABLED, unknown stored values such as the reserved number 2, and
-// the zero value. The gate reaches it through auth.ClassifyMCPCeiling, which
-// TestMCPCeilingVerdictAdmissionMatchesTheServesPredicate holds against this
-// same predicate over the whole enum.
-//
-// READ_ONLY is admitted from the cutover, once the SQL clamp made a read-only
-// session one that cannot write. What it may then do is decided per method by
-// the ceiling gate and per statement by the clamp; this function only decides
-// whether the session opens at all.
-//
-// UNSPECIFIED is refused here even though an unset stored ceiling means
-// READ_WRITE: the store resolves that before this point, so a zero value
-// arriving here was resolved by nobody.
-func TestMCPConnectionAllowed(t *testing.T) {
- tests := []struct {
- capability storepb.MCPSetting_Capability
- allowed bool
- }{
- {storepb.MCPSetting_CAPABILITY_UNSPECIFIED, false},
- {storepb.MCPSetting_READ_WRITE, true},
- {storepb.MCPSetting_DISABLED, false},
- {storepb.MCPSetting_Capability(2), false}, // reserved (was METADATA_ONLY)
- {storepb.MCPSetting_Capability(99), false}, // no such value in any build
- {storepb.MCPSetting_READ_ONLY, true},
- }
- for _, tt := range tests {
- t.Run(tt.capability.String(), func(t *testing.T) {
- require.Equal(t, tt.allowed, auth.MCPCeilingServesAnything(tt.capability))
- })
- }
-}
-
// TestMCPKillSwitchEndToEnd drives the /mcp auth middleware against a real store:
-// a workspace with DISABLED is rejected server-side with 403, while a
-// workspace that never configured a ceiling defaults to allowed (backward
-// compatible). This is the server-side enforcement the kill-switch promises —
-// the token authenticates fine; policy, not auth, blocks the disabled workspace.
+// a workspace with DISABLED is rejected server-side with 403, while an
+// explicit READ_WRITE ceiling is allowed. This is the server-side enforcement
+// the kill-switch promises — the token authenticates fine; policy, not auth,
+// blocks the disabled workspace.
func TestMCPKillSwitchEndToEnd(t *testing.T) {
ctx := context.Background()
container := testcontainer.GetTestPgContainer(ctx, t)
@@ -83,13 +49,19 @@ func TestMCPKillSwitchEndToEnd(t *testing.T) {
s, err := store.New(ctx, pgURL, false)
require.NoError(t, err)
- // ws-disabled: MCP explicitly disabled. ws-open: no MCP setting → unset → allowed.
+ // Both workspaces have the metadata row required after migration.
_, err = s.UpsertSetting(ctx, &store.SettingMessage{
Name: storepb.SettingName_MCP,
Workspace: "ws-disabled",
Value: &storepb.MCPSetting{Capability: storepb.MCPSetting_DISABLED},
})
require.NoError(t, err)
+ _, err = s.UpsertSetting(ctx, &store.SettingMessage{
+ Name: storepb.SettingName_MCP,
+ Workspace: "ws-open",
+ Value: &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE},
+ })
+ require.NoError(t, err)
secret := "test-secret-key"
profile := &config.Profile{Mode: common.ReleaseModeDev, ExternalURL: "https://bb.example.com"}
@@ -115,13 +87,13 @@ func TestMCPKillSwitchEndToEnd(t *testing.T) {
require.Equal(t, http.StatusForbidden, statusFor("ws-disabled"),
"DISABLED workspace must be rejected server-side despite a valid token")
require.Equal(t, http.StatusOK, statusFor("ws-open"),
- "workspace with no MCP ceiling must default to allowed (backward compatible)")
+ "the explicit READ_WRITE ceiling must be allowed")
}
// TestMCPKillSwitchBypassesSettingCache pins that the /mcp gate reads the
// stored policy fresh instead of through the store's setting cache. The cache
// has no TTL and only in-process writes refresh it, so with a cache-enabled
-// store (the non-HA production shape) a profile cached as unset would keep
+// store (the non-HA production shape) a cached READ_WRITE value would keep
// admitting MCP forever after the ceiling is flipped by an out-of-band admin
// path (direct SQL, another process) — the kill switch must observe the stored
// truth on the next request.
@@ -145,13 +117,12 @@ func TestMCPKillSwitchBypassesSettingCache(t *testing.T) {
s, err := store.New(ctx, pgURL, true /* enableCache */)
require.NoError(t, err)
- // An MCP setting row naming no ceiling, which is what a workspace that
- // configured only the masking toggle looks like. The row has to exist for
- // the out-of-band flip below to have something to write into.
+ // The explicit default row has to exist for the out-of-band flip below to
+ // have something to write into.
_, err = s.UpsertSetting(ctx, &store.SettingMessage{
Name: storepb.SettingName_MCP,
Workspace: "ws-cached",
- Value: &storepb.MCPSetting{},
+ Value: &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE},
})
require.NoError(t, err)
@@ -176,7 +147,7 @@ func TestMCPKillSwitchBypassesSettingCache(t *testing.T) {
return rec.Code
}
- // First request: unset ceiling → allowed. This also primes the setting cache.
+ // First request: READ_WRITE ceiling -> allowed. This also primes the setting cache.
require.Equal(t, http.StatusOK, statusFor())
// Flip the ceiling behind the store's back, as an emergency SQL toggle would.
@@ -217,19 +188,12 @@ func tokenForWorkspace(t *testing.T, secret, workspaceID string) string {
// nothing. An unknown enum NUMBER never had that problem, because protojson
// keeps it and no mode serves it.
//
-// The legacy row is the accepted trade recorded in code. Before this change the
-// ceiling lived on the workspace profile; that key is not migrated and not read,
-// so a profile row still carrying it — including DISABLED — resolves to
-// READ_WRITE. Deliberate: the released API served the field but nothing but a
-// hand-built UpdateSetting call could reach it. Pinned here so nobody adds a
-// fallback read to be helpful.
-//
// The read-only row is the cutover pin, now on its other side: READ_ONLY opens
// a session, because a read-only session can no longer write — the ceiling gate
// refuses the methods the mode does not cover and the SQL clamp refuses a
// statement that writes. The rows around it are what must NOT have moved with
-// it: a ceiling this build cannot read still refuses, and so does a value no
-// Bytebase write produces.
+// it: a capability this build does not recognize still refuses, and so does a
+// value no Bytebase write produces.
func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
ctx := context.Background()
container := testcontainer.GetTestPgContainer(ctx, t)
@@ -245,17 +209,21 @@ func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
why string
}{
{"ws-typo", `{"capability":"READ_WRTIE"}`, http.StatusForbidden,
- "a ceiling this build cannot read is not a ceiling that permits"},
+ "an unknown enum name resolves to UNSPECIFIED, which no mode permits"},
{"ws-reserved", `{"capability":2}`, http.StatusForbidden,
"the reserved number was METADATA_ONLY; no mode serves it"},
{"ws-explicit-unset", `{"capability":"CAPABILITY_UNSPECIFIED"}`, http.StatusForbidden,
"no Bytebase write produces this key with this value, so a row that has it was hand-edited"},
{"ws-readonly", `{"capability":"READ_ONLY"}`, http.StatusOK,
"READ_ONLY admits a session now that the SQL clamp holds it to reads"},
- {"ws-other-unknown-field", `{"someFieldFromANewerRelease":"x"}`, http.StatusOK,
- "one unknown field must not disable MCP: only the ceiling key is read strictly"},
- {"ws-open", `{}`, http.StatusOK,
- "an MCP setting row that names no ceiling keeps working"},
+ {"ws-other-unknown-field", `{"capability":"READ_WRITE","someFieldFromANewerRelease":"x"}`, http.StatusOK,
+ "one unknown field must not disable MCP when the required ceiling is valid"},
+ {"ws-open", `{"capability":"READ_WRITE"}`, http.StatusOK,
+ "the explicit default admits MCP"},
+ {"ws-missing-capability", `{}`, http.StatusForbidden,
+ "an existing row with an unset capability is invalid"},
+ {"ws-wrong-type", `{"capability":true}`, http.StatusServiceUnavailable,
+ "a payload the store protocol cannot decode is a metadata read failure"},
{"ws-ignoring", `{"capability":"READ_ONLY","ignoreMaskingExemptions":true}`, http.StatusOK,
"ignoring masking exemptions is not a reason to refuse the connection; it changes what the session reads"},
}
@@ -269,11 +237,6 @@ func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
require.NoError(t, err)
}
- // Two workspaces with no MCP setting row at all. ws-absent is the ordinary
- // never-configured case; ws-legacy carries the pre-3.22 ceiling on its
- // workspace profile, where nothing reads it. Both must resolve READ_WRITE,
- // and ws-legacy stores DISABLED so the pin is the strongest version of the
- // trade rather than the mildest.
for _, ws := range []struct{ workspace, profile string }{
{workspace: "ws-absent"},
{workspace: "ws-legacy", profile: `{"mcpCapability":"DISABLED"}`},
@@ -319,8 +282,10 @@ func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
"ws-open": storepb.MCPSetting_READ_WRITE,
"ws-other-unknown-field": storepb.MCPSetting_READ_WRITE,
"ws-ignoring": storepb.MCPSetting_READ_ONLY,
- "ws-absent": storepb.MCPSetting_READ_WRITE,
- "ws-legacy": storepb.MCPSetting_READ_WRITE,
+ "ws-typo": storepb.MCPSetting_CAPABILITY_UNSPECIFIED,
+ "ws-reserved": storepb.MCPSetting_Capability(2),
+ "ws-explicit-unset": storepb.MCPSetting_CAPABILITY_UNSPECIFIED,
+ "ws-missing-capability": storepb.MCPSetting_CAPABILITY_UNSPECIFIED,
} {
got, err := s.GetMCPSettingsUncached(ctx, workspace)
require.NoError(t, err, "%s stores a ceiling this build understands", workspace)
@@ -337,8 +302,6 @@ func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
"ws-readonly": false,
"ws-open": false,
"ws-other-unknown-field": false,
- "ws-absent": false,
- "ws-legacy": false,
} {
settings, err := s.GetMCPSettingsUncached(ctx, workspace)
require.NoError(t, err)
@@ -346,17 +309,18 @@ func TestMCPCeilingStoredValueFailsClosed(t *testing.T) {
"%s must resolve its OWN toggle, and an unset one is false", workspace)
}
- for _, workspace := range []string{"ws-typo", "ws-reserved", "ws-explicit-unset"} {
+ for _, workspace := range []string{"ws-absent", "ws-legacy"} {
got, err := s.GetMCPSettingsUncached(ctx, workspace)
- if err == nil {
- // The reserved number parses; it is refused later because no
- // ceiling serves it. What must never happen is resolving to a
- // value some other workspace stored.
- require.NotEqual(t, storepb.MCPSetting_READ_WRITE, got.Capability,
- "%s must not resolve to a neighbour's permissive ceiling", workspace)
- }
+ require.NoError(t, err)
+ require.Equal(t, storepb.MCPSetting_READ_WRITE, got.Capability,
+ "unexpected capability for %s", workspace)
+ require.False(t, got.IgnoreMaskingExemptions)
}
+ got, err := s.GetMCPSettingsUncached(ctx, "ws-wrong-type")
+ require.Error(t, err, "an invalid MCP payload must remain a store error")
+ require.Nil(t, got, "an error must not carry a guessed settings result")
+
for _, row := range rows {
t.Run(row.workspace, func(t *testing.T) {
e := echo.New()
diff --git a/backend/api/mcp/server_test.go b/backend/api/mcp/server_test.go
index f646641882..36bd570ad6 100644
--- a/backend/api/mcp/server_test.go
+++ b/backend/api/mcp/server_test.go
@@ -17,7 +17,6 @@ import (
"github.com/bytebase/bytebase/backend/api/auth"
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
- "github.com/bytebase/bytebase/backend/store"
)
func TestMCPAuthMiddleware(t *testing.T) {
@@ -142,7 +141,7 @@ func TestNewServerRequiresStore(t *testing.T) {
//
// The stored-value cases are covered against a real database in
// TestMCPCeilingStoredValueFailsClosed; this covers the arm above them.
-func TestMCPCeilingFailuresRefuseTheConnectionDifferently(t *testing.T) {
+func TestMCPReadFailureRefusesTheConnectionAsUnavailable(t *testing.T) {
secret := "test-secret-key"
profile := &config.Profile{Mode: common.ReleaseModeDev, ExternalURL: "https://bb.example.com"}
@@ -170,9 +169,6 @@ func TestMCPCeilingFailuresRefuseTheConnectionDifferently(t *testing.T) {
require.Equal(t, http.StatusServiceUnavailable, statusFor(t, errors.New("db unreachable")),
"a failed read is an outage; the session is still refused, and the client may retry")
- require.Equal(t, http.StatusForbidden,
- statusFor(t, errors.Wrap(store.ErrMCPCapabilityUnreadable, "READ_WRTIE")),
- "a stored value this build cannot interpret is a policy an admin must fix, not something to retry")
}
func TestMCPAuthFailsExplicitlyWithoutExternalURL(t *testing.T) {
diff --git a/backend/api/mcp/store_test.go b/backend/api/mcp/store_test.go
index 161c618882..19a953d38a 100644
--- a/backend/api/mcp/store_test.go
+++ b/backend/api/mcp/store_test.go
@@ -4,7 +4,6 @@ import (
"context"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/store"
)
type testServerStore struct {
@@ -41,8 +40,11 @@ func (s *testServerStore) GetWorkspaceProfileSetting(context.Context, string) (*
return s.workspaceProfile, nil
}
-func (s *testServerStore) GetMCPSettingsUncached(context.Context, string) (store.MCPSettings, error) {
- return store.MCPSettings{Capability: s.capability}, s.capabilityErr
+func (s *testServerStore) GetMCPSettingsUncached(context.Context, string) (*storepb.MCPSetting, error) {
+ if s.capabilityErr != nil {
+ return nil, s.capabilityErr
+ }
+ return &storepb.MCPSetting{Capability: s.capability}, nil
}
func (*testServerStore) DeleteOAuth2RefreshTokensByUserAndClient(context.Context, string, string) error {
diff --git a/backend/api/mcp/tool_reauthorize_test.go b/backend/api/mcp/tool_reauthorize_test.go
index fde55f7a72..7c31580d6c 100644
--- a/backend/api/mcp/tool_reauthorize_test.go
+++ b/backend/api/mcp/tool_reauthorize_test.go
@@ -36,6 +36,8 @@ func newReauthorizeTestServer(ctx context.Context, t *testing.T) (*Server, *stor
require.NoError(t, migrator.MigrateSchema(ctx, db))
_, err := db.ExecContext(ctx, `
INSERT INTO workspace (resource_id) VALUES ('ws-test');
+ INSERT INTO setting (name, workspace, value)
+ VALUES ('MCP', 'ws-test', '{"capability":"READ_WRITE"}');
INSERT INTO principal (name, email, password_hash) VALUES ('demo', '[email protected]', 'unused');
INSERT INTO oauth2_client (client_id, workspace, client_secret_hash, config)
VALUES ('client-A', NULL, 'unused-hash', '{"clientName":"test","redirectUris":["http://localhost/cb"],"grantTypes":["authorization_code","refresh_token"],"tokenEndpointAuthMethod":"none"}'::jsonb);
diff --git a/backend/api/mcp/tool_resolve_test.go b/backend/api/mcp/tool_resolve_test.go
index 158ada8833..71cfc95ae9 100644
--- a/backend/api/mcp/tool_resolve_test.go
+++ b/backend/api/mcp/tool_resolve_test.go
@@ -91,9 +91,9 @@ func TestResolve_ProjectInstanceDatabaseAndFilter(t *testing.T) {
}
// TestResolve_PolicyDenialGetsNoRoleAdvice covers the resolve door. It answers
-// 403 only when the stored ceiling is unreadable or unserved, which is exactly
-// the case where telling the agent to ask for bb.databases.list would send the
-// person it acts for after a grant that cannot fix a broken setting.
+// 403 when the stored ceiling is unserved, which is exactly the case where
+// telling the agent to ask for bb.databases.list would send the person it acts
+// for after a grant that cannot fix a broken setting.
func TestResolve_PolicyDenialGetsNoRoleAdvice(t *testing.T) {
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.URL.Path, "DatabaseService/ListDatabases") {
@@ -101,7 +101,7 @@ func TestResolve_PolicyDenialGetsNoRoleAdvice(t *testing.T) {
w.WriteHeader(http.StatusForbidden)
_ = json.NewEncoder(w).Encode(map[string]any{
"message": "/bytebase.v1.DatabaseService/ListDatabases is refused: this workspace's " +
- "stored MCP capability ceiling is not one this build understands",
+ "stored MCP capability ceiling is not one this build serves",
})
return
}
@@ -114,7 +114,7 @@ func TestResolve_PolicyDenialGetsNoRoleAdvice(t *testing.T) {
var te *toolError
require.ErrorAs(t, err, &te)
require.Contains(t, te.Message, "MCP capability ceiling")
- require.Empty(t, te.Suggestion, "no grant fixes a stored ceiling this build cannot read")
+ require.Empty(t, te.Suggestion, "no grant fixes a stored ceiling this build does not serve")
}
// TestTranslateMetadataError_PolicyDenialGetsNoRoleAdvice is the same contract
diff --git a/backend/api/oauth2/consent_audit.go b/backend/api/oauth2/consent_audit.go
index 395da15777..c648916881 100644
--- a/backend/api/oauth2/consent_audit.go
+++ b/backend/api/oauth2/consent_audit.go
@@ -15,20 +15,8 @@ import (
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/common/log"
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
- "github.com/bytebase/bytebase/backend/store"
)
-// One heading per way the workspace's MCP policy refuses a consent. Only the
-// heading is local: it is page copy, this is its one consumer, and the three
-// states have different fixes, so a heading naming the wrong one is the part a
-// hurried reader acts on. The sentence under it is the verdict's own
-// (auth.MCPCeilingVerdict.Refusal), shared with every other door.
-var consentHeadings = map[auth.MCPCeilingVerdict]string{
- auth.MCPCeilingDisabled: "MCP access is turned off",
- auth.MCPCeilingUnreadable: "This workspace's MCP setting cannot be read",
- auth.MCPCeilingUnserved: "This workspace's MCP setting is not one this version supports",
-}
-
// consentAttempt is the consent a ceiling check may refuse: who is consenting,
// which client asked, what was asked for, and where the client waits.
type consentAttempt struct {
@@ -43,7 +31,7 @@ type consentAttempt struct {
// *store.Store satisfies it; a test supplies its own, which is what lets the
// outage arm be exercised — a real store cannot be made to fail a single read.
type mcpCeilingReader interface {
- GetMCPSettingsUncached(ctx context.Context, workspace string) (store.MCPSettings, error)
+ GetMCPSettingsUncached(ctx context.Context, workspace string) (*storepb.MCPSetting, error)
}
// refuseConsentByCeiling holds a consent about to be granted against the
@@ -63,7 +51,7 @@ type mcpCeilingReader interface {
func (s *Service) refuseConsentByCeiling(c *echo.Context, attempt consentAttempt) (bool, error) {
ctx := c.Request().Context()
settings, err := s.mcpCeiling.GetMCPSettingsUncached(ctx, attempt.user.workspaceID)
- verdict := auth.ClassifyMCPCeiling(settings.Capability, err)
+ verdict := auth.ClassifyMCPCeiling(settings, err)
if verdict == auth.MCPCeilingServes {
return false, nil
}
@@ -120,7 +108,7 @@ func (s *Service) refuseConsent(c *echo.Context, attempt consentAttempt, verdict
// allows inline style and blocks inline script, so the page carries no
// behavior.
func consentRefusedHTML(verdict auth.MCPCeilingVerdict, redirectURI, state string) string {
- heading := html.EscapeString(consentHeadings[verdict])
+ heading := html.EscapeString(verdict.Heading())
page := `<!DOCTYPE html>
<html>
<head>
diff --git a/backend/api/oauth2/consent_ceiling_test.go b/backend/api/oauth2/consent_ceiling_test.go
index 1b96fa6d06..b12cdfdea8 100644
--- a/backend/api/oauth2/consent_ceiling_test.go
+++ b/backend/api/oauth2/consent_ceiling_test.go
@@ -47,13 +47,14 @@ func TestConsentCeiling(t *testing.T) {
_, err := db.ExecContext(ctx, `
INSERT INTO workspace (resource_id) VALUES
- ('ws-disabled'), ('ws-readonly'), ('ws-unset'), ('ws-typo'), ('ws-reserved');
+ ('ws-disabled'), ('ws-readonly'), ('ws-readwrite'), ('ws-typo'), ('ws-reserved');
INSERT INTO principal (name, email, password_hash) VALUES ('demo', '[email protected]', 'unused');
INSERT INTO oauth2_client (client_id, workspace, client_secret_hash, config)
VALUES ('client-A', NULL, 'unused-hash', '{"clientName":"test","redirectUris":["http://localhost/cb"],"grantTypes":["authorization_code","refresh_token"],"tokenEndpointAuthMethod":"none"}'::jsonb);
INSERT INTO setting (name, workspace, value) VALUES
('MCP', 'ws-disabled', '{"capability":"DISABLED"}'),
('MCP', 'ws-readonly', '{"capability":"READ_ONLY"}'),
+ ('MCP', 'ws-readwrite', '{"capability":"READ_WRITE"}'),
('MCP', 'ws-typo', '{"capability":"READ_ONLYY"}'),
('MCP', 'ws-reserved', '{"capability":2}');
`)
@@ -112,20 +113,17 @@ func TestConsentCeiling(t *testing.T) {
"a consent never reached the /mcp boundary that mints one")
})
- t.Run("a stored ceiling nobody can read is refused as a typo, not as policy", func(t *testing.T) {
+ t.Run("an unknown capability is refused as unserved", func(t *testing.T) {
rec := consentTo(t, s, "ws-typo")
require.Equal(t, http.StatusForbidden, rec.Code)
- require.Contains(t, rec.Body.String(), "not one this build understands")
- // The heading follows the verdict: a stored value nobody can read is
- // not "an admin turned MCP off", and the heading is what a hurried
- // reader acts on.
- require.Contains(t, rec.Body.String(), "MCP setting cannot be read")
+ require.Contains(t, rec.Body.String(), "not one this build serves")
+ require.Contains(t, rec.Body.String(), "not one this version supports")
require.NotContains(t, rec.Body.String(), "MCP access is turned off")
rows := auditRows(t, "ws-typo")
require.Len(t, rows, 1)
- require.Contains(t, rows[0].Payload.GetStatus().GetMessage(), "not one this build understands")
+ require.Contains(t, rows[0].Payload.GetStatus().GetMessage(), "not one this build serves")
})
t.Run("a ceiling this build does not serve is refused too", func(t *testing.T) {
@@ -139,7 +137,7 @@ func TestConsentCeiling(t *testing.T) {
})
t.Run("a serving ceiling consents and records nothing", func(t *testing.T) {
- for _, workspace := range []string{"ws-readonly", "ws-unset"} {
+ for _, workspace := range []string{"ws-readonly", "ws-readwrite"} {
t.Run(workspace, func(t *testing.T) {
rec := consentTo(t, s, workspace)
@@ -283,8 +281,8 @@ func TestConsentCeilingOutageIsNotARefusal(t *testing.T) {
// cannot be made to do for one call.
type failingCeilingReader struct{ err error }
-func (f failingCeilingReader) GetMCPSettingsUncached(context.Context, string) (store.MCPSettings, error) {
- return store.MCPSettings{}, f.err
+func (f failingCeilingReader) GetMCPSettingsUncached(context.Context, string) (*storepb.MCPSetting, error) {
+ return nil, f.err
}
// TestTokenIssuanceRechecksTheCeiling pins the half a consent-time check alone
@@ -307,6 +305,7 @@ func TestTokenIssuanceRechecksTheCeiling(t *testing.T) {
INSERT INTO principal (name, email, password_hash) VALUES ('demo', '[email protected]', 'unused');
INSERT INTO oauth2_client (client_id, workspace, client_secret_hash, config)
VALUES ('client-A', NULL, 'unused-hash', '{"clientName":"test","redirectUris":["http://localhost/cb"],"grantTypes":["authorization_code","refresh_token"],"tokenEndpointAuthMethod":"none"}'::jsonb);
+ INSERT INTO setting (name, workspace, value) VALUES ('MCP', 'ws-test', '{"capability":"READ_WRITE"}');
`)
require.NoError(t, err)
@@ -331,7 +330,7 @@ func TestTokenIssuanceRechecksTheCeiling(t *testing.T) {
require.NotEmpty(t, tokens.RefreshToken)
_, err = db.ExecContext(ctx,
- `INSERT INTO setting (name, workspace, value) VALUES ('MCP', 'ws-test', '{"capability":"DISABLED"}')`)
+ `UPDATE setting SET value = '{"capability":"DISABLED"}' WHERE workspace = 'ws-test' AND name = 'MCP'`)
require.NoError(t, err)
refresh := func() *httptest.ResponseRecorder {
@@ -416,6 +415,6 @@ func TestTokenIssuanceRechecksTheCeiling(t *testing.T) {
// the live ceiling would now refuse.
type servingCeilingReader struct{}
-func (servingCeilingReader) GetMCPSettingsUncached(context.Context, string) (store.MCPSettings, error) {
- return store.MCPSettings{Capability: storepb.MCPSetting_READ_WRITE}, nil
+func (servingCeilingReader) GetMCPSettingsUncached(context.Context, string) (*storepb.MCPSetting, error) {
+ return &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE}, nil
}
diff --git a/backend/api/oauth2/grant_test.go b/backend/api/oauth2/grant_test.go
index 75a19ef8c9..36e75eedb4 100644
--- a/backend/api/oauth2/grant_test.go
+++ b/backend/api/oauth2/grant_test.go
@@ -69,6 +69,7 @@ func TestResourceScopeGrantLifecycle(t *testing.T) {
INSERT INTO principal (name, email, password_hash) VALUES ('demo', '[email protected]', 'unused');
INSERT INTO oauth2_client (client_id, workspace, client_secret_hash, config)
VALUES ('client-A', NULL, 'unused-hash', '{"clientName":"test","redirectUris":["http://localhost/cb"],"grantTypes":["authorization_code","refresh_token"],"tokenEndpointAuthMethod":"none"}'::jsonb);
+ INSERT INTO setting (name, workspace, value) VALUES ('MCP', 'ws-test', '{"capability":"READ_WRITE"}');
`)
require.NoError(t, err)
diff --git a/backend/api/oauth2/token.go b/backend/api/oauth2/token.go
index b8b2d6a594..0ceb4371b9 100644
--- a/backend/api/oauth2/token.go
+++ b/backend/api/oauth2/token.go
@@ -465,7 +465,7 @@ func (s *Service) refuseIssuanceByCeiling(ctx context.Context, workspaceID strin
return nil
}
settings, err := s.mcpCeiling.GetMCPSettingsUncached(ctx, workspaceID)
- switch verdict := auth.ClassifyMCPCeiling(settings.Capability, err); {
+ switch verdict := auth.ClassifyMCPCeiling(settings, err); {
case verdict == auth.MCPCeilingServes:
return nil
case verdict.IsPolicy():
diff --git a/backend/api/v1/mcp_gate.go b/backend/api/v1/mcp_gate.go
index 8df77e61c0..e8ec8da60d 100644
--- a/backend/api/v1/mcp_gate.go
+++ b/backend/api/v1/mcp_gate.go
@@ -16,7 +16,6 @@ import (
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
- "github.com/bytebase/bytebase/backend/store"
)
// mcpDenialWording is one reason's sentence plus the class it belongs to. The
@@ -267,7 +266,7 @@ var mcpServingClasses = map[storepb.MCPSetting_Capability][]v1pb.MCPMethodClass{
// database. Named for what it does rather than for what satisfies it, per the
// convention for a single-method interface.
type mcpSettingsReader interface {
- GetMCPSettingsUncached(ctx context.Context, workspace string) (store.MCPSettings, error)
+ GetMCPSettingsUncached(ctx context.Context, workspace string) (*storepb.MCPSetting, error)
}
// mcpSettingsContextKey carries the MCP settings the gate already resolved, so
@@ -275,13 +274,13 @@ type mcpSettingsReader interface {
// than a second one the gate could disagree with.
type mcpSettingsContextKey struct{}
-func withMCPSettings(ctx context.Context, settings store.MCPSettings) context.Context {
+func withMCPSettings(ctx context.Context, settings *storepb.MCPSetting) context.Context {
return context.WithValue(ctx, mcpSettingsContextKey{}, settings)
}
-func mcpSettingsFromContext(ctx context.Context) (store.MCPSettings, bool) {
- settings, ok := ctx.Value(mcpSettingsContextKey{}).(store.MCPSettings)
- return settings, ok
+func mcpSettingsFromContext(ctx context.Context) (*storepb.MCPSetting, bool) {
+ settings, ok := ctx.Value(mcpSettingsContextKey{}).(*storepb.MCPSetting)
+ return settings, ok && settings != nil
}
// internalMCPGateInterceptor refuses, before dispatch, every request an MCP
@@ -452,19 +451,16 @@ func (in *internalMCPGateInterceptor) refuse(ctx context.Context, req connect.An
// refuseByCeiling holds the method's class against the workspace's live
// ceiling, and returns the settings it resolved so the request can be held
// against the same read further in.
-func (in *internalMCPGateInterceptor) refuseByCeiling(ctx context.Context, procedure string, class v1pb.MCPMethodClass) (store.MCPSettings, bool, error) {
+func (in *internalMCPGateInterceptor) refuseByCeiling(ctx context.Context, procedure string, class v1pb.MCPMethodClass) (*storepb.MCPSetting, bool, error) {
// The internal auth interceptor puts the delegated credential's workspace
// on every request it admits, so an empty one means the chain was
// reordered — a bug in this process, not an outage, and not a verdict
// about the caller.
workspaceID := common.GetWorkspaceIDFromContext(ctx)
if workspaceID == "" {
- return store.MCPSettings{}, false, connect.NewError(connect.CodeInternal, errors.Errorf(
+ return nil, false, connect.NewError(connect.CodeInternal, errors.Errorf(
"%s cannot be checked against the MCP capability ceiling: no workspace on the request", procedure))
}
- // The store applies the backward-compatible default for a workspace that
- // never set a ceiling and reports everything it cannot make sense of as an
- // error.
settings, err := in.store.GetMCPSettingsUncached(ctx, workspaceID)
// auth.ClassifyMCPCeiling decides, so this gate, the /mcp connection gate,
@@ -484,17 +480,17 @@ func (in *internalMCPGateInterceptor) refuseByCeiling(ctx context.Context, proce
// below, which holds an explicit empty list for it, so a mode that serves
// nothing reads as an ordinary per-method denial naming the class — the
// more useful answer at a per-method door than a workspace-level sentence.
- switch verdict := auth.ClassifyMCPCeiling(settings.Capability, err); verdict {
+ switch verdict := auth.ClassifyMCPCeiling(settings, err); verdict {
case auth.MCPCeilingServes, auth.MCPCeilingDisabled:
case auth.MCPCeilingUnavailable:
slog.Warn("failed to resolve the MCP capability ceiling; refusing the request",
slog.String("method", procedure), slog.String("workspace", workspaceID), log.BBError(err))
- return settings, false, connect.NewError(connect.CodeUnavailable, errors.Errorf(
+ return nil, false, connect.NewError(connect.CodeUnavailable, errors.Errorf(
"%s is refused: %s", procedure, verdict.Refusal()))
default:
slog.Warn("the MCP capability ceiling refuses this request",
slog.String("method", procedure), slog.String("workspace", workspaceID), log.BBError(err))
- return settings, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
+ return nil, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
"%s is refused: %s", procedure, verdict.Refusal()))
}
@@ -504,13 +500,13 @@ func (in *internalMCPGateInterceptor) refuseByCeiling(ctx context.Context, proce
// the switch above already refused. Kept because the serving table and
// the classifier are two statements of one rule, and this is what a
// caller gets if they ever part company.
- return settings, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
+ return nil, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
"%s is refused: %s", procedure, auth.MCPCeilingUnserved.Refusal()))
}
if slices.Contains(served, class) {
return settings, false, nil
}
- return settings, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
+ return nil, true, connect.NewError(connect.CodePermissionDenied, errors.Errorf(
"%s is a %v method and this workspace's MCP capability ceiling is %v, which serves %s. "+
"Ask a workspace admin to raise the MCP ceiling in the workspace settings, "+
"or perform this action signed in to the Bytebase console instead",
diff --git a/backend/api/v1/mcp_gate_test.go b/backend/api/v1/mcp_gate_test.go
index 24931ec0ee..cfefd8c2c6 100644
--- a/backend/api/v1/mcp_gate_test.go
+++ b/backend/api/v1/mcp_gate_test.go
@@ -21,7 +21,6 @@ import (
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
"github.com/bytebase/bytebase/backend/generated-go/v1/v1connect"
- "github.com/bytebase/bytebase/backend/store"
)
// mcpClassification is one v1 RPC's MCP annotations, as the compiled
@@ -396,21 +395,23 @@ func TestLintRefusedClassesMatchTheServingTable(t *testing.T) {
// TestLintCeilingAdmissionMatchesTheServingTable is the connection gate's half
// of the same arrangement. The /mcp boundary decides whether a session opens at
-// all, and it asks auth.MCPCeilingServesAnything, which cannot see this table.
-// This holds the two against each other over every ceiling value, so a mode
+// all through auth.ClassifyMCPCeiling, which cannot see this table. This holds
+// the two against each other over every ceiling value, so a mode
// that serves no class cannot start admitting sessions — or the reverse, which
// would refuse a connection whose methods the gate is ready to serve.
func TestLintCeilingAdmissionMatchesTheServingTable(t *testing.T) {
values := storepb.MCPSetting_Capability(0).Descriptor().Values()
for i := range values.Len() {
capability := storepb.MCPSetting_Capability(values.Get(i).Number())
- require.Equal(t, len(mcpServingClasses[capability]) > 0, auth.MCPCeilingServesAnything(capability),
- "%v: the serving table and auth.MCPCeilingServesAnything disagree about whether this ceiling serves anything", capability)
+ verdict := auth.ClassifyMCPCeiling(&storepb.MCPSetting{Capability: capability}, nil)
+ require.Equal(t, len(mcpServingClasses[capability]) > 0, verdict == auth.MCPCeilingServes,
+ "%v: the serving table and auth.ClassifyMCPCeiling disagree about whether this ceiling serves anything", capability)
}
// A stored number no release ever wrote is refused too, and it cannot come
// from the descriptor because it is in no build's enum.
for _, unknown := range []storepb.MCPSetting_Capability{2, 99} {
- require.False(t, auth.MCPCeilingServesAnything(unknown),
+ verdict := auth.ClassifyMCPCeiling(&storepb.MCPSetting{Capability: unknown}, nil)
+ require.NotEqual(t, auth.MCPCeilingServes, verdict,
"%v: a ceiling this build cannot interpret must not open a session", unknown)
}
}
@@ -797,8 +798,11 @@ type mcpGateStore struct {
err error
}
-func (s mcpGateStore) GetMCPSettingsUncached(context.Context, string) (store.MCPSettings, error) {
- return store.MCPSettings{Capability: s.ceiling, IgnoreMaskingExemptions: s.ignoreMaskingExemptions}, s.err
+func (s mcpGateStore) GetMCPSettingsUncached(context.Context, string) (*storepb.MCPSetting, error) {
+ if s.err != nil {
+ return nil, s.err
+ }
+ return &storepb.MCPSetting{Capability: s.ceiling, IgnoreMaskingExemptions: s.ignoreMaskingExemptions}, nil
}
func readWriteCeiling() mcpGateStore {
@@ -934,19 +938,13 @@ func TestMCPGateFailsClosedOnTheCeiling(t *testing.T) {
"the denial rows an operator filters on must be denials; an outage is not one")
})
- t.Run("a stored value this build cannot interpret is a policy refusal", func(t *testing.T) {
- // The opposite half of the same failure. No retry fixes a mistyped
- // ceiling, so promising one would be a lie, and an admin has to act —
- // which makes it a denial, and an audited one. The /mcp connection
- // gate splits the same two the same way.
- got := invokeMCPGate(t, mcpGateStore{err: errors.Wrap(store.ErrMCPCapabilityUnreadable, "READ_WRTIE")},
+ t.Run("an unspecified stored value is a policy refusal", func(t *testing.T) {
+ got := invokeMCPGate(t, mcpGateStore{ceiling: storepb.MCPSetting_CAPABILITY_UNSPECIFIED},
classContext(v1pb.MCPMethodClass_READ),
v1connect.DatabaseServiceGetDatabaseProcedure, connect.NewRequest(&v1pb.GetDatabaseRequest{}))
require.Error(t, got.err)
require.False(t, got.dispatched)
require.Equal(t, connect.CodePermissionDenied, connect.CodeOf(got.err))
- require.NotContains(t, got.err.Error(), "READ_WRTIE",
- "the agent gets the outcome, not the workspace's storage state")
require.True(t, got.auditMarked)
})
diff --git a/backend/api/v1/mcp_info.go b/backend/api/v1/mcp_info.go
index 5b132541e6..f8a0d6ba5d 100644
--- a/backend/api/v1/mcp_info.go
+++ b/backend/api/v1/mcp_info.go
@@ -20,7 +20,6 @@ import (
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base"
- "github.com/bytebase/bytebase/backend/store"
)
// GetMCPInfo reports what MCP does in this workspace.
@@ -43,9 +42,9 @@ func (s *WorkspaceService) GetMCPInfo(ctx context.Context, _ *connect.Request[v1
// 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.
- switch verdict := auth.ClassifyMCPCeiling(settings.Capability, err); verdict {
+ switch verdict := auth.ClassifyMCPCeiling(settings, err); verdict {
case auth.MCPCeilingServes, auth.MCPCeilingDisabled:
- case auth.MCPCeilingUnreadable, auth.MCPCeilingUnserved:
+ case auth.MCPCeilingUnserved:
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.New(verdict.Refusal()))
default:
// The store error stays in the log. This method is served to MCP
@@ -74,7 +73,7 @@ func (s *WorkspaceService) GetMCPInfo(ctx context.Context, _ *connect.Request[v1
// admitted under, which is the rule mcp_gate.go states and the clamp and the
// masking check both follow. Off that chain — the console, an admin opening the
// settings page — nothing is stamped and the store is read.
-func (s *WorkspaceService) mcpSettingsForInfo(ctx context.Context, workspaceID string) (store.MCPSettings, error) {
+func (s *WorkspaceService) mcpSettingsForInfo(ctx context.Context, workspaceID string) (*storepb.MCPSetting, error) {
if settings, ok := mcpSettingsFromContext(ctx); ok {
return settings, nil
}
diff --git a/backend/api/v1/mcp_info_test.go b/backend/api/v1/mcp_info_test.go
index 7a3d14ca4f..f4897c28b4 100644
--- a/backend/api/v1/mcp_info_test.go
+++ b/backend/api/v1/mcp_info_test.go
@@ -359,11 +359,11 @@ func TestGetMCPInfoHandler(t *testing.T) {
require.NoError(t, err)
}
- t.Run("a workspace that never configured MCP", func(t *testing.T) {
+ t.Run("a workspace with the default MCP policy", func(t *testing.T) {
info, err := get(workspaceCtx())
require.NoError(t, err)
require.Equal(t, "workspaces/"+workspaceID, info.Workspace)
- require.Equal(t, v1pb.MCPSetting_READ_WRITE, info.Capability)
+ require.Equal(t, v1pb.MCPSetting_READ_ONLY, info.Capability)
require.False(t, info.IgnoreMaskingExemptions)
// The list is the live registry's, not a fixture: every entry must be a
@@ -402,11 +402,11 @@ func TestGetMCPInfoHandler(t *testing.T) {
"an admin with MCP off is exactly who needs to see what the other modes contain")
})
- t.Run("a ceiling this build cannot read fails closed", func(t *testing.T) {
+ t.Run("an unknown capability fails closed", 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 understands")
+ require.Contains(t, err.Error(), "not one this build serves")
})
t.Run("a ceiling this build does not serve fails closed", func(t *testing.T) {
@@ -423,7 +423,7 @@ func TestGetMCPInfoHandler(t *testing.T) {
// request under READ_ONLY. Answering from the store would report a
// ceiling the request was not admitted under.
setCeiling(t, `{"capability":"DISABLED"}`)
- stamped := withMCPSettings(workspaceCtx(), store.MCPSettings{
+ stamped := withMCPSettings(workspaceCtx(), &storepb.MCPSetting{
Capability: storepb.MCPSetting_READ_ONLY,
IgnoreMaskingExemptions: true,
})
diff --git a/backend/api/v1/mcp_masking_test.go b/backend/api/v1/mcp_masking_test.go
index d84f20cdb6..eadbc979de 100644
--- a/backend/api/v1/mcp_masking_test.go
+++ b/backend/api/v1/mcp_masking_test.go
@@ -15,8 +15,8 @@ import (
"github.com/bytebase/bytebase/backend/store"
)
-func maskingSettings(ignore bool) store.MCPSettings {
- return store.MCPSettings{
+func maskingSettings(ignore bool) *storepb.MCPSetting {
+ return &storepb.MCPSetting{
Capability: storepb.MCPSetting_READ_WRITE,
IgnoreMaskingExemptions: ignore,
}
diff --git a/backend/api/v1/mcp_sql_clamp_test.go b/backend/api/v1/mcp_sql_clamp_test.go
index 744d33b8c5..f0024df0c1 100644
--- a/backend/api/v1/mcp_sql_clamp_test.go
+++ b/backend/api/v1/mcp_sql_clamp_test.go
@@ -11,7 +11,6 @@ import (
storepb "github.com/bytebase/bytebase/backend/generated-go/store"
v1pb "github.com/bytebase/bytebase/backend/generated-go/v1"
parserbase "github.com/bytebase/bytebase/backend/plugin/parser/base"
- "github.com/bytebase/bytebase/backend/store"
// The clamp asks the parser registry what it can classify and how it
// splits, so this test binary has to register what the server registers.
@@ -489,12 +488,12 @@ func TestMCPClampAppliesOnlyToReadOnlyMCPSessions(t *testing.T) {
{
name: "an MCP session under a read-write ceiling is not clamped",
ctx: withMCPSettings(contextWithAuth(withGrant),
- store.MCPSettings{Capability: storepb.MCPSetting_READ_WRITE}),
+ &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE}),
},
{
name: "an MCP session under a read-only ceiling is clamped",
ctx: withMCPSettings(contextWithAuth(withGrant),
- store.MCPSettings{Capability: storepb.MCPSetting_READ_ONLY}),
+ &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_ONLY}),
applies: true,
},
{
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index 4c8cfa7d18..1c2653b107 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -4,14 +4,13 @@ import (
"context"
"log/slog"
"regexp"
- "slices"
"strings"
"time"
"connectrpc.com/connect"
"github.com/pkg/errors"
- "google.golang.org/protobuf/proto" // Added
+ "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"github.com/bytebase/bytebase/backend/common"
@@ -66,76 +65,19 @@ func (s *SettingService) ListSettings(ctx context.Context, _ *connect.Request[v1
}
response := &v1pb.ListSettingsResponse{}
- workspaceID := common.GetWorkspaceIDFromContext(ctx)
- stored := map[storepb.SettingName]bool{}
for _, setting := range settings {
if s.isSettingDisallowed(setting.Name) {
continue
}
- // The MCP setting is served below, from its own reader. The bulk read
- // gives the parsed message and nothing else, and serving that would
- // report a row whose capability this build cannot resolve as a
- // never-configured workspace — the permissive default over one that is
- // refusing every connection.
- if setting.Name == storepb.SettingName_MCP {
- continue
- }
- stored[setting.Name] = true
settingMessage, err := convertToSettingMessage(setting)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))
}
response.Settings = append(response.Settings, settingMessage)
}
- for _, name := range alwaysPresentSettings {
- if stored[name] || s.isSettingDisallowed(name) {
- continue
- }
- // One reader for the MCP setting, so a list and a get cannot describe
- // the same row two ways — the unreadable state only one of them carried
- // is the difference an admin acts on.
- if name == storepb.SettingName_MCP {
- settingMessage, err := s.mcpSettingMessage(ctx, workspaceID)
- if err != nil {
- return nil, err
- }
- response.Settings = append(response.Settings, settingMessage)
- continue
- }
- settingMessage, err := convertToSettingMessage(emptySetting(name, workspaceID))
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))
- }
- response.Settings = append(response.Settings, settingMessage)
- }
return connect.NewResponse(response), nil
}
-// alwaysPresentSettings are the settings whose absent row is a defined state
-// rather than a missing resource, so Get, List and Update all answer that they
-// exist. The MCP setting is one: no row means MCP was never configured, which
-// the resolver reads as the backward-compatible ceiling. Three different
-// answers is how a client reads the resource and then cannot patch it.
-var alwaysPresentSettings = []storepb.SettingName{storepb.SettingName_MCP}
-
-func settingIsAlwaysPresent(name storepb.SettingName) bool {
- return emptySetting(name, "") != nil
-}
-
-// emptySetting is the zero value served for an always-present setting with no
-// row yet, or nil for one whose absence really is a 404. It must match what the
-// store writes for an empty row, or the resource would change shape the first
-// time anyone saves it. TestAlwaysPresentSettingsHaveAZeroValue pins that this
-// and alwaysPresentSettings agree.
-func emptySetting(name storepb.SettingName, workspaceID string) *store.SettingMessage {
- switch name {
- case storepb.SettingName_MCP:
- return &store.SettingMessage{Name: name, Workspace: workspaceID, Value: &storepb.MCPSetting{}}
- default:
- return nil
- }
-}
-
// GetSetting gets the setting by name.
func (s *SettingService) GetSetting(ctx context.Context, request *connect.Request[v1pb.GetSettingRequest]) (*connect.Response[v1pb.Setting], error) {
settingName, err := common.GetSettingName(request.Msg.Name)
@@ -167,23 +109,12 @@ func (s *SettingService) GetSetting(ctx context.Context, request *connect.Reques
return nil, err
}
- if storeSettingName == storepb.SettingName_MCP {
- message, err := s.mcpSettingMessage(ctx, common.GetWorkspaceIDFromContext(ctx))
- if err != nil {
- return nil, err
- }
- return connect.NewResponse(message), nil
- }
-
setting, err := s.store.GetSetting(ctx, common.GetWorkspaceIDFromContext(ctx), storeSettingName)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get setting: %v", err))
}
if setting == nil {
- if !settingIsAlwaysPresent(storeSettingName) {
- return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("setting %s not found", settingName))
- }
- setting = emptySetting(storeSettingName, common.GetWorkspaceIDFromContext(ctx))
+ return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("setting %s not found", settingName))
}
// Only return whitelisted setting.
settingMessage, err := convertToSettingMessage(setting)
@@ -233,22 +164,11 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Req
workspaceID := common.GetWorkspaceIDFromContext(ctx)
- // The MCP setting dispatches before the read below, not after. That read
- // parses the stored row, and a ceiling this build cannot parse fails it —
- // which would refuse the write that repairs the row, on the one path an
- // admin has to repair it (BOT-107). updateMCPSetting needs nothing from it:
- // it reads the row again under a lock, and takes its audit before-image
- // from that locked read rather than from the cache this one consults.
- if storeSettingName == storepb.SettingName_MCP {
- s.stampMCPAuditBefore(ctx, workspaceID)
- return s.updateMCPSetting(ctx, request, workspaceID)
- }
-
existedSetting, err := s.store.GetSetting(ctx, workspaceID, storeSettingName)
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to find setting %s with error: %v", settingName, err))
}
- if existedSetting == nil && !request.Msg.AllowMissing && !settingIsAlwaysPresent(storeSettingName) {
+ if existedSetting == nil && !request.Msg.AllowMissing {
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("setting %s not found", settingName))
}
// audit log.
@@ -268,6 +188,38 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *connect.Req
var resetClassification bool
switch storeSettingName {
+ case storepb.SettingName_MCP:
+ if request.Msg.UpdateMask == nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("update mask is required"))
+ }
+ payload := request.Msg.Setting.Value.GetMcp()
+ if payload == nil {
+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("mcp setting is required"))
+ }
+
+ mcpSetting := &storepb.MCPSetting{Capability: storepb.MCPSetting_READ_WRITE}
+ if existedSetting != nil {
+ existing, ok := existedSetting.Value.(*storepb.MCPSetting)
+ if !ok {
+ return nil, connect.NewError(connect.CodeInternal, errors.Errorf("invalid setting value type for %s", storepb.SettingName_MCP))
+ }
+ mcpSetting = proto.CloneOf(existing)
+ }
+
+ for _, path := range request.Msg.UpdateMask.Paths {
+ switch path {
+ case "value.mcp.capability":
+ mcpSetting.Capability = convertToStoreMCPCapability(payload.Capability)
+ case "value.mcp.ignore_masking_exemptions":
+ mcpSetting.IgnoreMaskingExemptions = payload.IgnoreMaskingExemptions
+ default:
+ return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid update mask path %q", path))
+ }
+ }
+ if err := validateMCPCapability(mcpSetting.GetCapability()); err != nil {
+ return nil, err
+ }
+ storeSettingValue = mcpSetting
case storepb.SettingName_WORKSPACE_PROFILE:
return s.updateWorkspaceProfileSetting(ctx, request, workspaceID)
case storepb.SettingName_WORKSPACE_APPROVAL:
@@ -652,7 +604,7 @@ func (s *SettingService) updateWorkspaceProfileSetting(ctx context.Context, requ
return nil, err
}
var lockedBefore *storepb.WorkspaceProfileSetting
- apply := func(current proto.Message, _ []byte) (proto.Message, error) {
+ apply := func(current proto.Message) (proto.Message, error) {
oldSetting, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("invalid setting value type for %s", storepb.SettingName_WORKSPACE_PROFILE))
@@ -685,7 +637,7 @@ func (s *SettingService) updateWorkspaceProfileSetting(ctx context.Context, requ
// longer populate the cache), but validate against a clone anyway so
// a validate-only request can never mutate shared state should the
// read path change.
- if _, err := apply(proto.CloneOf(profileValue), nil); err != nil {
+ if _, err := apply(proto.CloneOf(profileValue)); err != nil {
return nil, err
}
return connect.NewResponse(&v1pb.Setting{
@@ -1164,283 +1116,10 @@ func validateAnnouncementTheme(t *storepb.WorkspaceProfileSetting_Announcement_A
return nil
}
-// mcpSettingMessage answers the MCP setting from the row itself, carrying the
-// unreadable state the parsed value cannot.
-//
-// Uncached, unlike its sibling settings: the setting cache has no TTL and only
-// in-process writes refresh it, while every way a capability becomes unreadable
-// — a hand edit, a newer replica during a rolling upgrade — happens out of
-// band. A cached copy would show an admin the ceiling that was readable before
-// the edit, over a workspace where MCP is now refused every connection. The
-// enforcement gate reads the same row the same way
-// (store.GetMCPSettingsUncached).
-func (s *SettingService) mcpSettingMessage(ctx context.Context, workspaceID string) (*v1pb.Setting, error) {
- raw, exists, err := s.store.RawSettingValue(ctx, workspaceID, storepb.SettingName_MCP)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get setting: %v", err))
- }
- stored := &storepb.MCPSetting{}
- if exists {
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(raw), stored); err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("the mcp setting does not parse: %v", err))
- }
- }
- message, err := convertToSettingMessage(&store.SettingMessage{
- Name: storepb.SettingName_MCP,
- Workspace: workspaceID,
- Value: stored,
- })
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))
- }
- message.GetValue().GetMcp().CapabilityUnreadable = mcpCapabilityUnreadable(raw, exists, stored)
- return message, nil
-}
-
-// mcpCapabilityUnreadable reports whether this build can resolve a ceiling from
-// the stored row.
-//
-// True when the row carries a capability key but protojson leaves the parsed
-// capability unspecified. An enum name a newer release wrote is the legitimate
-// trigger — a rolling upgrade — and a hand-edited token reaches the same state:
-// null, "", and an explicit CAPABILITY_UNSPECIFIED all parse away to unset
-// without erroring (TestMCPUnreadableCeilingIsVisibleToTheAdmin covers all
-// four).
-//
-// An absent key gives the same parsed value and means the opposite: never
-// configured, which resolves to the READ_WRITE default rather than a refusal
-// (BOT-100). A row that does not parse at all never gets this far; the read
-// fails, because there is no ceiling in it to describe.
-//
-// The page and the write path's repair guard both read this. Two copies drift
-// into a row the resolver refuses while the console reports a ceiling, or a
-// repair the page offers and the write rejects.
-func mcpCapabilityUnreadable(raw string, exists bool, stored *storepb.MCPSetting) bool {
- if !exists || stored.GetCapability() != storepb.MCPSetting_CAPABILITY_UNSPECIFIED {
- return false
- }
- key, err := store.RawMCPCapability(raw)
- // No capability key is the ordinary never-configured state — a first edit
- // that set only the masking toggle leaves exactly that — and resolves
- // READ_WRITE.
- return err == nil && key != ""
-}
-
-// stampMCPAuditBefore records the pre-lock MCP before-image on the audit row.
-//
-// The generic path below stamps one from the read it does before the merge.
-// MCP dispatches above that read, so without this a refused write — an
-// unreadable ceiling, a rejected mask, a dry run — audits with no before-image
-// at all, and a refusal is where the ceiling that was in force matters most.
-// updateMCPSetting overwrites it from the locked row when the write lands,
-// which is the value that was true at commit time.
-func (s *SettingService) stampMCPAuditBefore(ctx context.Context, workspaceID string) {
- setServiceData, ok := common.GetSetServiceDataFromContext(ctx)
- if !ok {
- return
- }
- message, err := s.mcpSettingMessage(ctx, workspaceID)
- if err != nil {
- slog.Warn("audit: failed to read the mcp setting for the before-image", log.BBError(err))
- return
- }
- p, err := anypb.New(message)
- if err != nil {
- slog.Warn("audit: failed to convert to anypb.Any", log.BBError(err))
- return
- }
- setServiceData(p)
-}
-
-// updateMCPSetting merges the named update-mask paths into the stored MCP
-// setting under a row lock. Each path sets one field, so an admin changing the
-// masking toggle does not have to resend a ceiling they are not changing.
-//
-// Locked rather than read-merge-write, unlike the sibling settings: this row is
-// the MCP kill switch, and two concurrent saves that each merged onto their own
-// unlocked read would leave one of them silently reverted — for a ceiling, the
-// difference between off and on.
-//
-// The audit before-image is re-captured from the locked row, overwriting the
-// pre-lock snapshot UpdateSetting took from the setting cache. A ceiling flipped
-// out of band would otherwise be recorded as a transition from whatever the
-// cache still held, which never happened.
-func (s *SettingService) updateMCPSetting(ctx context.Context, request *connect.Request[v1pb.UpdateSettingRequest], workspaceID string) (*connect.Response[v1pb.Setting], error) {
- if request.Msg.UpdateMask == nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("update mask is required"))
- }
- payload := request.Msg.Setting.Value.GetMcp()
- if payload == nil {
- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("mcp setting is required"))
- }
-
- repairsCapability := slices.Contains(request.Msg.UpdateMask.Paths, "value.mcp.capability")
-
- var lockedBefore *storepb.MCPSetting
- // The v1-only capability_unreadable the before-image cannot carry on its
- // own: lockedBefore is a store message, and that field exists to tell a
- // repair of an unreadable ceiling apart from configuring a workspace that
- // never had one. Without it the audit row for the two is byte-identical.
- var lockedBeforeUnreadable bool
- apply := func(current proto.Message, raw []byte) (proto.Message, error) {
- existing, ok := current.(*storepb.MCPSetting)
- if !ok {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("invalid setting value type for %s", storepb.SettingName_MCP))
- }
- // Captured before anything below can refuse. Every decision here is made
- // against the LOCKED row, so that is what the audit row has to show —
- // a refusal most of all, since the refusal names a ceiling only the
- // locked read saw. The pre-lock stamp can already be describing a value
- // another replica has replaced, which is the same reason the guard
- // below reads raw rather than a pre-flight.
- lockedBefore = proto.CloneOf(existing)
- lockedBeforeUnreadable = mcpCapabilityUnreadable(string(raw), len(raw) > 0, existing)
- // A key this build does not define would be deleted by the merge below:
- // the unmarshaler discarded it, so re-marshalling writes the row back
- // without it. During a rolling upgrade that is an older replica erasing
- // what a newer one configured. Reads stay lenient on purpose — one
- // field from a newer release must not disable MCP — but a partial write
- // refuses rather than corrupt.
- if len(raw) > 0 {
- unknown, err := store.UnknownSettingKeys(string(raw), existing)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to read the stored mcp setting: %v", err))
- }
- if len(unknown) > 0 {
- return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf(
- "this workspace's MCP setting carries %v, which this build does not understand, and saving another field would delete it. "+
- "A newer Bytebase replica most likely wrote it; retry once the rollout has finished", unknown))
- }
- }
-
- // A stored capability this build cannot read is enforced closed, and
- // this merge would quietly erase it: the unmarshaler drops an enum name
- // it does not know, and marshalling omits the zero enum, so the row
- // would come back with no capability key at all and the next read would
- // resolve it to the permissive default. Saving the masking toggle would
- // reopen MCP. Refuse unless this same request sets a capability.
- //
- // Read from the locked row, not before the lock: a newer replica during
- // a rolling upgrade can write a name this build has never heard of, and
- // a pre-flight would have checked a value that is no longer there.
- //
- // The same predicate the page reads, so a row cannot be offered as
- // repairable on one and refused on the other.
- if lockedBeforeUnreadable && !repairsCapability {
- return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf(
- "this workspace's stored MCP capability is not one this build understands, and saving another field would erase it. "+
- "Set value.mcp.capability in the same request to repair it"))
- }
- merged := proto.CloneOf(existing)
- for _, path := range request.Msg.UpdateMask.Paths {
- switch path {
- case "value.mcp.capability":
- capability := convertToStoreMCPCapability(payload.Capability)
- if err := validateMCPCapability(capability); err != nil {
- return nil, err
- }
- merged.Capability = capability
- case "value.mcp.ignore_masking_exemptions":
- merged.IgnoreMaskingExemptions = payload.IgnoreMaskingExemptions
- default:
- return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid update mask path %q", path))
- }
- }
- return merged, nil
- }
-
- // A dry run must not reach the row or the served cache: flipping the ceiling
- // on a request that asked for nothing would be the kill switch turning
- // itself off.
- if request.Msg.ValidateOnly {
- // The same parse and the same apply the locked path runs, so the dry run
- // cannot disagree with the write it stands in for in either direction.
- raw, _, err := s.store.RawSettingValue(ctx, workspaceID, storepb.SettingName_MCP)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to read mcp setting: %v", err))
- }
- current := &storepb.MCPSetting{}
- if raw != "" {
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(raw), current); err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("the mcp setting does not parse: %v", err))
- }
- }
- validated, err := apply(current, []byte(raw))
- if err != nil {
- var connectErr *connect.Error
- if errors.As(err, &connectErr) {
- return nil, err
- }
- return nil, connect.NewError(connect.CodeInvalidArgument, err)
- }
- settingMessage, err := convertToSettingMessage(&store.SettingMessage{
- Name: storepb.SettingName_MCP,
- Workspace: workspaceID,
- Value: validated,
- })
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))
- }
- return connect.NewResponse(settingMessage), nil
- }
-
- // UpdateSettingAtomic updates existing state only, and a workspace that
- // never configured MCP has no row to lock.
- if err := s.store.EnsureSettingRow(ctx, workspaceID, storepb.SettingName_MCP); err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to create mcp setting: %v", err))
- }
- // Overwrites the pre-lock stamp on either outcome. apply captured this from
- // the locked row, so it describes the state the write actually decided
- // against; the pre-lock stamp stays only for failures that never reach the
- // lock at all.
- stampLocked := func() {
- setServiceData, ok := common.GetSetServiceDataFromContext(ctx)
- if !ok || lockedBefore == nil {
- return
- }
- v1pbSetting, err := convertToSettingMessage(&store.SettingMessage{
- Name: storepb.SettingName_MCP,
- Workspace: workspaceID,
- Value: lockedBefore,
- })
- if err != nil {
- slog.Warn("audit: failed to convert to v1.Setting", log.BBError(err))
- return
- }
- v1pbSetting.GetValue().GetMcp().CapabilityUnreadable = lockedBeforeUnreadable
- p, err := anypb.New(v1pbSetting)
- if err != nil {
- slog.Warn("audit: failed to convert to anypb.Any", log.BBError(err))
- return
- }
- setServiceData(p)
- }
-
- setting, err := s.store.UpdateSettingAtomic(ctx, workspaceID, storepb.SettingName_MCP, apply, nil)
- if err != nil {
- stampLocked()
- var connectErr *connect.Error
- if errors.As(err, &connectErr) {
- return nil, err
- }
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to set setting: %v", err))
- }
- stampLocked()
-
- settingMessage, err := convertToSettingMessage(setting)
- if err != nil {
- return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to convert setting message: %v", err))
- }
- return connect.NewResponse(settingMessage), nil
-}
-
-// validateMCPCapability rejects an explicit write of UNSPECIFIED — absent has
-// defined resolver semantics (it resolves to READ_WRITE), so writing
-// "unspecified" is a caller bug — and unknown enum numbers, which proto3 open
-// enums would otherwise let through.
+// validateMCPCapability rejects UNSPECIFIED and unknown enum numbers.
func validateMCPCapability(capability storepb.MCPSetting_Capability) error {
if capability == storepb.MCPSetting_CAPABILITY_UNSPECIFIED {
- return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("capability cannot be set to CAPABILITY_UNSPECIFIED; choose an explicit capability or omit the update mask path to leave it unset"))
+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("capability must be specified"))
}
if _, ok := storepb.MCPSetting_Capability_name[int32(capability)]; !ok {
return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("unknown capability value %d", capability))
diff --git a/backend/api/v1/setting_service_test.go b/backend/api/v1/setting_service_test.go
index 0c509e93ec..fc703a7ddf 100644
--- a/backend/api/v1/setting_service_test.go
+++ b/backend/api/v1/setting_service_test.go
@@ -282,17 +282,3 @@ func TestPreflightWorkspaceProfileSaaSRestrictedPaths(t *testing.T) {
require.NoError(t, err, path)
}
}
-
-// TestAlwaysPresentSettingsHaveAZeroValue pins the two halves of the
-// always-present rule against each other. ListSettings walks the slice to
-// synthesize absent rows; Get and Update key on emptySetting returning
-// non-nil. A name in one and not the other is a setting that lists but cannot
-// be read, or reads but cannot be patched.
-func TestAlwaysPresentSettingsHaveAZeroValue(t *testing.T) {
- for _, name := range alwaysPresentSettings {
- require.NotNil(t, emptySetting(name, "ws"), "%v is listed as always present", name)
- require.True(t, settingIsAlwaysPresent(name))
- }
- require.False(t, settingIsAlwaysPresent(storepb.SettingName_WORKSPACE_PROFILE),
- "a setting whose row always exists must keep 404 for a genuinely missing one")
-}
diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.go
index c22c9bc82e..df331148db 100644
--- a/backend/api/v1/workspace_service.go
+++ b/backend/api/v1/workspace_service.go
@@ -227,7 +227,7 @@ func (s *WorkspaceService) RotateDirectorySyncToken(ctx context.Context, req *co
// would keep accepting the token they think they just replaced. apply stays
// free of database reads; it runs holding the row lock and the connection.
if _, err := s.store.UpdateSettingAtomic(ctx, workspaceID, storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected setting value type %T", current)
diff --git a/backend/component/recovery/service.go b/backend/component/recovery/service.go
index 85acab86e8..164f6c0b30 100644
--- a/backend/component/recovery/service.go
+++ b/backend/component/recovery/service.go
@@ -135,7 +135,7 @@ func (s *Service) EnablePasswordSignin(ctx context.Context, workspaceID string)
ctx,
workspaceID,
storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.New("workspace profile setting has an unexpected type")
diff --git a/backend/generated-go/store/setting.pb.go b/backend/generated-go/store/setting.pb.go
index cabb6b370d..2dee560f3c 100644
--- a/backend/generated-go/store/setting.pb.go
+++ b/backend/generated-go/store/setting.pb.go
@@ -150,9 +150,7 @@ func (WorkspaceProfileSetting_DatabaseChangeMode) EnumDescriptor() ([]byte, []in
return file_store_setting_proto_rawDescGZIP(), []int{1, 0}
}
-// Capability is the ceiling: a session runs at this level or lower. An absent
-// MCP setting resolves to READ_WRITE, so a workspace that never configured
-// MCP is unaffected.
+// Capability is the ceiling: a session runs at this level or lower.
type MCPSetting_Capability int32
const (
diff --git a/backend/generated-go/v1/setting_service.pb.go b/backend/generated-go/v1/setting_service.pb.go
index 2506dc5247..a53f87c2ee 100644
--- a/backend/generated-go/v1/setting_service.pb.go
+++ b/backend/generated-go/v1/setting_service.pb.go
@@ -148,10 +148,9 @@ func (Setting_SettingName) EnumDescriptor() ([]byte, []int) {
return file_v1_setting_service_proto_rawDescGZIP(), []int{5, 0}
}
-// Capability is the ceiling: a session runs at this level or lower. An absent
-// MCP setting resolves to READ_WRITE, so a workspace that never configured
-// MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
-// omit the update mask path to leave the ceiling unset.
+// Capability is the ceiling: a session runs at this level or lower.
+// Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+// path to leave the current ceiling unchanged.
type MCPSetting_Capability int32
const (
@@ -1346,33 +1345,8 @@ type MCPSetting struct {
// It narrows what an agent reads through the paths Bytebase masks; it is not
// a confidentiality boundary.
IgnoreMaskingExemptions bool `protobuf:"varint,2,opt,name=ignore_masking_exemptions,json=ignoreMaskingExemptions,proto3" json:"ignore_masking_exemptions,omitempty"`
- // True when the row carries a capability key that this build cannot resolve
- // to a ceiling. An enum name a newer release wrote is the legitimate trigger,
- // during a rolling upgrade; a hand-edited token reaches the same state.
- // False for every readable row, including one that was never configured.
- //
- // The capability field cannot carry this on its own: the unmarshaler discards
- // an enum name it does not know, so an unreadable row and a never-configured
- // one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
- // first and served at READ_WRITE for the second. A client reading only the
- // capability shows the most permissive ceiling over a workspace where every
- // MCP connection is being refused.
- //
- // A row protojson cannot parse at all is NOT this state. There is no ceiling
- // in it to describe, so the read fails instead, and repairing it needs an
- // operator rather than this field.
- //
- // The stored token itself is deliberately not returned. Telling a typo apart
- // from a value a newer release wrote would only pay off if this enum grew,
- // and it has not: its one reserved slot held a tier removed before any
- // release shipped it.
- //
- // Set the row right by writing value.mcp.capability. Any other path is
- // refused while this is true, because the merge that saved it would erase the
- // value nobody could read.
- CapabilityUnreadable bool `protobuf:"varint,3,opt,name=capability_unreadable,json=capabilityUnreadable,proto3" json:"capability_unreadable,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *MCPSetting) Reset() {
@@ -1419,13 +1393,6 @@ func (x *MCPSetting) GetIgnoreMaskingExemptions() bool {
return false
}
-func (x *MCPSetting) GetCapabilityUnreadable() bool {
- if x != nil {
- return x.CapabilityUnreadable
- }
- return false
-}
-
type SQLEditorThemeSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@@ -3678,14 +3645,13 @@ const file_v1_setting_service_proto_rawDesc = "" +
"\x18require_uppercase_letter\x18\x04 \x01(\bR\x16requireUppercaseLetter\x12:\n" +
"\x19require_special_character\x18\x05 \x01(\bR\x17requireSpecialCharacter\x12Q\n" +
"&require_reset_password_for_first_login\x18\x06 \x01(\bR!requireResetPasswordForFirstLogin\x12F\n" +
- "\x11password_rotation\x18\a \x01(\v2\x19.google.protobuf.DurationR\x10passwordRotationJ\x04\b\x0f\x10\x10J\x04\b\x1a\x10\x1bJ\x04\b\x10\x10\x11R\x0emcp_capability\"\xa3\x02\n" +
+ "\x11password_rotation\x18\a \x01(\v2\x19.google.protobuf.DurationR\x10passwordRotationJ\x04\b\x0f\x10\x10J\x04\b\x1a\x10\x1bJ\x04\b\x10\x10\x11R\x0emcp_capability\"\xe9\x01\n" +
"\n" +
"MCPSetting\x12B\n" +
"\n" +
"capability\x18\x01 \x01(\x0e2\".bytebase.v1.MCPSetting.CapabilityR\n" +
"capability\x12:\n" +
- "\x19ignore_masking_exemptions\x18\x02 \x01(\bR\x17ignoreMaskingExemptions\x128\n" +
- "\x15capability_unreadable\x18\x03 \x01(\bB\x03\xe0A\x03R\x14capabilityUnreadable\"[\n" +
+ "\x19ignore_masking_exemptions\x18\x02 \x01(\bR\x17ignoreMaskingExemptions\"[\n" +
"\n" +
"Capability\x12\x1a\n" +
"\x16CAPABILITY_UNSPECIFIED\x10\x00\x12\f\n" +
diff --git a/backend/generated-go/v1/setting_service_equal.pb.go b/backend/generated-go/v1/setting_service_equal.pb.go
index 8c76add619..d87de87740 100644
--- a/backend/generated-go/v1/setting_service_equal.pb.go
+++ b/backend/generated-go/v1/setting_service_equal.pb.go
@@ -425,9 +425,6 @@ func (x *MCPSetting) Equal(y *MCPSetting) bool {
if x.IgnoreMaskingExemptions != y.IgnoreMaskingExemptions {
return false
}
- if x.CapabilityUnreadable != y.CapabilityUnreadable {
- return false
- }
return true
}
diff --git a/backend/generated-go/v1/workspace_service.pb.go b/backend/generated-go/v1/workspace_service.pb.go
index 6a4e6f2f0d..e7cc01e7e0 100644
--- a/backend/generated-go/v1/workspace_service.pb.go
+++ b/backend/generated-go/v1/workspace_service.pb.go
@@ -196,8 +196,7 @@ 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. A workspace that never configured
- // MCP resolves to READ_WRITE.
+ // The ceiling in force for this workspace.
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/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sql
index be1e8a852e..b1f677fa19 100644
--- a/backend/migrator/migration/LATEST.sql
+++ b/backend/migrator/migration/LATEST.sql
@@ -81,7 +81,7 @@ ALTER SEQUENCE principal_id_seq RESTART WITH 101;
-- Setting
CREATE TABLE setting (
-- name: SYSTEM, WORKSPACE_PROFILE, WORKSPACE_APPROVAL,
- -- APP_IM, AI, DATA_CLASSIFICATION, SEMANTIC_TYPES, ENVIRONMENT
+ -- APP_IM, AI, DATA_CLASSIFICATION, SEMANTIC_TYPES, ENVIRONMENT, EMAIL, MCP
-- Enum: SettingName (proto/store/store/setting.proto)
name text NOT NULL,
workspace text NOT NULL REFERENCES workspace(resource_id),
diff --git a/backend/store/setting.go b/backend/store/setting.go
index 4b6c340ee0..89d9494996 100644
--- a/backend/store/setting.go
+++ b/backend/store/setting.go
@@ -3,10 +3,8 @@ package store
import (
"context"
"database/sql"
- "encoding/json"
"log/slog"
"math"
- "slices"
"time"
"github.com/pkg/errors"
@@ -25,6 +23,8 @@ type SettingMessage struct {
Value proto.Message
}
+var errSettingValueInvalid = errors.New("the stored setting value is invalid")
+
func getSettingMessage(name storepb.SettingName) (proto.Message, error) {
switch name {
case storepb.SettingName_WORKSPACE_PROFILE:
@@ -355,7 +355,7 @@ func (s *Store) ListSettings(ctx context.Context, find *FindSettingMessage) ([]*
return nil, err
}
if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(valueString), msg); err != nil {
- return nil, err
+ return nil, errors.Wrapf(errSettingValueInvalid, "failed to unmarshal setting %s: %v", settingMessage.Name, err)
}
settingMessage.Value = msg
@@ -373,51 +373,6 @@ func (s *Store) ListSettings(ctx context.Context, find *FindSettingMessage) ([]*
return settingMessages, nil
}
-// RawSettingValue returns a setting row's stored JSON, and whether the row
-// exists. Callers that must reason about what the row literally says — rather
-// than what the unmarshaler could make of it — read it through this.
-func (s *Store) RawSettingValue(ctx context.Context, workspace string, name storepb.SettingName) (string, bool, error) {
- q := qb.Q().Space(`
- SELECT value FROM setting WHERE workspace = ? AND name = ?
- `, workspace, name.String())
- query, args, err := q.ToSQL()
- if err != nil {
- return "", false, errors.Wrap(err, "failed to build sql")
- }
- var valueString string
- if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&valueString); err != nil {
- if errors.Is(err, sql.ErrNoRows) {
- return "", false, nil
- }
- return "", false, errors.Wrapf(err, "failed to read the %s setting", name)
- }
- return valueString, true, nil
-}
-
-// EnsureSettingRow creates an empty row for a setting that has none, and does
-// nothing when one exists. It is what lets a setting not seeded at workspace
-// creation be updated under a row lock: UpdateSettingAtomic deliberately
-// refuses a missing row, so the first write has to make one first.
-//
-// Only safe for a setting whose readers answer an empty row and an absent one
-// the same way. The MCP setting does: SettingService.GetSetting returns a zero
-// message for both, and GetMCPSettingsUncached resolves both to READ_WRITE.
-// WorkspaceProfileSetting does not — an absent row is an error there.
-func (s *Store) EnsureSettingRow(ctx context.Context, workspace string, name storepb.SettingName) error {
- q := qb.Q().Space(`
- INSERT INTO setting (name, workspace, value) VALUES (?, ?, '{}')
- ON CONFLICT (name, workspace) DO NOTHING
- `, name.String(), workspace)
- query, args, err := q.ToSQL()
- if err != nil {
- return errors.Wrap(err, "failed to build sql")
- }
- if _, err := s.GetDB().ExecContext(ctx, query, args...); err != nil {
- return errors.Wrapf(err, "failed to create setting %s", name)
- }
- return nil
-}
-
// UpdateSettingAtomic performs a row-locking read-modify-write of a setting:
// the current value is read under SELECT ... FOR UPDATE, apply transforms it,
// and the result is written back in the same transaction — so a concurrent
@@ -434,18 +389,11 @@ func (s *Store) EnsureSettingRow(ctx context.Context, workspace string, name sto
// lock, and a nested read wanting a second connection is the bounded-pool
// starvation cycle.
//
-// apply also receives the locked row's raw bytes. The unmarshaler discards what
-// it cannot interpret — an enum name from a newer release, say — and marshalling
-// omits a zero field, so a merge that only looked at current would write the row
-// back with that value silently deleted. A caller that must not do that reads
-// the raw bytes, and reads them from the locked row rather than a pre-flight, so
-// there is no window for a concurrent writer to slip a value in between.
-//
// A row this build cannot parse is refused: the only message this could hand
// apply is the zero value, and a merging apply would write that back — a
// caller that sets one field on current and returns it (RotateDirectorySyncToken)
// would erase everything else the row held.
-func (s *Store) UpdateSettingAtomic(ctx context.Context, workspace string, name storepb.SettingName, apply func(current proto.Message, raw []byte) (proto.Message, error), postCommit func(current *SettingMessage)) (*SettingMessage, error) {
+func (s *Store) UpdateSettingAtomic(ctx context.Context, workspace string, name storepb.SettingName, apply func(current proto.Message) (proto.Message, error), postCommit func(current *SettingMessage)) (*SettingMessage, error) {
return s.writeSettingAtomic(ctx, workspace, name, func(raw string) (proto.Message, error) {
current, err := getSettingMessage(name)
if err != nil {
@@ -454,7 +402,7 @@ func (s *Store) UpdateSettingAtomic(ctx context.Context, workspace string, name
if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(raw), current); err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal setting %s", name)
}
- return apply(current, []byte(raw))
+ return apply(current)
}, postCommit)
}
@@ -624,25 +572,6 @@ func (s *Store) DeleteSetting(ctx context.Context, workspace string, name storep
return nil
}
-// ErrMCPCapabilityUnreadable marks a stored MCP capability ceiling this build
-// cannot interpret: an enum name it does not know, a wrong-typed value, a row
-// that is not the JSON the setting expects. It is deliberately distinct from a
-// failed READ, because the two are opposite outcomes for the caller. A read
-// that failed is an outage and will likely succeed on retry; a value that
-// cannot be interpreted will never succeed until an admin rewrites it, so
-// telling the caller to retry would be a lie and telling it "policy" is the
-// truth. Both refuse.
-var ErrMCPCapabilityUnreadable = errors.New("the stored MCP capability ceiling cannot be interpreted")
-
-// MCPSettings is the MCP setting resolved for enforcement: the effective
-// ceiling, never UNSPECIFIED, and the masking toggle.
-type MCPSettings struct {
- Capability storepb.MCPSetting_Capability
- // IgnoreMaskingExemptions is false when unset, so a workspace that never
- // configured MCP keeps following each user's masking provisioning.
- IgnoreMaskingExemptions bool
-}
-
// GetMCPSettingsUncached reads the workspace's stored MCP setting straight from
// the database, bypassing the setting cache. The cache has no TTL and only
// in-process writes refresh it, so a setting flipped out of band — direct SQL,
@@ -650,119 +579,24 @@ type MCPSettings struct {
//
// Both fields come off one row, so the gate cannot admit a call that a later
// enforcement point then judges under a different row.
+// Returns nil with any error; no caller may act on partially resolved settings.
//
-// The raw-key check exists because protojson silently discards an enum NAME it
-// does not know, and the discarded value resolves to the permissive default
-// below, so a stored {"capability":"READ_ONLYY"} would reopen the workspace. An
-// unknown enum NUMBER survives protojson and fails closed on its own, because
-// no mode serves it, so only the name case needs the raw read. Nothing else
-// about the row is read strictly: rejecting it for an unknown field would let
-// one field from a newer release disable MCP workspace-wide.
-//
-// Before this change the ceiling lived on the workspace profile as
-// mcp_capability. That key is not read here and is not migrated. The shared
-// unmarshaler discards unknown fields, so a profile row still carrying it is
-// inert, and a workspace that set a ceiling before upgrading resolves to
-// READ_WRITE until the MCP setting is saved.
-//
-// Deliberate: 3.21.0 and 3.21.1 served the field on the settings API, but the
-// only UI sat behind isDev() (GeneralPage.tsx) and Terraform never exposed it,
-// so setting a ceiling took a hand-built UpdateSetting call naming the
-// field-mask path.
-func (s *Store) GetMCPSettingsUncached(ctx context.Context, workspace string) (MCPSettings, error) {
- const unset = storepb.MCPSetting_CAPABILITY_UNSPECIFIED
- const whenUnset = storepb.MCPSetting_READ_WRITE
- failClosed := MCPSettings{Capability: unset}
-
- valueString, exists, err := s.RawSettingValue(ctx, workspace, storepb.SettingName_MCP)
- if err != nil {
- return failClosed, err
- }
- if !exists {
- // No MCP setting row: this workspace never configured MCP.
- return MCPSettings{Capability: whenUnset}, nil
- }
-
- setting := &storepb.MCPSetting{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(valueString), setting); err != nil {
- return failClosed, errors.Wrapf(ErrMCPCapabilityUnreadable, "the MCP setting does not parse: %v", err)
- }
- settings := MCPSettings{
- Capability: setting.GetCapability(),
- IgnoreMaskingExemptions: setting.GetIgnoreMaskingExemptions(),
- }
- if settings.Capability != unset {
- return settings, nil
- }
-
- stored, err := RawMCPCapability(valueString)
+// Existing workspaces without an MCP row retain the previous READ_WRITE
+// behavior. Workspace creation persists READ_ONLY for new workspaces. A present
+// row whose payload the store protocol cannot decode remains an error.
+func (s *Store) GetMCPSettingsUncached(ctx context.Context, workspace string) (*storepb.MCPSetting, error) {
+ stored, err := s.GetSettingUncached(ctx, workspace, storepb.SettingName_MCP)
if err != nil {
- return failClosed, err
+ return nil, err
}
- if stored != "" {
- return failClosed, errors.Wrapf(ErrMCPCapabilityUnreadable, "%s is not a value this build understands", stored)
+ if stored == nil {
+ return &storepb.MCPSetting{
+ Capability: storepb.MCPSetting_READ_WRITE,
+ }, nil
}
- settings.Capability = whenUnset
- return settings, nil
-}
-
-// UnknownSettingKeys returns the top-level keys a stored row carries that the
-// given message does not define, sorted.
-//
-// The unmarshaler discards them, so a read is unaffected — deliberately: one
-// field from a newer release must not disable a setting workspace-wide. A
-// partial WRITE is the opposite case. It re-marshals what the build understood
-// and the discarded keys are gone, so a merge on an older replica during a
-// rolling upgrade would delete configuration a newer one wrote. A caller that
-// merges rather than replaces checks this first.
-func UnknownSettingKeys(raw string, m proto.Message) ([]string, error) {
- var fields map[string]json.RawMessage
- if err := json.Unmarshal([]byte(raw), &fields); err != nil {
- return nil, errors.Wrapf(err, "the setting is not a JSON object")
- }
- known := map[string]bool{}
- descriptors := m.ProtoReflect().Descriptor().Fields()
- for i := 0; i < descriptors.Len(); i++ {
- field := descriptors.Get(i)
- known[field.JSONName()] = true
- known[string(field.Name())] = true
- }
- var unknown []string
- for key := range fields {
- if !known[key] {
- unknown = append(unknown, key)
- }
+ setting, ok := stored.Value.(*storepb.MCPSetting)
+ if !ok {
+ return nil, errors.Errorf("invalid setting value type for %s", storepb.SettingName_MCP)
}
- slices.Sort(unknown)
- return unknown, nil
-}
-
-// RawMCPCapability returns the MCP setting row's raw capability value, or ""
-// when the row carries no such key. The JSON name and the proto field name are
-// both "capability", so there is one spelling to check.
-//
-// A key present alongside a parsed-unset field means the stored name is one this
-// build does not know. An explicit CAPABILITY_UNSPECIFIED counts as that too,
-// deliberately: protojson omits a zero enum when it writes, and the settings API
-// rejects an explicit UNSPECIFIED, so no Bytebase write produces this key with
-// that value — only a hand-edited row does, and there it is indistinguishable
-// from a typo.
-//
-// Read with encoding/json rather than the shared protojson unmarshaler, and
-// that is forced, not legacy: this recovers what protojson DISCARDED.
-// common.ProtojsonUnmarshaler sets DiscardUnknown, so an enum name this build
-// does not know leaves no trace in the message, and protojson exposes no way to
-// ask what token a field carried. A strict unmarshaler is not the alternative —
-// it does reject the unknown enum name, but it rejects an unknown FIELD with
-// the same error, and tolerating a field a newer replica wrote is the rolling
-// upgrade this build has to survive.
-func RawMCPCapability(value string) (string, error) {
- var fields map[string]json.RawMessage
- if err := json.Unmarshal([]byte(value), &fields); err != nil {
- return "", errors.Wrapf(ErrMCPCapabilityUnreadable, "the MCP setting is not a JSON object: %v", err)
- }
- if raw, ok := fields["capability"]; ok {
- return string(raw), nil
- }
- return "", nil
+ return setting, nil
}
diff --git a/backend/store/setting_atomic_test.go b/backend/store/setting_atomic_test.go
index 81f359cb2b..db84e5b28a 100644
--- a/backend/store/setting_atomic_test.go
+++ b/backend/store/setting_atomic_test.go
@@ -78,7 +78,7 @@ func TestUpdateSettingAtomicInterleaving(t *testing.T) {
firstResult := make(chan error, 1)
go func() {
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -100,7 +100,7 @@ func TestUpdateSettingAtomicInterleaving(t *testing.T) {
secondResult := make(chan error, 1)
go func() {
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -165,7 +165,7 @@ func TestUpdateSettingAtomicApplyAbort(t *testing.T) {
sentinel := errors.New("validation failed")
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -191,7 +191,7 @@ func TestUpdateSettingAtomicMissingRow(t *testing.T) {
ctx, _, s := newSettingAtomicFixture(t)
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_AI,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
return current, nil
}, nil)
require.Error(t, err)
@@ -241,7 +241,7 @@ func TestUpdateSettingAtomicPublishOrder(t *testing.T) {
firstResult := make(chan error, 1)
go func() {
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -261,7 +261,7 @@ func TestUpdateSettingAtomicPublishOrder(t *testing.T) {
secondResult := make(chan error, 1)
go func() {
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -373,7 +373,7 @@ func TestGetSettingCacheDisabledNotSerialized(t *testing.T) {
writerResult := make(chan error, 1)
go func() {
_, err := s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -436,7 +436,7 @@ func TestUpdateSettingAtomicPublishSurvivesCancellation(t *testing.T) {
var observed *storepb.WorkspaceProfileSetting
_, err := s.UpdateSettingAtomic(updateCtx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
profile, ok := current.(*storepb.WorkspaceProfileSetting)
if !ok {
return nil, errors.Errorf("unexpected type %T", current)
@@ -536,7 +536,7 @@ func TestUpdateSettingAtomicRefusesAnUnparsedRow(t *testing.T) {
applied := false
_, err = s.UpdateSettingAtomic(ctx, "default", storepb.SettingName_WORKSPACE_PROFILE,
- func(current proto.Message, _ []byte) (proto.Message, error) {
+ func(current proto.Message) (proto.Message, error) {
applied = true
return current, nil
}, nil)
diff --git a/backend/store/workspace.go b/backend/store/workspace.go
index 9801da654f..d12321643c 100644
--- a/backend/store/workspace.go
+++ b/backend/store/workspace.go
@@ -143,6 +143,9 @@ func (s *Store) CreateWorkspace(ctx context.Context, create *WorkspaceMessage, a
DisallowPasswordSignin: false,
PasswordRestriction: &storepb.WorkspaceProfileSetting_PasswordRestriction{MinLength: 8},
}},
+ {storepb.SettingName_MCP, &storepb.MCPSetting{
+ Capability: storepb.MCPSetting_READ_ONLY,
+ }},
{storepb.SettingName_ENVIRONMENT, &storepb.EnvironmentSetting{
Environments: []*storepb.EnvironmentSetting_Environment{
{Title: "Test", Id: "test", Color: defaultEnvironmentColor()},
diff --git a/backend/store/workspace_test.go b/backend/store/workspace_test.go
index 359bd3b410..ad341b75b5 100644
--- a/backend/store/workspace_test.go
+++ b/backend/store/workspace_test.go
@@ -57,11 +57,18 @@ func TestCreateWorkspaceInitializesDefaults(t *testing.T) {
storepb.SettingName_WORKSPACE_APPROVAL,
storepb.SettingName_WORKSPACE_PROFILE,
storepb.SettingName_ENVIRONMENT,
+ storepb.SettingName_MCP,
storepb.SettingName_AI,
} {
require.Truef(t, slices.Contains(names, name), "missing setting %s", name)
}
+ mcpSetting, err := stores.GetSetting(ctx, workspaceID, storepb.SettingName_MCP)
+ require.NoError(t, err)
+ mcp, ok := mcpSetting.Value.(*storepb.MCPSetting)
+ require.True(t, ok)
+ require.Equal(t, storepb.MCPSetting_READ_ONLY, mcp.Capability)
+
environmentSetting, err := stores.GetSetting(ctx, workspaceID, storepb.SettingName_ENVIRONMENT)
require.NoError(t, err)
environments, ok := environmentSetting.Value.(*storepb.EnvironmentSetting)
diff --git a/backend/tests/mcp_capability_setting_test.go b/backend/tests/mcp_capability_setting_test.go
index 3911e12e48..523872d9a5 100644
--- a/backend/tests/mcp_capability_setting_test.go
+++ b/backend/tests/mcp_capability_setting_test.go
@@ -69,9 +69,8 @@ func currentWorkspaceID(ctx context.Context, t *testing.T, ctl *controller) stri
// TestMCPCapabilitySettingRoundTrip verifies the workspace MCP capability
// ceiling round-trips through the v1 settings API for every defined value, and
-// that an explicit write of UNSPECIFIED is rejected — absent has defined
-// resolver semantics (it resolves to READ_WRITE), so writing "unspecified"
-// is a caller bug.
+// that an explicit write of UNSPECIFIED is rejected. Workspace creation stores
+// a concrete capability.
func TestMCPCapabilitySettingRoundTrip(t *testing.T) {
t.Parallel()
a := require.New(t)
@@ -82,10 +81,10 @@ func TestMCPCapabilitySettingRoundTrip(t *testing.T) {
a.NoError(err)
defer ctl.Close(ctx)
- // A fresh workspace has no explicit ceiling.
+ // A fresh workspace starts with the safe, immediately useful ceiling.
capability, err := ctl.getMCPCapability(ctx)
a.NoError(err)
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, capability)
+ a.Equal(v1pb.MCPSetting_READ_ONLY, capability)
for _, want := range []v1pb.MCPSetting_Capability{
v1pb.MCPSetting_DISABLED,
@@ -122,38 +121,11 @@ func TestMCPCapabilitySettingRoundTrip(t *testing.T) {
got, err = ctl.getMCPCapability(ctx)
a.NoError(err)
a.Equal(v1pb.MCPSetting_DISABLED, got)
-
- // Saving the other field of the MCP setting must not revert a ceiling
- // written out-of-band (emergency SQL): the update path merges the named
- // mask paths onto the stored value and writes the whole message back, so
- // merging onto a stale cached base would silently clear the kill switch.
- // The cache is warm from the reads above and holds DISABLED; flip the
- // stored value behind the server's back, then update the other field.
- workspaceID := currentWorkspaceID(ctx, t, ctl)
- db, err := sql.Open("pgx", ctl.profile.PgURL)
- a.NoError(err)
- defer db.Close()
- _, err = db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{capability}', '"READ_ONLY"')
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID)
- a.NoError(err)
- a.NoError(ctl.setIgnoreMaskingExemptions(ctx, true))
- got, err = ctl.getMCPCapability(ctx)
- a.NoError(err)
- a.Equal(v1pb.MCPSetting_READ_ONLY, got,
- "the sibling update must merge onto the stored setting, not a stale cached one")
- ignoring, err := ctl.getIgnoreMaskingExemptions(ctx)
- a.NoError(err)
- a.True(ignoring, "and the field it named must actually be written")
}
-// TestMCPSettingIsPresentBeforeItIsConfigured is the answer to "does
-// settings/MCP exist?" on a workspace that never touched it. Get, List and
-// Update have to agree: a client that reads the resource and then cannot patch
-// it with default update semantics has been told two different things.
-
-func TestMCPSettingIsPresentBeforeItIsConfigured(t *testing.T) {
+// TestMCPSettingExistsWithTheWorkspace pins that workspace creation writes the
+// safe default for new workspaces.
+func TestMCPSettingExistsWithTheWorkspace(t *testing.T) {
t.Parallel()
a := require.New(t)
ctx := context.Background()
@@ -165,8 +137,8 @@ func TestMCPSettingIsPresentBeforeItIsConfigured(t *testing.T) {
got, err := ctl.settingServiceClient.GetSetting(ctx, connect.NewRequest(&v1pb.GetSettingRequest{
Name: "settings/" + v1pb.Setting_MCP.String(),
}))
- a.NoError(err, "an unconfigured MCP setting reads as its zero value, not 404")
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, got.Msg.Value.GetMcp().GetCapability())
+ a.NoError(err)
+ a.Equal(v1pb.MCPSetting_READ_ONLY, got.Msg.Value.GetMcp().GetCapability())
list, err := ctl.settingServiceClient.ListSettings(ctx, connect.NewRequest(&v1pb.ListSettingsRequest{}))
a.NoError(err)
@@ -196,16 +168,12 @@ func TestMCPSettingIsPresentBeforeItIsConfigured(t *testing.T) {
a.Equal(v1pb.MCPSetting_READ_ONLY, stored)
}
-// TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate is the write-path half of
-// the fail-closed rule. GetMCPSettingsUncached refuses a stored capability this
-// build cannot read; the merge would erase it, because the unmarshaler drops an
-// enum name it does not know and marshalling omits the zero enum — so the row
-// would come back with no capability key and the next read would resolve it to
-// READ_WRITE. Saving the masking toggle would reopen MCP.
-//
-// Reachable on a rolling upgrade, not only from a typo: a newer replica can
-// write a capability name this build has never heard of.
-func TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
+// TestMCPUnrecognizedCeilingSurvivesAToggleOnlyUpdate is the write-path half of
+// the fail-closed rule. The unmarshaler resolves an unknown enum name to
+// UNSPECIFIED, and marshalling would omit that zero enum. The partial update
+// therefore requires the request to set a recognized capability rather than
+// silently erasing the stored value.
+func TestMCPUnrecognizedCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
t.Parallel()
a := require.New(t)
ctx := context.Background()
@@ -214,8 +182,6 @@ func TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
a.NoError(err)
defer ctl.Close(ctx)
- a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_DISABLED))
-
workspaceID := currentWorkspaceID(ctx, t, ctl)
db, err := sql.Open("pgx", ctl.profile.PgURL)
a.NoError(err)
@@ -231,8 +197,7 @@ func TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
err = ctl.setIgnoreMaskingExemptions(ctx, true)
a.Error(err, "saving the toggle must not erase a ceiling this build cannot read")
- a.Equal(connect.CodeFailedPrecondition, connect.CodeOf(err))
- a.Contains(err.Error(), "value.mcp.capability", "the refusal must name the way out")
+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))
var stored string
a.NoError(db.QueryRowContext(ctx, `
@@ -241,8 +206,7 @@ func TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
`, workspaceID).Scan(&stored))
a.Equal("READ_ONLYY", stored, "the unreadable ceiling is still there, so enforcement still fails closed")
- // The dry run reads the same raw row the locked merge does, so it cannot
- // report success on a request the real write refuses.
+ // A dry run can repair the parsed capability state without persisting it.
dryRun := ctl.updateMCPCapability(ctx, v1pb.MCPSetting_READ_ONLY, true)
a.NoError(dryRun, "a dry run that repairs the capability is fine")
@@ -254,17 +218,7 @@ func TestMCPUnreadableCeilingSurvivesAToggleOnlyUpdate(t *testing.T) {
a.NoError(ctl.setIgnoreMaskingExemptions(ctx, true), "and the toggle saves once the ceiling is readable")
}
-// TestMCPUnreadableCeilingIsVisibleToTheAdmin is the read-path half of the same
-// rule, and the defect BOT-100 records. Enforcement inspects the row's own
-// capability key and refuses; the settings API parses with the shared
-// unmarshaler, which drops an enum name it does not know, so the same row read
-// two ways said READ_WRITE — the most permissive ceiling — over a workspace
-// refusing every MCP connection.
-//
-// The second-order effect is the one an admin feels: with the page already
-// showing Read-write, picking Read-write changes nothing, so the row could not
-// be repaired to READ_WRITE in one save at all.
-func TestMCPUnreadableCeilingIsVisibleToTheAdmin(t *testing.T) {
+func TestMCPMissingRowUsesGenericUpdateSemantics(t *testing.T) {
t.Parallel()
a := require.New(t)
ctx := context.Background()
@@ -273,97 +227,37 @@ func TestMCPUnreadableCeilingIsVisibleToTheAdmin(t *testing.T) {
a.NoError(err)
defer ctl.Close(ctx)
- a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_DISABLED))
-
workspaceID := currentWorkspaceID(ctx, t, ctl)
db, err := sql.Open("pgx", ctl.profile.PgURL)
a.NoError(err)
defer db.Close()
_, err = db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{capability}', '"READ_ONLYY"')
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID)
- a.NoError(err)
-
- setting, err := ctl.getMCPSetting(ctx)
- a.NoError(err)
- a.True(setting.GetCapabilityUnreadable(),
- "the admin has to be told, or the page describes a ceiling nobody is enforcing")
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, setting.GetCapability(),
- "and the parsed capability stays unset, so no reader mistakes it for a choice")
-
- // Every token the store treats as unreadable, not just the mistyped name.
- // Each of these unmarshals away to unset without erroring, so a reader that
- // only looked at the parsed capability would report the permissive default
- // over a workspace refusing every connection.
- for _, token := range []string{`null`, `""`, `"CAPABILITY_UNSPECIFIED"`} {
- _, err = db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{capability}', $2::jsonb)
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID, token)
- a.NoError(err, token)
-
- setting, err = ctl.getMCPSetting(ctx)
- a.NoError(err, token)
- a.True(setting.GetCapabilityUnreadable(),
- "%s is a ceiling the store refuses; reporting it as readable is the defect this field ends", token)
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, setting.GetCapability(), token)
- }
-
- // A wrong-TYPED token is a different state, and deliberately not a
- // repairable one. It fails the whole unmarshal rather than just the enum,
- // so there is no ceiling in the row to describe and no supported writer
- // that produces one — the read says so plainly instead of offering a fix
- // it would need a raw-replacement path to deliver.
- for _, token := range []string{`{}`, `true`, `1.5`, `[]`} {
- _, err = db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{capability}', $2::jsonb)
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID, token)
- a.NoError(err, token)
-
- _, err = ctl.getMCPSetting(ctx)
- a.Error(err, "%s carries no ceiling to report, so the read fails rather than inventing one", token)
- }
-
- // Back to the mistyped name for the repair below.
- _, err = db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{capability}', '"READ_ONLYY"')
- WHERE workspace = $1 AND name = 'MCP';
+ DELETE FROM setting WHERE workspace = $1 AND name = 'MCP';
`, workspaceID)
a.NoError(err)
- // The same row through the list surface: a client that discovers the
- // setting there and then patches it must not be told a different story.
- list, err := ctl.settingServiceClient.ListSettings(ctx, connect.NewRequest(&v1pb.ListSettingsRequest{}))
- a.NoError(err)
- var listed *v1pb.MCPSetting
- for _, entry := range list.Msg.Settings {
- if entry.Name == "settings/"+v1pb.Setting_MCP.String() {
- listed = entry.Value.GetMcp()
- }
- }
- a.NotNil(listed)
- a.True(listed.GetCapabilityUnreadable())
+ _, err = ctl.getMCPSetting(ctx)
+ a.Error(err)
+ a.Equal(connect.CodeNotFound, connect.CodeOf(err))
- // One save repairs it, to the most permissive ceiling included — the pick
- // the old shape could not express.
- a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_READ_WRITE))
- repaired, err := ctl.getMCPSetting(ctx)
- a.NoError(err)
- a.Equal(v1pb.MCPSetting_READ_WRITE, repaired.GetCapability())
- a.False(repaired.GetCapabilityUnreadable(), "a readable row carries no unreadable value")
+ _, err = ctl.settingServiceClient.UpdateSetting(ctx, connect.NewRequest(&v1pb.UpdateSettingRequest{
+ Setting: &v1pb.Setting{
+ Name: "settings/" + v1pb.Setting_MCP.String(),
+ Value: &v1pb.SettingValue{Value: &v1pb.SettingValue_Mcp{
+ Mcp: &v1pb.MCPSetting{Capability: v1pb.MCPSetting_READ_ONLY},
+ }},
+ },
+ UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"value.mcp.capability"}},
+ }))
+ a.Error(err)
+ a.Equal(connect.CodeNotFound, connect.CodeOf(err))
- // A workspace that never configured MCP is not the same state and must not
- // be reported as one: it resolves READ_WRITE and nothing is wrong with it.
- _, err = db.ExecContext(ctx, `
- DELETE FROM setting WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID)
- a.NoError(err)
- unconfigured, err := ctl.getMCPSetting(ctx)
+ a.NoError(ctl.setIgnoreMaskingExemptions(ctx, true),
+ "allow_missing must create an MCP row from the READ_WRITE compatibility fallback")
+ setting, err := ctl.getMCPSetting(ctx)
a.NoError(err)
- a.False(unconfigured.GetCapabilityUnreadable())
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, unconfigured.GetCapability())
+ a.Equal(v1pb.MCPSetting_READ_WRITE, setting.GetCapability())
+ a.True(setting.GetIgnoreMaskingExemptions())
}
// TestMCPRepairKeepsTheMaskingToggle pins that fixing the ceiling does not
@@ -391,11 +285,9 @@ func TestMCPRepairKeepsTheMaskingToggle(t *testing.T) {
`, workspaceID)
a.NoError(err)
- // The toggle is readable even though the ceiling is not, so the page must
- // show it rather than reporting the workspace as not ignoring exemptions.
+ // Generic reads still expose the fields this build understands.
setting, err := ctl.getMCPSetting(ctx)
a.NoError(err)
- a.True(setting.GetCapabilityUnreadable(), "the ceiling is the unreadable part")
a.True(setting.GetIgnoreMaskingExemptions(),
"the toggle is readable even though the ceiling is not")
@@ -406,95 +298,11 @@ func TestMCPRepairKeepsTheMaskingToggle(t *testing.T) {
a.Equal(v1pb.MCPSetting_READ_ONLY, repaired.GetCapability())
a.True(repaired.GetIgnoreMaskingExemptions(),
"repairing the ceiling must not return exemptions to MCP sessions")
- a.False(repaired.GetCapabilityUnreadable())
-}
-
-// TestMCPToggleOnlyRowIsNotUnreadable pins the other direction. A first edit
-// that sets only the masking toggle leaves a row with no capability key at all,
-// which is the ordinary never-configured state resolving READ_WRITE — not a row
-// an admin has to repair.
-func TestMCPToggleOnlyRowIsNotUnreadable(t *testing.T) {
- t.Parallel()
- a := require.New(t)
- ctx := context.Background()
- ctl := &controller{}
- ctx, err := ctl.StartServerWithExternalPg(ctx)
- a.NoError(err)
- defer ctl.Close(ctx)
-
- a.NoError(ctl.setIgnoreMaskingExemptions(ctx, true))
-
- setting, err := ctl.getMCPSetting(ctx)
- a.NoError(err)
- a.True(setting.GetIgnoreMaskingExemptions())
- a.False(setting.GetCapabilityUnreadable(),
- "no capability key is never-configured, not unreadable; claiming otherwise "+
- "tells the admin every MCP connection is refused when none is")
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, setting.GetCapability())
-}
-
-// TestMCPUnknownFieldSurvivesAPartialUpdate is the mixed-version half of the
-// same rule. An older replica parses the row with the shared unmarshaler, which
-// discards what it cannot name, and re-marshalling writes the row back without
-// it — so a partial update on the old replica would delete configuration the
-// new one wrote. Reads stay lenient on purpose (one field from a newer release
-// must not disable MCP); the write refuses.
-func TestMCPUnknownFieldSurvivesAPartialUpdate(t *testing.T) {
- t.Parallel()
- a := require.New(t)
- ctx := context.Background()
- ctl := &controller{}
- ctx, err := ctl.StartServerWithExternalPg(ctx)
- a.NoError(err)
- defer ctl.Close(ctx)
-
- a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_READ_ONLY))
-
- workspaceID := currentWorkspaceID(ctx, t, ctl)
- db, err := sql.Open("pgx", ctl.profile.PgURL)
- a.NoError(err)
- defer db.Close()
- result, err := db.ExecContext(ctx, `
- UPDATE setting SET value = jsonb_set(value, '{rulesFromANewerRelease}', '[{"x":1}]')
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID)
- a.NoError(err)
- affected, err := result.RowsAffected()
- a.NoError(err)
- a.Equal(int64(1), affected, "the MCP setting row must exist for this test to mean anything")
-
- // The read is unaffected: an unknown field must not disable MCP.
- capability, err := ctl.getMCPCapability(ctx)
- a.NoError(err)
- a.Equal(v1pb.MCPSetting_READ_ONLY, capability)
-
- err = ctl.setIgnoreMaskingExemptions(ctx, true)
- a.Error(err, "a partial write must not delete a field a newer replica wrote")
- a.Equal(connect.CodeFailedPrecondition, connect.CodeOf(err))
- a.Contains(err.Error(), "rulesFromANewerRelease", "the refusal must name what would be lost")
-
- var present bool
- a.NoError(db.QueryRowContext(ctx, `
- SELECT jsonb_exists(value, 'rulesFromANewerRelease') FROM setting
- WHERE workspace = $1 AND name = 'MCP';
- `, workspaceID).Scan(&present))
- a.True(present, "and the field is still there")
}
-// TestMCPRefusedRepairAuditsTheCeilingThatCausedIt pins the before-image on a
-// refusal, which nothing else covers.
-//
-// updateMCPSetting decides everything against the LOCKED row — the guard reads
-// raw for exactly that reason — so the audit row for a refusal has to describe
-// that row too. It used to record only the pre-lock snapshot taken before
-// UpdateSetting dispatched, because the locked capture happened after the point
-// where a refusal returns.
-//
-// This covers the deterministic half. The stale case needs another replica to
-// write between the pre-lock read and the lock, and there is no injection point
-// for that in this package, so the fix is structural: the capture is now the
-// first statement in the callback and no refusal can return ahead of it.
-func TestMCPRefusedRepairAuditsTheCeilingThatCausedIt(t *testing.T) {
+// TestMCPMissingCapabilityRefusesPartialUpdate pins that a partial update cannot
+// make an invalid row look permissive.
+func TestMCPMissingCapabilityRefusesPartialUpdate(t *testing.T) {
t.Parallel()
a := require.New(t)
ctx := context.Background()
@@ -503,38 +311,16 @@ func TestMCPRefusedRepairAuditsTheCeilingThatCausedIt(t *testing.T) {
a.NoError(err)
defer ctl.Close(ctx)
- workspace, err := ctl.workspaceServiceClient.GetWorkspace(ctx, connect.NewRequest(&v1pb.GetWorkspaceRequest{
- Name: "workspaces/-",
- }))
- a.NoError(err)
workspaceID := currentWorkspaceID(ctx, t, ctl)
-
db, err := sql.Open("pgx", ctl.profile.PgURL)
a.NoError(err)
defer db.Close()
_, err = db.ExecContext(ctx, `
- INSERT INTO setting (name, workspace, value) VALUES ('MCP', $1, '{"capability": "READ_ONLYY"}')
- ON CONFLICT (name, workspace) DO UPDATE SET value = EXCLUDED.value;
+ UPDATE setting SET value = '{}' WHERE workspace = $1 AND name = 'MCP'
`, workspaceID)
a.NoError(err)
- // Refused: the toggle alone would marshal the row back without the ceiling.
err = ctl.setIgnoreMaskingExemptions(ctx, true)
a.Error(err)
- a.Equal(connect.CodeFailedPrecondition, connect.CodeOf(err))
-
- resp, err := ctl.auditLogServiceClient.SearchAuditLogs(ctx, connect.NewRequest(&v1pb.SearchAuditLogsRequest{
- Parent: workspace.Msg.Name,
- Filter: `method == "/bytebase.v1.SettingService/UpdateSetting"`,
- OrderBy: "create_time desc",
- }))
- a.NoError(err)
- a.NotEmpty(resp.Msg.AuditLogs, "a refused MCP write still belongs in the audit log")
-
- before := resp.Msg.AuditLogs[0].ServiceData
- a.NotNil(before, "the refusal has to say which ceiling it was protecting")
- setting := &v1pb.Setting{}
- a.NoError(before.UnmarshalTo(setting))
- a.True(setting.GetValue().GetMcp().GetCapabilityUnreadable(),
- "the before-image must show the unreadable ceiling that caused the refusal")
+ a.Equal(connect.CodeInvalidArgument, connect.CodeOf(err))
}
diff --git a/backend/tests/mcp_gate_test.go b/backend/tests/mcp_gate_test.go
index 71fc996b2a..a029db6055 100644
--- a/backend/tests/mcp_gate_test.go
+++ b/backend/tests/mcp_gate_test.go
@@ -279,16 +279,14 @@ func TestMCPCannotRunAnIssuelessRollout(t *testing.T) {
a.NotEmpty(consoleRollout.Msg.Name)
}
-// TestMCPAbsentRowResolvesReadWrite pins the one permissive default the
-// resolver has: a workspace that never configured MCP serves WRITE.
+// TestMCPDefaultRowIsReadOnly pins the safe default persisted by workspace
+// creation: a workspace whose admin never changed MCP does not serve WRITE.
//
// Every other gate test now sets a ceiling explicitly, which is right — each is
// about what a NAMED ceiling serves, and depending on the default made them say
-// less than their names claimed. That left nothing exercising the unset case on
-// the live path, so changing store.GetMCPSettingsUncached's whenUnset would
-// silently refuse writes for every workspace that has not configured MCP —
-// which today is all of them — with no test to say so.
-func TestMCPAbsentRowResolvesReadWrite(t *testing.T) {
+// less than their names claimed. This keeps the persisted default on the live
+// path, so changing workspace creation would be caught.
+func TestMCPDefaultRowIsReadOnly(t *testing.T) {
t.Parallel()
a := require.New(t)
ctx := context.Background()
@@ -300,17 +298,15 @@ func TestMCPAbsentRowResolvesReadWrite(t *testing.T) {
project, err := ctl.projectServiceClient.CreateProject(ctx, connect.NewRequest(&v1pb.CreateProjectRequest{
ProjectId: "mcp-unset",
- Project: &v1pb.Project{Title: "MCP unset ceiling"},
+ Project: &v1pb.Project{Title: "MCP default ceiling"},
}))
a.NoError(err)
- // No setMCPCapability anywhere in this test: the absence IS the fixture.
+ // No setMCPCapability anywhere in this test: workspace creation owns the
+ // explicit READ_ONLY fixture.
setting, err := ctl.getMCPSetting(ctx)
a.NoError(err)
- a.Equal(v1pb.MCPSetting_CAPABILITY_UNSPECIFIED, setting.GetCapability(),
- "this test is about a workspace that never configured MCP")
- a.False(setting.GetCapabilityUnreadable(),
- "absent, not unreadable — the two resolve to opposite ceilings")
+ a.Equal(v1pb.MCPSetting_READ_ONLY, setting.GetCapability())
session := openMCPSession(ctx, t, ctl, ctl.authInterceptor.token)
defer session.Close()
@@ -319,6 +315,6 @@ func TestMCPAbsentRowResolvesReadWrite(t *testing.T) {
"parent": project.Msg.Name,
"sheet": map[string]any{"content": base64.StdEncoding.EncodeToString([]byte("SELECT 1;"))},
})
- a.Equal(http.StatusOK, sheet.Status,
- "an unconfigured workspace resolves READ_WRITE, so a WRITE method is served: %s", sheet.Error)
+ a.Equal(http.StatusForbidden, sheet.Status,
+ "the default READ_ONLY policy must refuse a WRITE method: %s", sheet.Error)
}
diff --git a/backend/tests/mcp_migration_matrix_test.go b/backend/tests/mcp_migration_matrix_test.go
index c1715adf7c..25b4b88a67 100644
--- a/backend/tests/mcp_migration_matrix_test.go
+++ b/backend/tests/mcp_migration_matrix_test.go
@@ -297,9 +297,7 @@ func TestMCPMigrationCeilingLookupFailureFailsClosed(t *testing.T) {
a.NoError(err)
workspaceID := strings.TrimPrefix(workspace.Msg.Name, "workspaces/")
- // Seeded so the row exists to corrupt: an absent MCP setting is the
- // never-configured state, which resolves READ_WRITE without a row to write
- // a wrong-typed value into.
+ // Set the control value explicitly before corrupting it.
a.NoError(ctl.setMCPCapability(ctx, v1pb.MCPSetting_READ_WRITE))
mcpToken, _ := mintMCPOAuthToken(t, ctl, ctl.authInterceptor.token)
@@ -310,17 +308,18 @@ func TestMCPMigrationCeilingLookupFailureFailsClosed(t *testing.T) {
db, err := sql.Open("pgx", ctl.profile.PgURL)
a.NoError(err)
- defer db.Close()
+ t.Cleanup(func() { db.Close() })
// The stored ceiling is given a value the MCP setting cannot be parsed with,
// so the read errors outright. That is a distinct arm from an unrecognized
// enum NAME, which the store's unmarshaler discards: a name it does not
- // know is caught by the raw-key check in GetMCPSettingsUncached and also
- // fails closed, and TestMCPCeilingStoredValueFailsClosed
+ // know is parsed as UNSPECIFIED and fails closed, and
+ // TestMCPCeilingStoredValueFailsClosed
// (backend/api/mcp) owns that case. This one is the unmarshal error itself.
restore := func() {
result, err := db.ExecContext(ctx, `
- DELETE FROM setting WHERE workspace = $1 AND name = 'MCP';
+ UPDATE setting SET value = '{"capability":"READ_WRITE"}'::jsonb
+ WHERE workspace = $1 AND name = 'MCP';
`, workspaceID)
a.NoError(err)
affected, err := result.RowsAffected()
@@ -333,7 +332,7 @@ func TestMCPMigrationCeilingLookupFailureFailsClosed(t *testing.T) {
`, workspaceID)
a.NoError(err)
// Registered before the assertions below so a failing one cannot leave the
- // server running on an unreadable MCP setting through teardown, burying the
+ // server running on an invalid MCP setting through teardown, burying the
// real failure under unrelated errors.
restored := false
t.Cleanup(func() {
@@ -346,12 +345,9 @@ func TestMCPMigrationCeilingLookupFailureFailsClosed(t *testing.T) {
a.Equal(int64(1), affected, "the workspace profile row must exist for this test to mean anything")
status, body = postMCP(t, ctl, mcpToken)
- a.Equal(http.StatusForbidden, status,
+ a.Equal(http.StatusServiceUnavailable, status,
"a ceiling that cannot be read must fail closed, not fall back to permitting MCP; %s", body)
- // Not the disabled wording. An admin turning MCP off and an admin leaving a
- // value nobody can parse are different problems with different fixes, and
- // the refusal is the only place the difference reaches anyone.
- a.Contains(body, "not one this build understands")
+ a.Contains(body, "could not be read")
a.NotContains(body, "turned MCP access off")
// Restoring the row proves the refusal was the unreadable policy and
diff --git a/frontend/src/components/mcp/MCPModeContentsSheet.tsx b/frontend/src/components/mcp/MCPModeContentsSheet.tsx
index c3ebd48ed2..8b8b267267 100644
--- a/frontend/src/components/mcp/MCPModeContentsSheet.tsx
+++ b/frontend/src/components/mcp/MCPModeContentsSheet.tsx
@@ -38,7 +38,7 @@ interface Props {
* 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
* nothing — "0 of 0" over a workspace whose ceiling this drawer exists to
- * explain. GetMCPInfo refuses outright under an unreadable or unserved
+ * explain. GetMCPInfo refuses outright under an invalid or unserved
* ceiling (BOT-106), which is exactly when an admin opens this.
*/
readonly info: MCPInfo;
diff --git a/frontend/src/components/mcp/mcpPolicy.test.ts b/frontend/src/components/mcp/mcpPolicy.test.ts
index 2f70eb74eb..662733a7c6 100644
--- a/frontend/src/components/mcp/mcpPolicy.test.ts
+++ b/frontend/src/components/mcp/mcpPolicy.test.ts
@@ -2,10 +2,7 @@ import { create } from "@bufbuild/protobuf";
import { describe, expect, test } from "vitest";
import { MCPMethodClass } from "@/types/proto-es/v1/annotation_pb";
import { Engine } from "@/types/proto-es/v1/common_pb";
-import {
- MCPSetting_Capability,
- MCPSettingSchema,
-} from "@/types/proto-es/v1/setting_service_pb";
+import { MCPSetting_Capability } from "@/types/proto-es/v1/setting_service_pb";
import {
MCPCapabilityModeSchema,
MCPEngineEnforcement_Masking,
@@ -14,104 +11,22 @@ import {
MCPMethodSchema,
} from "@/types/proto-es/v1/workspace_service_pb";
import {
- ceilingIsBroken,
groupEnginesByMasking,
groupEnginesByReadOnlyDepth,
groupMethodsByService,
- initialCapabilityPick,
+ isMCPMode,
methodsServedBy,
- readStoredCeiling,
serviceOfMethod,
} from "./mcpPolicy";
-const setting = (
- fields: Partial<{ capability: number; unreadable: boolean }>
-) =>
- create(MCPSettingSchema, {
- capability:
- fields.capability ?? MCPSetting_Capability.CAPABILITY_UNSPECIFIED,
- capabilityUnreadable: fields.unreadable ?? false,
- });
-
-describe("readStoredCeiling", () => {
- test("a stored mode is the mode", () => {
- expect(readStoredCeiling(setting({ capability: 3 }))).toEqual({
- kind: "mode",
- capability: MCPSetting_Capability.READ_ONLY,
- });
- });
-
- test("no row is unconfigured, not a choice", () => {
- expect(readStoredCeiling(setting({}))).toEqual({ kind: "unconfigured" });
- });
-
- test("an unreadable row is its own state, never read-write", () => {
- // The defect BOT-100 records: the two arrive as the same capability and
- // mean opposite things — one resolves READ_WRITE, the other is refused.
- const stored = readStoredCeiling(setting({ unreadable: true }));
- expect(stored).toEqual({ kind: "unreadable" });
- expect(readStoredCeiling(setting({}))).toEqual({ kind: "unconfigured" });
- });
-
- test("the flag outranks a capability that parsed away to unset", () => {
- // The row reads back CAPABILITY_UNSPECIFIED either way. Only the flag
- // separates a ceiling nobody can resolve from a workspace that never
- // configured one, and they resolve to opposite ceilings — refused, versus
- // the READ_WRITE default (BOT-100).
- expect(readStoredCeiling(setting({ unreadable: true }))).toEqual({
- kind: "unreadable",
- });
- expect(readStoredCeiling(setting({}))).toEqual({ kind: "unconfigured" });
- });
-
- test("a number no mode serves is unserved", () => {
- // The reserved 2 (was METADATA_ONLY), or a ceiling a newer release wrote.
- expect(readStoredCeiling(setting({ capability: 2 }))).toEqual({
- kind: "unserved",
- stored: "2",
- });
- });
-});
-
-describe("initialCapabilityPick", () => {
- test("a stored mode preselects itself", () => {
- expect(
- initialCapabilityPick({
- kind: "mode",
- capability: MCPSetting_Capability.DISABLED,
- })
- ).toBe(MCPSetting_Capability.DISABLED);
- });
-
- test("an unconfigured row preselects the ceiling it resolves to", () => {
- expect(initialCapabilityPick({ kind: "unconfigured" })).toBe(
- MCPSetting_Capability.READ_WRITE
- );
- });
-
- test("a broken row preselects nothing, so every pick is savable", () => {
- // Preselecting read-write here is what left an admin unable to repair the
- // row to read-write at all: the pick matched the preselection, so the form
- // was never dirty and the footer never enabled.
- for (const stored of [
- { kind: "unreadable" as const },
- { kind: "unserved" as const, stored: "2" },
- ]) {
- expect(ceilingIsBroken(stored)).toBe(true);
- expect(initialCapabilityPick(stored)).toBeUndefined();
- }
- });
-
- test("a readable row is not broken", () => {
- // Without this the whole suite passes on `ceilingIsBroken = () => true`,
- // which would put every workspace into the repair banner.
- expect(ceilingIsBroken({ kind: "unconfigured" })).toBe(false);
- expect(
- ceilingIsBroken({
- kind: "mode",
- capability: MCPSetting_Capability.READ_ONLY,
- })
- ).toBe(false);
+describe("isMCPMode", () => {
+ test("accepts only selectable capabilities", () => {
+ expect(isMCPMode(MCPSetting_Capability.DISABLED)).toBe(true);
+ expect(isMCPMode(MCPSetting_Capability.READ_ONLY)).toBe(true);
+ expect(isMCPMode(MCPSetting_Capability.READ_WRITE)).toBe(true);
+ expect(isMCPMode(MCPSetting_Capability.CAPABILITY_UNSPECIFIED)).toBe(false);
+ expect(isMCPMode(2 as MCPSetting_Capability)).toBe(false);
+ expect(isMCPMode(99 as MCPSetting_Capability)).toBe(false);
});
});
diff --git a/frontend/src/components/mcp/mcpPolicy.ts b/frontend/src/components/mcp/mcpPolicy.ts
index 34de95eaa8..3e1f923d09 100644
--- a/frontend/src/components/mcp/mcpPolicy.ts
+++ b/frontend/src/components/mcp/mcpPolicy.ts
@@ -1,5 +1,4 @@
import type { Engine } from "@/types/proto-es/v1/common_pb";
-import type { MCPSetting } from "@/types/proto-es/v1/setting_service_pb";
import { MCPSetting_Capability } from "@/types/proto-es/v1/setting_service_pb";
import type {
MCPCapabilityMode,
@@ -12,81 +11,22 @@ import {
MCPEngineEnforcement_ReadOnlyDepth,
} from "@/types/proto-es/v1/workspace_service_pb";
+export type MCPMode =
+ | MCPSetting_Capability.DISABLED
+ | MCPSetting_Capability.READ_ONLY
+ | MCPSetting_Capability.READ_WRITE;
+
/** The ceilings an admin picks between, least to most capable. */
-export const MCP_CAPABILITY_CHOICES: readonly MCPSetting_Capability[] = [
+export const MCP_CAPABILITY_CHOICES: readonly MCPMode[] = [
MCPSetting_Capability.DISABLED,
MCPSetting_Capability.READ_ONLY,
MCPSetting_Capability.READ_WRITE,
];
-/**
- * What the stored row says, which is not always a mode.
- *
- * `unconfigured` and `unreadable` both arrive as CAPABILITY_UNSPECIFIED and
- * mean opposite things: the first resolves READ_WRITE server-side, the second
- * is refused every connection. Collapsing them is the defect BOT-100 records.
- */
-export type StoredCeiling =
- | { kind: "mode"; capability: MCPSetting_Capability }
- | { kind: "unconfigured" }
- | { kind: "unreadable" }
- | { kind: "unserved"; stored: string };
-
-const isChoice = (capability: MCPSetting_Capability): boolean =>
- MCP_CAPABILITY_CHOICES.includes(capability);
-
-/** Reads the stored row into the state the page renders. */
-export const readStoredCeiling = (setting: MCPSetting): StoredCeiling => {
- // The server does not return the stored token, only that it could not
- // resolve one. Unserved is different: that value parsed, so the number is
- // already here and costs nothing to show.
- if (setting.capabilityUnreadable) {
- return { kind: "unreadable" };
- }
- if (isChoice(setting.capability)) {
- return { kind: "mode", capability: setting.capability };
- }
- if (setting.capability === MCPSetting_Capability.CAPABILITY_UNSPECIFIED) {
- return { kind: "unconfigured" };
- }
- // A number that parsed but no mode serves: the reserved 2, or a ceiling a
- // newer release wrote. Enforcement refuses it, so it is not a choice either.
- return { kind: "unserved", stored: String(setting.capability) };
-};
-
-/** A stored row the server refuses, which carries the value nobody could read. */
-export type BrokenCeiling = Extract<
- StoredCeiling,
- { kind: "unreadable" } | { kind: "unserved" }
->;
-
-/** Whether the stored row is one the server can act on. */
-export const ceilingIsBroken = (
- stored: StoredCeiling
-): stored is BrokenCeiling =>
- stored.kind === "unreadable" || stored.kind === "unserved";
-
-/**
- * The card the form starts on, or undefined when the row is broken.
- *
- * A broken row starts on no card so that every pick is a change the footer can
- * save — including the most permissive one. Preselecting the ceiling such a row
- * resolves to is what left an admin unable to repair it in one save (BOT-100).
- */
-export const initialCapabilityPick = (
- stored: StoredCeiling
-): MCPSetting_Capability | undefined => {
- switch (stored.kind) {
- case "mode":
- return stored.capability;
- case "unconfigured":
- // No row resolves READ_WRITE server-side, so this is the ceiling in
- // force, not a guess.
- return MCPSetting_Capability.READ_WRITE;
- default:
- return undefined;
- }
-};
+export const isMCPMode = (
+ capability: MCPSetting_Capability
+): capability is MCPMode =>
+ MCP_CAPABILITY_CHOICES.some((choice) => choice === capability);
/**
* The methods a mode serves, by the same rule the gate evaluates: a method is
diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
index 77f4b47588..5ee9dc210c 100644
--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.test.tsx
@@ -20,7 +20,6 @@ const mocks = vi.hoisted(() => ({
| {
capability: number;
ignoreMaskingExemptions: boolean;
- capabilityUnreadable?: boolean;
}
| undefined,
},
@@ -126,7 +125,6 @@ beforeEach(async () => {
mocks.mcpSetting.value = {
capability: 3, // READ_ONLY
ignoreMaskingExemptions: false,
- capabilityUnreadable: false,
};
mocks.upsertSetting.mockResolvedValue(undefined);
mocks.hasFeature.mockReturnValue(true);
@@ -191,6 +189,46 @@ describe("MCPAccessPolicySection", () => {
unmount();
});
+ test("repairs an unspecified capability without a frontend fallback", async () => {
+ mocks.mcpSetting.value = {
+ capability: 0,
+ ignoreMaskingExemptions: false,
+ };
+ const { container, render, unmount } = renderIntoContainer(
+ <MCPAccessPolicySection />
+ );
+ render();
+ await flush();
+
+ expect(container.textContent).toContain(
+ "settings.mcp.policy.unreadable.title"
+ );
+ expect(container.textContent).not.toContain("settings.mcp.policy.in-force");
+
+ clickText(container, "settings.mcp.policy.edit");
+ await flush();
+ expect(container.textContent).toContain(
+ "settings.mcp.policy.unreadable.pick"
+ );
+
+ clickText(container, "settings.mcp.policy.mode.read-write.title");
+ await flush();
+ clickText(container, "settings.mcp.policy.save");
+ await flush();
+
+ expect(mocks.upsertSetting).toHaveBeenCalledWith(
+ expect.objectContaining({
+ updateMask: expect.objectContaining({
+ paths: ["value.mcp.capability"],
+ }),
+ })
+ );
+ const request = mocks.upsertSetting.mock.calls.at(-1)?.[0];
+ expect(request.value.value.value.capability).toBe(4);
+
+ unmount();
+ });
+
// Codex, #21236: the drawer opens from a mode card the admin is choosing, so
// it previews the candidate policy. Reading the persisted value described the
// masking behavior they were about to replace.
diff --git a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
index 78b3776bfa..e1e10af384 100644
--- a/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
+++ b/frontend/src/routes/workspace/mcp/MCPAccessPolicySection.tsx
@@ -10,13 +10,8 @@ import {
} from "@/api";
import { silentContextKey } from "@/api/context-key";
import { MCPModeContentsSheet } from "@/components/mcp/MCPModeContentsSheet";
-import type { StoredCeiling } from "@/components/mcp/mcpPolicy";
-import {
- ceilingIsBroken,
- initialCapabilityPick,
- MCP_CAPABILITY_CHOICES,
- readStoredCeiling,
-} from "@/components/mcp/mcpPolicy";
+import type { MCPMode } from "@/components/mcp/mcpPolicy";
+import { isMCPMode, MCP_CAPABILITY_CHOICES } from "@/components/mcp/mcpPolicy";
import { PermissionGuard } from "@/components/PermissionGuard";
import { Alert } from "@/components/ui/alert";
import type { BadgeProps } from "@/components/ui/badge";
@@ -44,14 +39,9 @@ import type { MCPInfo } from "@/types/proto-es/v1/workspace_service_pb";
// the card to the in-force chip, so they belong on one row rather than in
// parallel tables that can drift apart.
const MODES: Record<
- MCPSetting_Capability,
+ MCPMode,
{ key: string; tone: string; badge: BadgeProps["variant"] }
> = {
- [MCPSetting_Capability.CAPABILITY_UNSPECIFIED]: {
- key: "read-write",
- tone: "text-warning",
- badge: "warning",
- },
[MCPSetting_Capability.DISABLED]: {
key: "disabled",
tone: "text-error",
@@ -74,7 +64,7 @@ export function MCPAccessPolicySection() {
const settingsByName = useAppStore((s) => s.settingsByName);
// Read from the licence, not from GetMCPInfo. That request refuses outright
- // under an unreadable or unserved ceiling (BOT-106), which is exactly when an
+ // 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.
const dataMaskingAvailable = useAppStore((s) =>
@@ -93,13 +83,11 @@ export function MCPAccessPolicySection() {
const [info, setInfo] = useState<MCPInfo | undefined>(undefined);
const [editing, setEditing] = useState(false);
const [saving, setSaving] = useState(false);
- const [pick, setPick] = useState<MCPSetting_Capability | undefined>(
+ const [pick, setPick] = useState<MCPMode | undefined>(undefined);
+ const [ignoreMasking, setIgnoreMasking] = useState(false);
+ const [contentsFor, setContentsFor] = useState<MCPMode | undefined>(
undefined
);
- const [ignoreMasking, setIgnoreMasking] = useState(false);
- const [contentsFor, setContentsFor] = useState<
- MCPSetting_Capability | undefined
- >(undefined);
// GetMCPInfo resolves what a mode contains from the live descriptors, so it
// is re-read after a save rather than patched: the ceiling in force is part
@@ -140,7 +128,7 @@ export function MCPAccessPolicySection() {
// for a reason — a hand edit or a newer replica changes it out of band — and
// getOrFetchSettingByName returns a cached snapshot without revalidating, so
// a second visit in one session would compute the form's dirty state against
- // a value that is no longer stored. On an unreadable row that makes the
+ // a value that is no longer stored. On an invalid row that makes the
// one-save repair unreachable without a reload.
const [readFailed, setReadFailed] = useState(false);
// Whether this mount's own read has answered. Until it has, a value left in
@@ -190,24 +178,26 @@ export function MCPAccessPolicySection() {
};
}, [loadInfo]);
- const stored: StoredCeiling | undefined = useMemo(
- () => (mcpSetting ? readStoredCeiling(mcpSetting) : undefined),
- [mcpSetting]
- );
- const storedPick = stored ? initialCapabilityPick(stored) : undefined;
+ const storedCapability = mcpSetting?.capability;
+ const storedMode =
+ storedCapability !== undefined && isMCPMode(storedCapability)
+ ? storedCapability
+ : undefined;
+ const unreadable =
+ storedCapability === MCPSetting_Capability.CAPABILITY_UNSPECIFIED;
const storedIgnoreMasking = mcpSetting?.ignoreMaskingExemptions ?? false;
// The form is seeded when editing opens, not on every store change: the
// stored value only moves under an open form when someone else saved, and
// replacing an admin's unsaved pick is worse than showing it stale.
const startEditing = () => {
- setPick(storedPick);
+ setPick(storedMode);
setIgnoreMasking(storedIgnoreMasking);
setEditing(true);
};
const isDirty =
- editing && (pick !== storedPick || ignoreMasking !== storedIgnoreMasking);
+ editing && (pick !== storedMode || ignoreMasking !== storedIgnoreMasking);
// The section this replaced was registered in GeneralPage's guarded refs, so
// moving it to its own route would otherwise drop the confirm an admin gets
// when navigating away from an unsaved ceiling.
@@ -216,7 +206,7 @@ export function MCPAccessPolicySection() {
// else would erase it, and the server refuses that write.
const canSave = isDirty && pick !== undefined;
- const modeLabel = (capability: MCPSetting_Capability): string =>
+ const modeLabel = (capability: MCPMode): string =>
t(`settings.mcp.policy.mode.${MODES[capability].key}.title`);
const save = async () => {
@@ -224,7 +214,7 @@ export function MCPAccessPolicySection() {
return;
}
const paths: string[] = [];
- if (pick !== storedPick) {
+ if (pick !== storedMode) {
paths.push("value.mcp.capability");
}
if (ignoreMasking !== storedIgnoreMasking) {
@@ -257,13 +247,10 @@ export function MCPAccessPolicySection() {
}
};
- const inForceCapability = (state: StoredCeiling): MCPSetting_Capability =>
- state.kind === "mode" ? state.capability : MCPSetting_Capability.READ_WRITE;
-
// The mode the drawer is showing, frozen while it closes. The Sheet unmounts
// after its close animation, so reading contentsFor directly would swap the
// contents for another mode's for those ~200ms.
- const openContentsRef = useRef(MCPSetting_Capability.READ_ONLY);
+ const openContentsRef = useRef<MCPMode>(MCPSetting_Capability.READ_ONLY);
if (contentsFor !== undefined) {
openContentsRef.current = contentsFor;
}
@@ -282,7 +269,7 @@ export function MCPAccessPolicySection() {
/>
);
}
- if (!readSettled || !stored) {
+ if (!readSettled || storedCapability === undefined) {
return (
<p className="textinfolabel">{t("settings.mcp.policy.loading")}</p>
);
@@ -290,10 +277,10 @@ export function MCPAccessPolicySection() {
return (
<div className="rounded-sm border border-control-border p-4 flex flex-col gap-y-4">
<div className="flex items-start justify-between gap-x-2">
- {ceilingIsBroken(stored) ? (
+ {storedMode === undefined ? (
<span className="text-sm font-medium text-warning">
{t(
- stored.kind === "unreadable"
+ unreadable
? "settings.mcp.policy.unreadable.title"
: "settings.mcp.policy.unserved.title"
)}
@@ -301,16 +288,13 @@ export function MCPAccessPolicySection() {
) : (
<div className="flex flex-wrap items-center gap-2">
<Rows3
- className={cn(
- "size-4 shrink-0",
- MODES[inForceCapability(stored)].tone
- )}
+ className={cn("size-4 shrink-0", MODES[storedMode].tone)}
/>
<span className="text-sm text-control-light">
{t("settings.mcp.policy.in-force")}
</span>
- <Badge variant={MODES[inForceCapability(stored)].badge}>
- {modeLabel(inForceCapability(stored))}
+ <Badge variant={MODES[storedMode].badge}>
+ {modeLabel(storedMode)}
</Badge>
{storedIgnoreMasking && (
<Badge variant="secondary">
@@ -335,14 +319,14 @@ export function MCPAccessPolicySection() {
)}
</div>
- {ceilingIsBroken(stored) && (
+ {storedMode === undefined && (
<Alert
variant="warning"
description={
- stored.kind === "unreadable"
+ unreadable
? t("settings.mcp.policy.unreadable.description")
: t("settings.mcp.policy.unserved.description", {
- stored: stored.stored,
+ stored: String(storedCapability),
})
}
/>
@@ -358,7 +342,12 @@ export function MCPAccessPolicySection() {
className="grid grid-cols-1 gap-4 md:grid-cols-3"
disabled={saving}
value={pick === undefined ? "" : String(pick)}
- onValueChange={(value) => setPick(Number(value))}
+ onValueChange={(value) => {
+ const capability = Number(value) as MCPSetting_Capability;
+ if (isMCPMode(capability)) {
+ setPick(capability);
+ }
+ }}
>
{MCP_CAPABILITY_CHOICES.map((capability) => {
const mode = MODES[capability];
@@ -469,11 +458,11 @@ export function MCPAccessPolicySection() {
</>
) : (
<>
- {!ceilingIsBroken(stored) && (
+ {storedMode !== undefined && (
<p className="textinfolabel">
{t(
`settings.mcp.policy.mode.${
- MODES[inForceCapability(stored)].key
+ MODES[storedMode].key
}.description`
)}
</p>
diff --git a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts b/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
index 29c116feab..dd756893e6 100644
--- a/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
+++ b/frontend/src/types/proto-es/v1/setting_service_pb.d.ts
@@ -779,36 +779,6 @@ export declare type MCPSetting = Message<"bytebase.v1.MCPSetting"> & {
* @generated from field: bool ignore_masking_exemptions = 2;
*/
ignoreMaskingExemptions: boolean;
-
- /**
- * True when the row carries a capability key that this build cannot resolve
- * to a ceiling. An enum name a newer release wrote is the legitimate trigger,
- * during a rolling upgrade; a hand-edited token reaches the same state.
- * False for every readable row, including one that was never configured.
- *
- * The capability field cannot carry this on its own: the unmarshaler discards
- * an enum name it does not know, so an unreadable row and a never-configured
- * one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
- * first and served at READ_WRITE for the second. A client reading only the
- * capability shows the most permissive ceiling over a workspace where every
- * MCP connection is being refused.
- *
- * A row protojson cannot parse at all is NOT this state. There is no ceiling
- * in it to describe, so the read fails instead, and repairing it needs an
- * operator rather than this field.
- *
- * The stored token itself is deliberately not returned. Telling a typo apart
- * from a value a newer release wrote would only pay off if this enum grew,
- * and it has not: its one reserved slot held a tier removed before any
- * release shipped it.
- *
- * Set the row right by writing value.mcp.capability. Any other path is
- * refused while this is true, because the merge that saved it would erase the
- * value nobody could read.
- *
- * @generated from field: bool capability_unreadable = 3;
- */
- capabilityUnreadable: boolean;
};
/**
@@ -818,10 +788,9 @@ export declare type MCPSetting = Message<"bytebase.v1.MCPSetting"> & {
export declare const MCPSettingSchema: GenMessage<MCPSetting>;
/**
- * Capability is the ceiling: a session runs at this level or lower. An absent
- * MCP setting resolves to READ_WRITE, so a workspace that never configured
- * MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
- * omit the update mask path to leave the ceiling unset.
+ * Capability is the ceiling: a session runs at this level or lower.
+ * Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+ * path to leave the current ceiling unchanged.
*
* @generated from enum bytebase.v1.MCPSetting.Capability
*/
diff --git a/frontend/src/types/proto-es/v1/setting_service_pb.js b/frontend/src/types/proto-es/v1/setting_service_pb.js
index 63eb248fe6..99e6133967 100644
--- a/frontend/src/types/proto-es/v1/setting_service_pb.js
+++ b/frontend/src/types/proto-es/v1/setting_service_pb.js
@@ -18,7 +18,7 @@ import { file_v1_issue_service } from "./issue_service_pb";
* Describes the file v1/setting_service.proto.
*/
export const file_v1_setting_service = /*@__PURE__*/
- fileDesc("Chh2MS9zZXR0aW5nX3NlcnZpY2UucHJvdG8SC2J5dGViYXNlLnYxIhUKE0xpc3RTZXR0aW5nc1JlcXVlc3QiPgoUTGlzdFNldHRpbmdzUmVzcG9uc2USJgoIc2V0dGluZ3MYASADKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIj8KEUdldFNldHRpbmdSZXF1ZXN0EioKBG5hbWUYASABKAlCHOBBAvpBFgoUYnl0ZWJhc2UuY29tL1NldHRpbmciOwoSR2V0U2V0dGluZ1Jlc3BvbnNlEiUKB3NldHRpbmcYASABKAsyFC5ieXRlYmFzZS52MS5TZXR0aW5nIqEBChRVcGRhdGVTZXR0a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5MaXN0U2V0dGluZ3NSZXNwb25zZSI32kEAiuowEGJiLnNldHRpbmdzLmxpc3SQ6jABoOowBKjqMAmC0+STAg4SDC92MS9zZXR0aW5ncxKHAQoKR2V0U2V0dGluZxIeLmJ5dGViYXNlLnYxLkdldFNldHRpbmdSZXF1ZXN0GhQuYnl0ZWJhc2UudjEuU2V0dGluZyJD2kEEbmFtZYrqMA9iYi5zZXR0aW5ncy5nZXSQ6jACoOowBKjqMAmC0+STAhcSFS92MS97bmFtZT1zZXR0aW5ncy8qfRKbAQoNVXBkYXRlU2V0dGluZxIhLmJ5dGViYXNlLnYxLlVwZGF0ZVNldHRpbmdSZXF1ZXN0GhQuYnl0ZWJhc2UudjEuU2V0dGluZyJRiuowD2JiLnNldHRpbmdzLnNldJDqMAKY6jABoOowA6jqMAeC0+STAig6B3NldHRpbmcyHS92MS97c2V0dGluZy5uYW1lPXNldHRpbmdzLyp9ErgBChBUZXN0RW1haWxTZXR0aW5nEiQuYnl0ZWJhc2UudjEuVGVzdEVtYWlsU2V0dGluZ1JlcXVlc3QaJS5ieXRlYmFzZS52MS5UZXN0RW1haWxTZXR0aW5nUmVzcG9uc2UiV4rqMA9iYi5zZXR0aW5ncy5zZXSQ6jABoOowA6jqMAaC0+STAjI6ASoiLS92MS97cGFyZW50PXdvcmtzcGFjZXMvKn0vc2V0dGluZ3MvRU1BSUw6dGVzdEKpAQoPY29tLmJ5dGViYXNlLnYxQhNTZXR0aW5nU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_type_color,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Kn0vc2V0dGluZ3MvRU1BSUw6dGVzdEKpAQoPY29tLmJ5dGViYXNlLnYxQhNTZXR0aW5nU2VydmljZVByb3RvUAFaNGdpdGh1Yi5jb20vYnl0ZWJhc2UvYnl0ZWJhc2UvYmFja2VuZC9nZW5lcmF0ZWQtZ28vdjGiAgNCWFiqAgtCeXRlYmFzZS5WMcoCC0J5dGViYXNlXFYx4gIXQnl0ZWJhc2VcVjFcR1BCTWV0YWRhdGHqAgxCeXRlYmFzZTo6VjFiBnByb3RvMw", [file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_duration, file_google_protobuf_field_mask, file_google_type_color, file_google_type_expr, file_v1_annotation, file_v1_common, file_v1_issue_service]);
/**
* Describes the message bytebase.v1.ListSettingsRequest.
@@ -165,10 +165,9 @@ export const MCPSetting_CapabilitySchema = /*@__PURE__*/
enumDesc(file_v1_setting_service, 9, 0);
/**
- * Capability is the ceiling: a session runs at this level or lower. An absent
- * MCP setting resolves to READ_WRITE, so a workspace that never configured
- * MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
- * omit the update mask path to leave the ceiling unset.
+ * Capability is the ceiling: a session runs at this level or lower.
+ * Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+ * path to leave the current ceiling unchanged.
*
* @generated from enum bytebase.v1.MCPSetting.Capability
*/
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 c13474df28..9e957634bc 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,8 +50,7 @@ export declare type MCPInfo = Message<"bytebase.v1.MCPInfo"> & {
workspace: string;
/**
- * The ceiling in force for this workspace. A workspace that never configured
- * MCP resolves to READ_WRITE.
+ * The ceiling in force for this workspace.
*
* @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 98ddc926ac..45520515b1 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -26755,9 +26755,7 @@ components:
readOnly: true
capability:
title: capability
- description: |-
- The ceiling in force for this workspace. A workspace that never configured
- MCP resolves to READ_WRITE.
+ description: The ceiling in force for this workspace.
readOnly: true
$ref: '#/components/schemas/bytebase.v1.MCPSetting.Capability'
modes:
@@ -26907,35 +26905,6 @@ components:
masking policy, and it does nothing on the engines Bytebase does not mask.
It narrows what an agent reads through the paths Bytebase masks; it is not
a confidentiality boundary.
- capabilityUnreadable:
- type: boolean
- title: capability_unreadable
- description: |-
- True when the row carries a capability key that this build cannot resolve
- to a ceiling. An enum name a newer release wrote is the legitimate trigger,
- during a rolling upgrade; a hand-edited token reaches the same state.
- False for every readable row, including one that was never configured.
-
- The capability field cannot carry this on its own: the unmarshaler discards
- an enum name it does not know, so an unreadable row and a never-configured
- one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
- first and served at READ_WRITE for the second. A client reading only the
- capability shows the most permissive ceiling over a workspace where every
- MCP connection is being refused.
-
- A row protojson cannot parse at all is NOT this state. There is no ceiling
- in it to describe, so the read fails instead, and repairing it needs an
- operator rather than this field.
-
- The stored token itself is deliberately not returned. Telling a typo apart
- from a value a newer release wrote would only pay off if this enum grew,
- and it has not: its one reserved slot held a tier removed before any
- release shipped it.
-
- Set the row right by writing value.mcp.capability. Any other path is
- refused while this is true, because the merge that saved it would erase the
- value nobody could read.
- readOnly: true
title: MCPSetting
additionalProperties: false
description: |-
@@ -26950,10 +26919,9 @@ components:
- READ_ONLY
- READ_WRITE
description: |-
- Capability is the ceiling: a session runs at this level or lower. An absent
- MCP setting resolves to READ_WRITE, so a workspace that never configured
- MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
- omit the update mask path to leave the ceiling unset.
+ Capability is the ceiling: a session runs at this level or lower.
+ Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+ path to leave the current ceiling unchanged.
bytebase.v1.MaskingExemptionPolicy:
type: object
properties:
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index b670e7d53b..369284e4e7 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -5065,9 +5065,7 @@ It cannot force masking where there is none. Masking substitutes values in query
<a name="bytebase-store-MCPSetting-Capability"></a>
### MCPSetting.Capability
-Capability is the ceiling: a session runs at this level or lower. An absent
-MCP setting resolves to READ_WRITE, so a workspace that never configured
-MCP is unaffected.
+Capability is the ceiling: a session runs at this level or lower.
| Name | Number | Description |
| ---- | ------ | ----------- |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 1ab29b623d..7577b11da4 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -13830,7 +13830,7 @@ frontend-only concept that seeds these colors; the store only holds them. </p></
</table>
<h3 id="bytebase.store.MCPSetting.Capability">MCPSetting.Capability</h3>
- <p>Capability is the ceiling: a session runs at this level or lower. An absent</p><p>MCP setting resolves to READ_WRITE, so a workspace that never configured</p><p>MCP is unaffected.</p>
+ <p>Capability is the ceiling: a session runs at this level or lower.</p>
<table class="enum-table">
<thead>
<tr><td>Name</td><td>Number</td><td>Description</td></tr>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 6f8122f4c9..b2158ef053 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -4973,15 +4973,6 @@ workspace.
| ignore_masking_exemptions | [bool](#bool) | | Whether a request that arrived over MCP stops applying the caller&#39;s own unmasking provisioning. Two mechanisms let a user see a real value and this suppresses both: the masking exemptions granted to them, and the unmask carried by an access grant. The same user in the console is untouched.
It cannot force masking where there is none. Masking substitutes values in query results, so this does not reach data copied into a column carrying no masking policy, and it does nothing on the engines Bytebase does not mask. It narrows what an agent reads through the paths Bytebase masks; it is not a confidentiality boundary. |
-| capability_unreadable | [bool](#bool) | | True when the row carries a capability key that this build cannot resolve to a ceiling. An enum name a newer release wrote is the legitimate trigger, during a rolling upgrade; a hand-edited token reaches the same state. False for every readable row, including one that was never configured.
-
-The capability field cannot carry this on its own: the unmarshaler discards an enum name it does not know, so an unreadable row and a never-configured one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the first and served at READ_WRITE for the second. A client reading only the capability shows the most permissive ceiling over a workspace where every MCP connection is being refused.
-
-A row protojson cannot parse at all is NOT this state. There is no ceiling in it to describe, so the read fails instead, and repairing it needs an operator rather than this field.
-
-The stored token itself is deliberately not returned. Telling a typo apart from a value a newer release wrote would only pay off if this enum grew, and it has not: its one reserved slot held a tier removed before any release shipped it.
-
-Set the row right by writing value.mcp.capability. Any other path is refused while this is true, because the merge that saved it would erase the value nobody could read. |
@@ -5332,10 +5323,9 @@ For examples: resource.environment_id == &#34;prod&#34; &amp;&amp; statement.aff
<a name="bytebase-v1-MCPSetting-Capability"></a>
### MCPSetting.Capability
-Capability is the ceiling: a session runs at this level or lower. An absent
-MCP setting resolves to READ_WRITE, so a workspace that never configured
-MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
-omit the update mask path to leave the ceiling unset.
+Capability is the ceiling: a session runs at this level or lower.
+Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+path to leave the current ceiling unchanged.
| Name | Number | Description |
| ---- | ------ | ----------- |
@@ -12867,7 +12857,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. A workspace that never configured MCP resolves to READ_WRITE. |
+| capability | [MCPSetting.Capability](#bytebase-v1-MCPSetting-Capability) | | The ceiling in force for this workspace. |
| 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 c63bf8ee6b..0b3f0a2ed2 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -10500,7 +10500,7 @@ Permissions required: bb.databases.get</p></td>
<td>/v1/{name=projects/*/instances/*/databases/*}:query</td>
<td>*</td>
</tr>
-
+
@@ -10527,7 +10527,7 @@ Permissions required: bb.databases.get</p></td>
<td>/v1/{name=projects/*/instances/*/databases/*}:export</td>
<td>*</td>
</tr>
-
+
</tbody>
</table>
@@ -14351,36 +14351,6 @@ It narrows what an agent reads through the paths Bytebase masks; it is not
a confidentiality boundary. </p></td>
</tr>
- <tr>
- <td>capability_unreadable</td>
- <td><a href="#bool">bool</a></td>
- <td></td>
- <td><p>True when the row carries a capability key that this build cannot resolve
-to a ceiling. An enum name a newer release wrote is the legitimate trigger,
-during a rolling upgrade; a hand-edited token reaches the same state.
-False for every readable row, including one that was never configured.
-
-The capability field cannot carry this on its own: the unmarshaler discards
-an enum name it does not know, so an unreadable row and a never-configured
-one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
-first and served at READ_WRITE for the second. A client reading only the
-capability shows the most permissive ceiling over a workspace where every
-MCP connection is being refused.
-
-A row protojson cannot parse at all is NOT this state. There is no ceiling
-in it to describe, so the read fails instead, and repairing it needs an
-operator rather than this field.
-
-The stored token itself is deliberately not returned. Telling a typo apart
-from a value a newer release wrote would only pay off if this enum grew,
-and it has not: its one reserved slot held a tier removed before any
-release shipped it.
-
-Set the row right by writing value.mcp.capability. Any other path is
-refused while this is true, because the merge that saved it would erase the
-value nobody could read. </p></td>
- </tr>
-
</tbody>
</table>
@@ -15318,7 +15288,7 @@ Default to this mode.</p></td>
</table>
<h3 id="bytebase.v1.MCPSetting.Capability">MCPSetting.Capability</h3>
- <p>Capability is the ceiling: a session runs at this level or lower. An absent</p><p>MCP setting resolves to READ_WRITE, so a workspace that never configured</p><p>MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —</p><p>omit the update mask path to leave the ceiling unset.</p>
+ <p>Capability is the ceiling: a session runs at this level or lower.</p><p>Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask</p><p>path to leave the current ceiling unchanged.</p>
<table class="enum-table">
<thead>
<tr><td>Name</td><td>Number</td><td>Description</td></tr>
@@ -36498,8 +36468,7 @@ 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. A workspace that never configured
-MCP resolves to READ_WRITE. </p></td>
+ <td><p>The ceiling in force for this workspace. </p></td>
</tr>
<tr>
@@ -37227,3 +37196,4 @@ Permissions required: bb.workspaces.rotateDirectorySyncToken</p></td>
</table>
</body>
</html>
+
diff --git a/proto/store/store/setting.proto b/proto/store/store/setting.proto
index 31edaff417..bab5570e45 100644
--- a/proto/store/store/setting.proto
+++ b/proto/store/store/setting.proto
@@ -39,8 +39,6 @@ message SystemSetting {
message WorkspaceProfileSetting {
reserved 15;
// 26 was mcp_capability, released in 3.21.0 and moved to the MCP setting.
- // A row still carrying the old key is inert: the shared unmarshaler discards
- // unknown fields, and nothing reads it. See store.GetMCPSettingsUncached.
reserved 26;
reserved "mcp_capability";
message Announcement {
@@ -178,9 +176,7 @@ message WorkspaceProfileSetting {
// request and should not share a row — or a parse failure — with branding and
// sign-in configuration.
message MCPSetting {
- // Capability is the ceiling: a session runs at this level or lower. An absent
- // MCP setting resolves to READ_WRITE, so a workspace that never configured
- // MCP is unaffected.
+ // Capability is the ceiling: a session runs at this level or lower.
enum Capability {
CAPABILITY_UNSPECIFIED = 0;
// MCP connections are rejected.
diff --git a/proto/v1/v1/setting_service.proto b/proto/v1/v1/setting_service.proto
index 9ff4376c11..fe30b818a0 100644
--- a/proto/v1/v1/setting_service.proto
+++ b/proto/v1/v1/setting_service.proto
@@ -213,7 +213,7 @@ message AppIMSetting {
message WorkspaceProfileSetting {
reserved 15;
- // 26 was mcp_capability, released in 3.21.0 and moved to the MCP setting.
+ // 26 was mcp_capability.
reserved 26;
reserved "mcp_capability";
// The external URL is used for sso authentication callback.
@@ -319,10 +319,9 @@ message WorkspaceProfileSetting {
// MCPSetting is what an MCP (Model Context Protocol) session may do in this
// workspace.
message MCPSetting {
- // Capability is the ceiling: a session runs at this level or lower. An absent
- // MCP setting resolves to READ_WRITE, so a workspace that never configured
- // MCP is unaffected. Writing CAPABILITY_UNSPECIFIED explicitly is rejected —
- // omit the update mask path to leave the ceiling unset.
+ // Capability is the ceiling: a session runs at this level or lower.
+ // Writing CAPABILITY_UNSPECIFIED explicitly is rejected; omit the update mask
+ // path to leave the current ceiling unchanged.
enum Capability {
CAPABILITY_UNSPECIFIED = 0;
// MCP connections are rejected.
@@ -358,32 +357,6 @@ message MCPSetting {
// It narrows what an agent reads through the paths Bytebase masks; it is not
// a confidentiality boundary.
bool ignore_masking_exemptions = 2;
-
- // True when the row carries a capability key that this build cannot resolve
- // to a ceiling. An enum name a newer release wrote is the legitimate trigger,
- // during a rolling upgrade; a hand-edited token reaches the same state.
- // False for every readable row, including one that was never configured.
- //
- // The capability field cannot carry this on its own: the unmarshaler discards
- // an enum name it does not know, so an unreadable row and a never-configured
- // one both arrive as CAPABILITY_UNSPECIFIED, while MCP is refused for the
- // first and served at READ_WRITE for the second. A client reading only the
- // capability shows the most permissive ceiling over a workspace where every
- // MCP connection is being refused.
- //
- // A row protojson cannot parse at all is NOT this state. There is no ceiling
- // in it to describe, so the read fails instead, and repairing it needs an
- // operator rather than this field.
- //
- // The stored token itself is deliberately not returned. Telling a typo apart
- // from a value a newer release wrote would only pay off if this enum grew,
- // and it has not: its one reserved slot held a tier removed before any
- // release shipped it.
- //
- // Set the row right by writing value.mcp.capability. Any other path is
- // refused while this is true, because the merge that saved it would erase the
- // value nobody could read.
- bool capability_unreadable = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}
message SQLEditorThemeSetting {
diff --git a/proto/v1/v1/workspace_service.proto b/proto/v1/v1/workspace_service.proto
index a4d69c102c..6c0df55d93 100644
--- a/proto/v1/v1/workspace_service.proto
+++ b/proto/v1/v1/workspace_service.proto
@@ -149,8 +149,7 @@ message MCPInfo {
// nothing to get it by.
string workspace = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
- // The ceiling in force for this workspace. A workspace that never configured
- // MCP resolves to READ_WRITE.
+ // The ceiling in force for this workspace.
MCPSetting.Capability capability = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// What each ceiling serves, including the one in force, so an admin can