[Bug]: "Create credential" in MCP Server settings on self-hosted fails with generic "you are not allowed to perform this action" when Copilot is disabled (the default)
What happened?
On a default self-hosted instance, creating an MCP credential from Settings → Integrations → MCP Server → Create credential fails with:
You are not allowed to perform this action.
No credential is created. The message reads like a workspace role/permission problem, but it is not one — the mutation only requires Workspace.Read. The actual cause is that MCP credential creation is gated behind copilot.enabled, which defaults to false on self-hosted, and nothing in the UI indicates this.
Steps to reproduce
- Deploy AFFiNE self-hosted with default configuration (Copilot/AI never enabled).
- Open a workspace → Settings → Integrations → MCP Server (the section is visible).
- Click "Create credential" → generic permission error.
Expected: the section is hidden/disabled with a hint that AI features must be enabled (with a docs link), or creation succeeds, or at minimum the error states the real cause.
Root cause (checked against 0.27.4 source, commit ca0ffc52f78187382928c90293cd487618f5f024):
McpCredentialResolveris decorated@CopilotEnabled()—plugins/copilot/mcp/resolver.ts#L93- which calls
assertCopilotEnabled()—plugins/copilot/availability.ts#L4-L8:
export function assertCopilotEnabled(config: Config) {
if (!config.copilot.enabled) {
throw new ActionForbidden('Copilot is disabled.');
}
}copilot.enableddefaults tofalse—plugins/copilot/config.ts#L73-L81- The client shows the generic
action_forbiddentext (base/error/def.ts#L464-L469) and drops the specific "Copilot is disabled." message. - The frontend renders the MCP Server section even though
serverConfig.featuresalready reports whetherCopilotis enabled, so the UI advertises a feature the backend will refuse.
Suggestions
- Hide/disable the MCP Server settings section when
serverConfig.featureslacksCopilot, with a hint + docs link. - Surface the concrete error message ("Copilot is disabled") instead of the generic
action_forbiddenstring. - Consider decoupling read-only MCP (
doc_search,read_document) fromcopilot.enabled— these tools don't need an LLM provider, but currently require enabling AI features.
Workaround (verified on 0.27.4): add to /root/.affine/config/config.json (host ./config/config.json in the official Docker Compose setup) and restart:
{ "copilot": { "enabled": true, "byok": { "enabled": true } } }Distribution version
Not applicable — web, self-hosted
App Version
No response
What browsers are you seeing the problem on if you're using web version?
Not browser-specific — the failure is a server-side guard; verified via direct GraphQL queries against the server.
Are you self-hosting?
- Yes
Self-hosting Version
0.27.4 (ghcr.io/toeverything/affine:stable, Docker Compose)
Relevant log output
# Default config: "Create credential" in the UI fails with
# "You are not allowed to perform this action."
# Server reports no Copilot feature:
$ curl -s http://localhost:3010/graphql -H 'Content-Type: application/json' \
-d '{"query":"{ serverConfig { version features } }"}'
{"data":{"serverConfig":{"version":"0.27.4","features":["Comment","CopilotEmbedding","OAuth"]}}}
# After adding {"copilot":{"enabled":true,"byok":{"enabled":true}}} to
# /root/.affine/config/config.json and restarting the app container:
{"data":{"serverConfig":{"version":"0.27.4","features":["Comment","Copilot","CopilotEmbedding","OAuth"]}}}
# -> credential creation now succeedsAnything else?
Related issues that are similar but different (not duplicates):
- #15506 — AI chat failing with
copilot_disabled(native runtime not readingconfig.json; different layer than the credential-creation guard) - #15112 — feature request for MCP write tools (this report is about the default read-only flow failing entirely)
- #15567 — "Can't make MCP Write" (access-mode availability, not this permission error)
Is your content generated by AI?
- I confirm that the content I submitted was not generated by AI / merely contained minimal AI edits.
- It was created mostly by AI after thorough interactive Human + AI session for troubleshooting and diagnosis.
Source: toeverything/AFFiNE