{"record":{"id":"4c9b3c3dd133477c","repo":"n8n-io/n8n","slug":"failed-to-enable-mcp-access-server-reported-mcpac","errorCode":null,"errorMessage":"Failed to enable MCP access (server reported mcpAccessEnabled=${String(data.mcpAccessEnabled)})","messagePattern":"Failed to enable MCP access \\(server reported mcpAccessEnabled=(.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts","lineNumber":637,"sourceCode":"\n\t/**\n\t * Enable MCP access for this instance (owner scope required).\n\t * PATCH /rest/mcp/settings  body: { mcpAccessEnabled: true }\n\t *\n\t * `/rest/e2e/reset` truncates the settings table and clears the cache, so MCP\n\t * access is off after a reset regardless of startup env — the fused\n\t * `--build-via-mcp` lane setup calls this after seeding. Throws if the server\n\t * reports MCP still disabled (e.g. N8N_MCP_MANAGED_BY_ENV refuses the PATCH).\n\t */\n\tasync enableMcpAccess(): Promise<void> {\n\t\tconst data = this.unwrapRestData<{ mcpAccessEnabled?: boolean }>(\n\t\t\tawait this.fetch('/rest/mcp/settings', {\n\t\t\t\tmethod: 'PATCH',\n\t\t\t\tbody: { mcpAccessEnabled: true },\n\t\t\t}),\n\t\t);\n\t\tif (data.mcpAccessEnabled !== true) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to enable MCP access (server reported mcpAccessEnabled=${String(data.mcpAccessEnabled)})`,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Mint a fresh MCP API key for the authenticated user.\n\t * POST /rest/mcp/api-key/rotate\n\t *\n\t * Uses rotate rather than GET /rest/mcp/api-key because the GET only returns\n\t * the raw JWT when it creates the key; a pre-existing key comes back redacted\n\t * (`******abcd`), which would silently break MCP auth if staged into a\n\t * `claude` config. Rotate deletes + recreates, so the response is always\n\t * unredacted — at the cost of invalidating any prior MCP key for this user.\n\t */\n\tasync rotateMcpApiKey(): Promise<string> {\n\t\tconst data = this.unwrapRestData<{ apiKey?: string }>(\n\t\t\tawait this.fetch('/rest/mcp/api-key/rotate', { method: 'POST' }),","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/clients/n8n-client.ts#L619-L655","documentation":"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.","triggerScenarios":"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.","commonSituations":"Enterprise deployments that pin MCP via env to prevent runtime toggling; CI image configured for reproducibility with managed-by-env.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Detect managed-by-env before calling PATCH:\nif (process.env.N8N_MCP_MANAGED_BY_ENV === 'true')\n  throw new Error('MCP is env-managed; unset N8N_MCP_MANAGED_BY_ENV to enable at runtime');","typeGuard":null,"tryCatchPattern":"try { await client.enableMcpAccess(); }\ncatch (e) {\n  if (e instanceof Error && e.message.includes('mcpAccessEnabled')) { /* unset env-managed flag, reboot, retry */ }\n  else throw e;\n}","preventionTips":["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."],"tags":["mcp","config","n8n-api","env"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}