Skip to content

Add AI_ENABLED env var to opt out of AI Chat#26458

Merged
rijkvanzanten merged 13 commits intomainfrom
bry/ai-env-opt-out
Jan 8, 2026
Merged

Add AI_ENABLED env var to opt out of AI Chat#26458
rijkvanzanten merged 13 commits intomainfrom
bry/ai-env-opt-out

Conversation

@bryantgillespie
Copy link
Member

@bryantgillespie bryantgillespie commented Jan 6, 2026

  • Adds AI_ENABLED env variable for opt out of AI chat.
  • Fixes AI Settings in navigation when MCP_ENABLED = false
  • Adds V-Notice to top of each section and disables form when MCP or AI Chat is disabled
ScreenShot 2026-01-06 at 16 51 55@2x

Docs PR
directus/docs#535


This pull request introduces a new AI_ENABLED environment variable to allow administrators to fully disable AI Chat features at the infrastructure level. When disabled, the /ai/chat API 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:

  • Added AI_ENABLED environment variable (default: true) to allow complete opt-out of AI Chat features. When set to false, the /ai/chat route is not mounted in the API, and the AI sidebar is hidden in the app. [1] [2] [3] [4] [5] [6]
  • Server now exposes the ai_enabled flag in its info response, and the client app consumes this value to control feature visibility. [1] [2] [3] [4]

Settings UI & User Feedback:

  • The AI and MCP settings are now shown in separate forms/groups in the settings UI, each with its own edit state and disabled state handling. Notices are shown if either feature is disabled via environment variables. [1] [2] [3] [4] [5]
  • The AI settings navigation link is now always shown, but the section is disabled and displays a notice if AI is disabled.

System Data & Field Grouping:

  • MCP-related settings fields have been moved from the ai_group to a new mcp_group in the system data schema, improving clarity and separation in the settings UI. [1] [2] [3] [4] [5] [6] [7] [8]
  • The project settings UI now excludes both ai_group and mcp_group from its main settings form.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ENABLED environment variable (defaults to true) that controls whether the /ai/chat API endpoint is mounted and whether the AI sidebar appears in the app
  • Separated MCP settings fields into a new mcp_group in 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Copy link
Member

@ComfortablyCoding ComfortablyCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

@rijkvanzanten
Copy link
Member

Should we allow disabling it via the settings page as well? Similar to what we did for MCP?

Lets stick with the env var for now as it's more of a global killswitch. We can revisit if/when the need arises 👍

Copy link
Member

@rijkvanzanten rijkvanzanten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rijkvanzanten rijkvanzanten merged commit 36c3049 into main Jan 8, 2026
68 of 69 checks passed
@rijkvanzanten rijkvanzanten deleted the bry/ai-env-opt-out branch January 8, 2026 22:02
@github-actions github-actions bot added this to the Next Release milestone Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants