Documentation Index
Fetch the complete documentation index at: https://docs.mdcms.ai/llms.txt
Use this file to discover all available pages before exploring further.
Config file
The CLI reads its configuration frommdcms.config.ts at the project root. Use defineConfig and defineType from @mdcms/cli to get full type safety.
mdcms.config.ts
Config options
All properties accepted bydefineConfig:
| Property | Type | Required | Description |
|---|---|---|---|
project | string | Yes | Project slug. Must match the project on the server |
serverUrl | string | Yes | Base URL of the MDCMS server |
environment | string | No | Default environment name (e.g. development) |
contentDirectories | string[] | No | Directories to scan for content files. Default: ["content"] |
locales | object | No | Locale configuration (see below) |
types | MdcmsTypeDefinition[] | No | Content type definitions created with defineType |
environments | Record<string, object> | No | Per-environment config overlays (can override serverUrl, environment) |
components | object[] | No | MDX component registrations for the Studio editor |
Locale options
| Property | Type | Description |
|---|---|---|
locales.default | string | The default locale code (e.g. "en") |
locales.supported | string[] | All supported locale codes |
locales.aliases | Record<string, string> | Map alternate locale codes to canonical ones |
Type definition options
EachdefineType(name, options) accepts:
| Property | Type | Description |
|---|---|---|
directory | string | Filesystem directory for this type’s content files |
localized | boolean | Whether documents of this type are localized. Default: false |
fields | Record<string, ZodSchema> | Frontmatter field definitions using Zod schemas |
Environment files
The CLI loads.env* files before importing mdcms.config.ts, so config files can read values from process.env:
mdcms.config.ts
mdcms.config.ts, mdcms.config.js, or mdcms.config.mjs. If you pass --config ./config/mdcms.config.ts, the CLI looks for env files in ./config. Without --config, the CLI searches upward from the current directory for the nearest config file.
Put local developer values in .env.local next to mdcms.config.ts:
.env.local
| Order | File | When loaded |
|---|---|---|
| 1 | .env.{NODE_ENV}.local | Always |
| 2 | .env.local | Except when NODE_ENV=test |
| 3 | .env.{NODE_ENV} | Always |
| 4 | .env | Always |
NODE_ENV is only the dotenv file selector. It controls names such as
.env.production; it does not select the MDCMS content environment. Use
MDCMS_ENVIRONMENT or the config environment field to choose an MDCMS
environment such as staging or production.NODE_ENV defaults to development when unset. Shell-exported variables override all file values, so CI secrets and one-off command exports always win. Use --no-env-file or MDCMS_DOTENV=0 to disable automatic env file loading for a run.
Manifest file
The manifest tracks the mapping between server documents and local files. It is stored at.mdcms.manifest.json in the project root, scoped to the current project and environment.
Structure
The manifest is a JSON object where each key is adocumentId and the value describes the local file:
.mdcms.manifest.json
| Field | Type | Description |
|---|---|---|
path | string | Relative path to the content file from project root |
format | "md" | "mdx" | File format |
draftRevision | number | Current draft revision number on the server |
publishedVersion | number | null | Published version number, or null if never published |
hash | string | Content hash of the file at last sync |
Schema state
After eachmdcms schema sync, the CLI writes a state file to:
marketing-site project in the development environment produces:
Contents
.mdcms/schema/marketing-site.development.json
schemaHash is required by mdcms push to validate that content is being pushed against the correct schema version. If this file is missing or the hash is stale, push operations will fail.
The
.mdcms/ directory should be added to .gitignore. The mdcms init
wizard does this automatically.File mapping
The CLI maps server documents to local files based on the type’sdirectory setting and the document’s path and locale.
Localized documents
Localized types produce files with the locale code inserted before the file extension:BlogPost document with path hello-world, locale en, and format mdx:
Non-localized documents
Non-localized types use a simpler pattern without the locale segment:Author document with path jane-doe and format md: