# mxcli Documentation — Full Reference Source: https://www.mxcli.org/print.html Version: mxcli v0.10.0 @ cf0ab07 Generated: 2026-05-19T06:04:06Z --- # [Preface](#preface) This documentation covers **mxcli**, a command-line tool for reading, querying, and modifying Mendix application projects, and **MDL (Mendix Definition Language)**, the SQL-like language it uses. Start with the [Vision](#vision) to understand where this project is headed. The material is organized into ten parts: - **Part I: Tutorial** walks you through installation, exploring a project, making your first changes, and integrating with AI assistants. - **Part II: MDL by Example** presents complete, self-contained examples – a CRM module, REST integration, data import, master-detail pages, validation, security, and more. - **Part III: Migration** covers AI-assisted migration of existing applications to Mendix – assessment, transformation, generation, data migration, and validation. - **Part IV: The MDL Language** is a comprehensive guide to MDL syntax – domain models, microflows, pages, security, navigation, workflows, and business events. - **Part V: Project Tools** covers code navigation, catalog queries, linting, testing, external SQL, and Docker integration. - **Part VI: IDE Integration** describes the VS Code extension, LSP server, and `mxcli init` project setup. - **Part VII: Go Library** documents the Go API for programmatic access to Mendix projects. - **Part VIII: MDL Statement Reference** provides detailed syntax and examples for every MDL statement. - **Part IX: Architecture and Internals** explains the MPR file format, parser pipeline, and catalog system for contributors. - **Part X: Appendixes** includes quick reference tables, reserved words, error messages, and a glossary. You can read the Tutorial sequentially or jump directly to the section relevant to your task. The Statement Reference (Part VI) is designed for lookup rather than linear reading. # [Vision](#vision) mxcli and MDL exist to make Mendix development accessible to coding agents, automation pipelines, and developers who prefer text-based tools. The long-term goal is a complete alternative to Mendix Studio Pro that runs headless, integrates with AI workflows, and never requires leaving VS Code. ## [Coding Agents First](#coding-agents-first) The primary audience for mxcli is not a human typing commands – it is a coding agent (Claude Code, GitHub Copilot, OpenCode, Cursor, Windsurf, or similar) that reads, reasons about, and modifies Mendix projects autonomously. Everything in mxcli is designed with this in mind: - **MDL as machine-readable output.** Every `DESCRIBE` command produces valid MDL that can be fed back as input. Agents can read a microflow, modify it, and write it back without lossy format conversions. - **Skills and context files.** `mxcli init` generates structured skill files that teach agents MDL syntax, common patterns, and project conventions – reducing hallucination and retry loops. - **Headless operation.** mxcli is a single static binary with no GUI, no daemon, and no login. It runs in CI pipelines, containers, and sandboxed agent environments without setup friction. ## [QA Feedback in the Agentic Loop](#qa-feedback-in-the-agentic-loop) Agents produce better results when they can evaluate their own output. mxcli provides the tooling to close this feedback loop: - **`mxcli check`** validates MDL syntax and catches anti-patterns before changes are applied. - **`mxcli lint`** runs 40+ rules across the full project, surfacing issues an agent can fix in the same session. - **`mxcli docker build` and `mx check`** compile and validate the project against the real Mendix runtime, catching structural errors that static analysis misses. - **`mxcli test`** runs microflow tests inside a live Mendix container, giving agents pass/fail signals on functional correctness. Together, these tools let an agent write MDL, validate it, fix issues, and verify the result – all without human intervention. ## [VS Code as the Review Surface](#vs-code-as-the-review-surface) While agents do the building, humans need to review and approve the result. The VS Code extension (`vscode-mdl`) provides the visual tools to do this without leaving the editor: - **Syntax highlighting, diagnostics, and completion** for `.mdl` files. - **Hover and go-to-definition** for navigating the Mendix model from code. - **Context menu commands** to run, check, and lint MDL directly from the editor. - **Terminal link integration** so that entity names, microflow references, and error locations in terminal output are clickable. The goal is that a developer can review an agent’s changes, run the app, inspect the result, and approve – all within VS Code. ## [Long-Term Roadmap](#long-term-roadmap) The end state is a complete headless development environment for Mendix: | Capability | Status | Description | | --- | --- | --- | | Model read/write | Shipped | Full domain model, microflow, page, security, navigation, workflow support | | Validation and linting | Shipped | `mxcli check`, `mxcli lint`, 40+ rules, SARIF output for CI | | Build and run | Shipped | `mxcli docker build/run` with hot reload | | Testing | Shipped | `.test.mdl` microflow tests with Docker runtime | | VS Code extension | Shipped | LSP, diagnostics, completion, hover, go-to-definition | | External SQL | Shipped | Query PostgreSQL, Oracle, SQL Server; import data | | Mendix Marketplace | Planned | Install and manage Marketplace modules from the CLI | | Mendix Cloud deployment | Planned | Deploy to Mendix Cloud environments without Studio Pro | | Mendix Catalog | Planned | Publish and consume APIs via the Mendix Catalog | | Visual page preview | Planned | Preview pages in VS Code without running the app | | Full Studio Pro parity | Long-term | Cover remaining metamodel domains (REST, OData, consumed services, etc.) | The measure of success is simple: a team should be able to develop, test, review, and deploy a Mendix application without ever opening Studio Pro. # [What is mxcli?](#what-is-mxcli) **mxcli** is a command-line tool that enables developers and AI coding assistants to read, understand, and modify Mendix application projects. Mendix projects are stored in binary `.mpr` files that cannot be read or edited as text. mxcli bridges this gap by providing a text-based interface using MDL (Mendix Definition Language), a SQL-like syntax for querying and manipulating Mendix models. ## [How It Works](#how-it-works) ``` ┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐ │ Developer │ │ mxcli │ │ Mendix Project │ │ or AI Agent │────>│ (MDL REPL) │────>│ (.mpr file) │ │ │ MDL │ │ │ │ │ "Create a │ │ Parses MDL │ │ Creates actual │ │ Customer │ │ Validates │ │ entities, │ │ entity..." │ │ Executes │ │ microflows, │ └─────────────────┘ └──────────────┘ │ pages, etc. │ └─────────────────┘ ``` A developer or AI agent writes MDL statements. mxcli parses and validates them, then applies the changes directly to the `.mpr` project file. The modified project can then be opened in Mendix Studio Pro as usual. > **Important:** Do not edit a project with mxcli while it is open in Studio Pro. Studio Pro maintains in-memory caches that cannot be updated externally, and concurrent edits will cause errors. Close the project in Studio Pro first, run mxcli, then re-open the project. ## [Key Capabilities](#key-capabilities) - **Project exploration** – list modules, entities, microflows, pages; describe any element in MDL; full-text search across all strings and source definitions. - **Code navigation** – find callers, callees, references, and impact analysis for any project element. - **Model modification** – create and alter entities, microflows, pages, security rules, navigation, workflows, and more using MDL scripts. - **Catalog queries** – SQL-based querying of project metadata (entity counts, microflow complexity, widget usage, cross-references). - **Linting and reports** – 40+ built-in lint rules with SARIF output for CI; scored best-practices reports. - **Testing** – test microflows using MDL syntax with javadoc-style annotations. - **AI assistant integration** – works with Claude Code, GitHub Copilot, OpenCode, Cursor, Continue.dev, Windsurf, and Aider. `mxcli init` sets up project configuration, skills, and a Dev Container for sandboxed AI development. - **VS Code extension** – syntax highlighting, diagnostics, code completion, hover, go-to-definition, and context menu commands for `.mdl` files. - **External SQL** – connect to PostgreSQL, Oracle, or SQL Server; query external databases; import data into a running Mendix application. ## [Supported Environments](#supported-environments) | Item | Details | | --- | --- | | Mendix versions | Studio Pro 8.x, 9.x, 10.x, 11.x | | MPR formats | v1 (single `.mpr` file) and v2 (`.mpr` + `mprcontents/` folder) | | Platforms | Linux, macOS, Windows (amd64 and arm64) | | Dependencies | None – mxcli is a single static binary with no runtime dependencies | # [What is MDL?](#what-is-mdl) **MDL (Mendix Definition Language)** is a text-based, SQL-like language for describing and manipulating Mendix application models. It provides a human-readable representation of Mendix project elements – entities, microflows, pages, security rules, and more – at the same abstraction level as the visual models in Studio Pro. ## [Why a Text-Based Language?](#why-a-text-based-language) Mendix projects are stored in a binary format (`.mpr` files containing BSON documents in SQLite). While Studio Pro provides a visual interface, there is no standard text format for Mendix models. This creates problems for: - **AI assistants** that need to read and generate model elements - **Code review** of changes to Mendix projects - **Scripting and automation** of repetitive modeling tasks - **Documentation** of project structure and design patterns MDL addresses these problems by providing a syntax that is both human-readable and machine-parseable. ## [Characteristics of MDL](#characteristics-of-mdl) - **SQL-like syntax** – uses familiar keywords like `CREATE`, `ALTER`, `DROP`, `SHOW`, `DESCRIBE`, `GRANT`. - **Declarative** – you describe what the model should look like, not how to construct it step by step. - **Complete** – covers domain models, microflows, pages, security, navigation, workflows, and business events. - **Validated** – mxcli can check MDL scripts for syntax errors and reference validity before applying them. ## [Token Efficiency](#token-efficiency) When working with AI coding assistants, context window size is a critical constraint. MDL’s compact syntax uses significantly fewer tokens than equivalent JSON model representations: | Representation | Tokens for a 10-entity module | | --- | --- | | JSON (raw model) | ~15,000–25,000 tokens | | MDL | ~2,000–4,000 tokens | | **Reduction** | **5–10x fewer tokens** | Fewer tokens means lower API costs, more application context fits in a single prompt, and AI assistants produce more accurate output because there is less noise in their input. ## [Example: JSON vs MDL](#example-json-vs-mdl) A simple entity definition illustrates the difference. **JSON representation (~180 tokens):** ``` { "entity": { "name": "Customer", "documentation": "Customer master data", "attributes": [ {"name": "Name", "type": {"type": "String", "length": 200}}, {"name": "Email", "type": {"type": "String", "length": 200}} ] } } ``` **MDL representation (~35 tokens):** ``` /** Customer master data */ CREATE PERSISTENT ENTITY Sales.Customer ( Name: String(200), Email: String(200) ); ``` The MDL version conveys the same information in roughly one-fifth the space, and its structure is immediately recognizable to anyone familiar with SQL DDL. ## [What MDL Covers](#what-mdl-covers) MDL provides statements for the following areas of a Mendix project: | Area | Example Statements | | --- | --- | | Domain model | `CREATE ENTITY`, `ALTER ENTITY`, `CREATE ASSOCIATION` | | Microflows | `CREATE MICROFLOW`, `CREATE NANOFLOW` | | Pages | `CREATE PAGE`, `CREATE SNIPPET`, `ALTER PAGE` | | Security | `CREATE MODULE ROLE`, `GRANT`, `REVOKE` | | Navigation | `ALTER NAVIGATION` | | Workflows | `CREATE WORKFLOW` | | Business events | `CREATE BUSINESS EVENT SERVICE` | | Project queries | `SHOW MODULES`, `DESCRIBE ENTITY`, `SEARCH` | | Catalog | `REFRESH CATALOG`, `SELECT FROM CATALOG` | See Part II (The MDL Language) for a complete guide, or Part VI (MDL Statement Reference) for detailed syntax of each statement. # [Mendix Concepts for Newcomers](#mendix-concepts-for-newcomers) This page explains the core Mendix concepts you’ll encounter when using mxcli. If you’re familiar with web frameworks, relational databases, or backend development, most of these will map to things you already know. ## [The Big Picture](#the-big-picture) A **Mendix application** is a model-driven app. Instead of writing code in files, developers build applications visually in **Studio Pro** (the Mendix IDE). The entire application model – data structures, logic, UI, security – is stored in a single binary file called an **MPR** (Mendix Project Resource). mxcli lets you read and modify that MPR file using text commands, without opening Studio Pro. ## [Modules](#modules) A **module** is the top-level organizational unit, like a package in Go or a namespace in C#. Each module has its own: - Domain model (data structures) - Microflows and nanoflows (logic) - Pages (UI) - Enumerations (constant sets) - Security settings A typical project has a few custom modules (`Sales`, `Admin`, `Integration`) plus system modules provided by the platform (`System`, `Administration`). ``` SHOW MODULES; ``` ## [Domain Model](#domain-model) The **domain model** is the data layer of a module. If you know relational databases, the mapping is straightforward: | Mendix Concept | Relational Equivalent | MDL Syntax | | --- | --- | --- | | Entity | Table | `CREATE ENTITY` | | Attribute | Column | Inside entity definition | | Association | Foreign key / Join table | `CREATE ASSOCIATION` | | Generalization | Table inheritance | `EXTENDS` | | Enumeration | Enum / Check constraint | `CREATE ENUMERATION` | ### [Entities](#entities) An **entity** defines a data type. There are several kinds: - **Persistent** – stored in the database (the default and most common) - **Non-persistent** – exists only in memory during a user session, useful for form state or temporary calculations - **View** – backed by an OQL query, like a database view ``` CREATE PERSISTENT ENTITY Sales.Customer ( Name: String(200) NOT NULL, Email: String(200), IsActive: Boolean DEFAULT true ); ``` ### [Associations](#associations) An **association** is a relationship between two entities. Think of it as a foreign key. - **Reference** – many-to-one or one-to-one (a foreign key column on the “from” entity) - **ReferenceSet** – many-to-many (a join table under the hood) ``` CREATE ASSOCIATION Sales.Order_Customer FROM Sales.Order TO Sales.Customer TYPE Reference; ``` ### [Generalization](#generalization) Entities can inherit from other entities using **generalization** (the `EXTENDS` keyword). The child entity gets all parent attributes. This is commonly used with system entities like `System.Image` (for file uploads) or `System.User` (for user accounts). ``` CREATE PERSISTENT ENTITY Sales.ProductImage EXTENDS System.Image ( Caption: String(200) ); ``` ## [Microflows and Nanoflows](#microflows-and-nanoflows) **Microflows** are the server-side logic of a Mendix app. They’re visual flowcharts in Studio Pro, but in MDL they read like imperative code with activities: - **Retrieve** data from the database - **Create**, **Change**, **Commit**, **Delete** objects - **Call** other microflows or external services - **If/Else** branching, **Loop** iteration - **Show Page**, **Log Message**, **Validation Feedback** ``` CREATE MICROFLOW Sales.CreateOrder( DECLARE $Customer: Sales.Customer ) RETURN Boolean BEGIN CREATE $Order: Sales.Order ( OrderDate = [%CurrentDateTime%], Status = 'Draft' ); CHANGE $Order ( Sales.Order_Customer = $Customer ); COMMIT $Order; RETURN true; END; ``` **Nanoflows** are the client-side equivalent. They run in the browser (or native mobile app) and are useful for offline-capable logic and low-latency UI interactions. They have the same syntax but fewer available activities (no database transactions, no direct service calls). ## [Pages](#pages) **Pages** define the user interface. A page has: - A **layout** – the outer frame (header, sidebar, footer) shared across pages - **Widgets** – the UI components inside the page Widgets are nested in a tree. Common widget types: | Widget | Purpose | Analogy | | --- | --- | --- | | DataView | Displays one object | A form | | DataGrid | Displays a list as a table | An HTML table with sorting/search | | ListView | Displays a list with custom layout | A repeating template | | TextBox | Text input bound to an attribute | An `` field | | Button | Triggers an action | A `