---
title: "Feature Flags"
description: "Optional features such as component docs, Mermaid, AI Chat and accessibility checks are controlled by switches in nuxt.config, and features that are off bundle none of their dependencies. This page lists each flag's default, the dependencies to install when enabling it, and what happens when it is off."
canonical_url: "https://docs.mhaibaraai.cn/en/docs/guide/features"
---
# Feature Flags

> Optional features such as component docs, Mermaid, AI Chat and accessibility checks are controlled by switches in nuxt.config, and features that are off bundle none of their dependencies. This page lists each flag's default, the dependencies to install when enabling it, and what happens when it is off.

## Overview

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  extends: ['@movk/nuxt-docs'],
  movkNuxtDocs: {
    componentDocs: false,
    mcp: true,
    ogImage: true,
    mermaid: false,
    a11y: false
  },
  aiChat: {
    enabled: undefined
  }
})
```

| Flag | Default | Enables | Extra install |
| --- | --- | --- | --- |
| `movkNuxtDocs.componentDocs` | `false` | `ComponentProps`, `ComponentSlots`, `ComponentEmits`, `ComponentCode`, `ComponentExample` and Prettier formatting | Yes |
| `movkNuxtDocs.mcp` | `true` | Built-in MCP Server (`@nuxtjs/mcp-toolkit`) | No |
| `movkNuxtDocs.ogImage` | `true` | OG images generated per page at build time (`nuxt-og-image`) | No |
| `movkNuxtDocs.mermaid` | `false` | Mermaid diagrams in Markdown | Yes |
| `movkNuxtDocs.a11y` | `false` | `@nuxt/a11y` accessibility checks during development | Yes |
| `aiChat.enabled` | `true` when `AI_API_KEY` exists at build time | AI chat assistant, floating input and "Explain with AI" | Yes |

Dependencies of features that are on by default (MCP, OG images) ship with the layer. Features that are off by default declare their dependencies as optional peer dependencies, which your project installs when enabling them.

> [!WARNING]
> 
> AI Chat reads the docs through the MCP Server. Setting 
> 
> movkNuxtDocs.mcp: false
> 
>  while 
> 
> aiChat
> 
>  is enabled fails the build.

## Installing dependencies

When an enabled feature is missing dependencies, the build stops and lists the missing packages with an install command, for example:

```text
[@movk/nuxt-docs] 已启用的功能缺少依赖：
  - mermaid: mermaid, dompurify
请安装后重试：pnpm add mermaid dompurify
```

### Component docs

```bash [pnpm]
pnpm add nuxt-component-meta vue-component-meta prettier
```

```bash [npm]
npm install nuxt-component-meta vue-component-meta prettier
```

```bash [yarn]
yarn add nuxt-component-meta vue-component-meta prettier
```

```bash [bun]
bun add nuxt-component-meta vue-component-meta prettier
```

Once enabled, only components listed in `componentMeta.include` get metadata, see [nuxt.config Options](https://docs.mhaibaraai.cn/en/docs/reference/nuxt-config#componentmeta).

### Mermaid

```bash [pnpm]
pnpm add mermaid dompurify
```

```bash [npm]
npm install mermaid dompurify
```

```bash [yarn]
yarn add mermaid dompurify
```

```bash [bun]
bun add mermaid dompurify
```

### Accessibility checks

```bash [pnpm]
pnpm add @nuxt/a11y
```

```bash [npm]
npm install @nuxt/a11y
```

```bash [yarn]
yarn add @nuxt/a11y
```

```bash [bun]
bun add @nuxt/a11y
```

### AI Chat

```bash [pnpm]
pnpm add ai @ai-sdk/openai @ai-sdk/vue @comark/vue @shikijs/engine-javascript @shikijs/langs @shikijs/themes
```

```bash [npm]
npm install ai @ai-sdk/openai @ai-sdk/vue @comark/vue @shikijs/engine-javascript @shikijs/langs @shikijs/themes
```

```bash [yarn]
yarn add ai @ai-sdk/openai @ai-sdk/vue @comark/vue @shikijs/engine-javascript @shikijs/langs @shikijs/themes
```

```bash [bun]
bun add ai @ai-sdk/openai @ai-sdk/vue @comark/vue @shikijs/engine-javascript @shikijs/langs @shikijs/themes
```

Then set `AI_API_KEY` (and optionally `AI_BASE_URL`) in both the build and runtime environments. See [AI Chat](https://docs.mhaibaraai.cn/en/docs/ai/ai-chat) for models and other options.

## When a feature is off

Disabled features are excluded from bundling and type checking, and callers never need to check the flag:

| Feature | When off |
| --- | --- |
| Component docs | The component docs MDC components are not registered; raw markdown and the MCP component tools receive empty metadata and examples |
| MCP | The `/mcp` endpoint is not registered and `/.well-known/mcp/server-card.json` is not generated |
| OG images | `defineOgImage` calls become no-ops; `og:title`, `og:description` and other meta tags remain |
| Mermaid | Code blocks tagged `mermaid` render as plain code blocks |
| a11y | `@nuxt/a11y` is not loaded |
| AI Chat | `AiChat`, `AiChatPanel` and related components are replaced with disabled versions, `useAIChat()` returns a disabled implementation, and the header hides the AI entry |

When `aiChat.enabled` is not set, it follows whether `AI_API_KEY` exists **at build time**. If you set `aiChat.enabled: true` without the variable at build time, the build warns you to make sure the runtime environment provides it.

> [!TIP]
> 
> Turning every optional feature off gives the smallest output and the fastest build:
> 
> ```ts [nuxt.config.ts]
> export default defineNuxtConfig({
>   movkNuxtDocs: {
>     mcp: false,
>     ogImage: false
>   },
>   aiChat: {
>     enabled: false
>   }
> })
> ```


## Sitemap

See the full [sitemap](https://docs.mhaibaraai.cn/sitemap.md) for all pages.
