Add AI_ENABLED env var to opt out of AI Chat#26458
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new AI_ENABLED environment variable to provide administrators with infrastructure-level control over AI Chat features. When disabled, the AI Chat functionality is completely removed from both the API and the application UI. The PR also improves the settings UI by separating AI and MCP (Model Context Protocol) settings into distinct groups with independent edit states and appropriate disabled state notifications.
Key Changes:
- Added
AI_ENABLEDenvironment variable (defaults totrue) that controls whether the/ai/chatAPI endpoint is mounted and whether the AI sidebar appears in the app - Separated MCP settings fields into a new
mcp_groupin the system data schema for better organization - Updated the AI settings page to display separate forms for AI and MCP settings with warning notices when features are disabled via environment variables
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/env/src/constants/directus-variables.ts |
Added AI_ENABLED to the list of recognized environment variables |
packages/env/src/constants/defaults.ts |
Set default value of AI_ENABLED to true |
api/src/services/server.ts |
Added ai_enabled flag to server info response based on environment variable |
api/src/app.ts |
Conditionally mount /ai/chat route only when AI_ENABLED is true |
app/src/stores/server.ts |
Added ai_enabled field to the Info type and hydration logic |
app/src/views/private/private-view/components/private-view-sidebar.vue |
Conditionally render AI sidebar and adjust layout based on ai_enabled flag |
app/src/modules/settings/routes/ai/overview.vue |
Split AI and MCP settings into separate forms with independent edit states and disabled notices |
app/src/modules/settings/components/navigation.vue |
Always show AI settings link (removed conditional based on mcp_enabled) |
app/src/modules/settings/routes/project/project.vue |
Added mcp_group to excluded groups list |
packages/system-data/src/fields/settings.yaml |
Created new mcp_group and moved MCP-related fields from ai_group to mcp_group |
app/src/lang/translations/en-US.yaml |
Added translation keys for AI and MCP disabled notices |
.changeset/silver-tigers-glow.md |
Documented the changes for version management |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Should we allow disabling it via the settings page as well? Similar to what we did for MCP?
Assuming we keep the AI_ENABLED flag in the info output we need to update the following locations:
- SDK server info command response type
- OpenAPI object response output
- Document the new AI_ENABLED env var
Co-authored-by: daedalus <[email protected]>
Lets stick with the env var for now as it's more of a global killswitch. We can revisit if/when the need arises 👍 |
Co-authored-by: daedalus <[email protected]>
AI_ENABLEDenv variable for opt out of AI chat.Docs PR
directus/docs#535
This pull request introduces a new
AI_ENABLEDenvironment variable to allow administrators to fully disable AI Chat features at the infrastructure level. When disabled, the/ai/chatAPI route is not mounted, the AI sidebar is hidden in the app, and the settings UI reflects the disabled state with appropriate notices. Additionally, the MCP (Model Context Protocol) settings have been separated into their own group in the settings UI, and the UI logic for editing AI and MCP settings has been improved.AI Chat Feature Toggle & Infrastructure:
AI_ENABLEDenvironment variable (default:true) to allow complete opt-out of AI Chat features. When set tofalse, the/ai/chatroute is not mounted in the API, and the AI sidebar is hidden in the app. [1] [2] [3] [4] [5] [6]ai_enabledflag in its info response, and the client app consumes this value to control feature visibility. [1] [2] [3] [4]Settings UI & User Feedback:
System Data & Field Grouping:
ai_groupto a newmcp_groupin the system data schema, improving clarity and separation in the settings UI. [1] [2] [3] [4] [5] [6] [7] [8]ai_groupandmcp_groupfrom its main settings form.