n8n-io/n8n · error · Error
Failed to enable MCP access (server reported mcpAccessEnable
Error message
Failed to enable MCP access (server reported mcpAccessEnabled=${String(data.mcpAccessEnabled)}) What it means
enableMcpAccess PATCHes /rest/mcp/settings with mcpAccessEnabled:true and expects the server to confirm it is enabled. If the response's mcpAccessEnabled is not strictly true, the server refused — the most common cause is N8N_MCP_MANAGED_BY_ENV pinning the setting to env, which makes the PATCH a no-op.
Source
Thrown at packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts:637
/**
* Enable MCP access for this instance (owner scope required).
* PATCH /rest/mcp/settings body: { mcpAccessEnabled: true }
*
* `/rest/e2e/reset` truncates the settings table and clears the cache, so MCP
* access is off after a reset regardless of startup env — the fused
* `--build-via-mcp` lane setup calls this after seeding. Throws if the server
* reports MCP still disabled (e.g. N8N_MCP_MANAGED_BY_ENV refuses the PATCH).
*/
async enableMcpAccess(): Promise<void> {
const data = this.unwrapRestData<{ mcpAccessEnabled?: boolean }>(
await this.fetch('/rest/mcp/settings', {
method: 'PATCH',
body: { mcpAccessEnabled: true },
}),
);
if (data.mcpAccessEnabled !== true) {
throw new Error(
`Failed to enable MCP access (server reported mcpAccessEnabled=${String(data.mcpAccessEnabled)})`,
);
}
}
/**
* Mint a fresh MCP API key for the authenticated user.
* POST /rest/mcp/api-key/rotate
*
* Uses rotate rather than GET /rest/mcp/api-key because the GET only returns
* the raw JWT when it creates the key; a pre-existing key comes back redacted
* (`******abcd`), which would silently break MCP auth if staged into a
* `claude` config. Rotate deletes + recreates, so the response is always
* unredacted — at the cost of invalidating any prior MCP key for this user.
*/
async rotateMcpApiKey(): Promise<string> {
const data = this.unwrapRestData<{ apiKey?: string }>(
await this.fetch('/rest/mcp/api-key/rotate', { method: 'POST' }),View on GitHub (pinned to 5ac6606e81)
Solutions
- Unset N8N_MCP_MANAGED_BY_ENV (or set it to allow runtime control) and reboot the instance before retrying.
- Pre-enable MCP access in the instance's env config so the PATCH is unnecessary.
- If env management is intentional, do not call enableMcpAccess — pre-configure the instance.
Defensive patterns
Strategy: validation
Validate before calling
// Detect managed-by-env before calling PATCH:
if (process.env.N8N_MCP_MANAGED_BY_ENV === 'true')
throw new Error('MCP is env-managed; unset N8N_MCP_MANAGED_BY_ENV to enable at runtime'); Try / catch
try { await client.enableMcpAccess(); }
catch (e) {
if (e instanceof Error && e.message.includes('mcpAccessEnabled')) { /* unset env-managed flag, reboot, retry */ }
else throw e;
} Prevention
- Pre-enable MCP access in env when N8N_MCP_MANAGED_BY_ENV is set.
- Don't call enableMcpAccess in lanes that run against env-managed instances.
- Document the managed-by-env gotcha in lane setup.
When it happens
Trigger: Running the fused `--build-via-mcp` lane setup against an instance booted with N8N_MCP_MANAGED_BY_ENV=true; the setting is locked by an admin policy.
Common situations: Enterprise deployments that pin MCP via env to prevent runtime toggling; CI image configured for reproducibility with managed-by-env.
Related errors
- MCP server "${cfg.name}": exactly one of "url" or "command"
- MCP server "${cfg.name}": provide either "url" or "command",
- MCP server name "${cfg.name}" is already registered
- Unknown agents module: "${moduleName}". ${validTokens ? `Val
- Failed to parse ${label} at ${path}: ${msg}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/4c9b3c3dd133477c.
Report an issue: GitHub.