Create an MView with an AI agent
Navigable guide for AI models to generate conformant MViews by accessing structured documentation.
Create an MView with an AI agent
This page is designed to be navigable by AI models. It is not self-contained: it guides you through the structured documentation so you can generate a conformant MView.
For AI models: how to use this page
When a user asks you to create an MView (e.g., "Create a mutation of this sales.csv file showing me charts by sales quantity per month"), follow this flow:
1. Understand what an MView is
Read first: /specs/mview/overview
This will give you:
- The conceptual model (source file → parser → data model → component → view)
- Design invariants (never modifies the original file, pure parser, component with no I/O)
- File structure (
mview.json, parser, component,resources/)
2. Identify required capabilities
Consult: /specs/mview/capabilities
Based on the source file type:
- CSV/XLSX/tabular →
["table"] - Markdown →
["markdown", "document"] - JSON/YAML/XML →
["tree", "structured"] - Logs →
["log", "text"] - Source code →
["code", "text"]
Each capability defines the normalized input shape that the runtime will deliver to the parser.
3. Build the mview.json manifest
Full reference: /specs/mview/schema-reference
JSON Schema: https://schemas.carmenlabs.com/mview/v1/schema.json
Required fields:
$schema: always"https://schemas.carmenlabs.com/mview/v1/schema.json"id: unique identifier in kebab-case (pattern:^[a-z0-9][a-z0-9._-]*$)name: human-readable nameversion: semverMAJOR.MINOR.PATCHprompt: the user prompt that originated this MViewruntime: object withenvironment,renderer, and optionallyversionentry: object withparserandcomponent(relative paths)
Common optional fields:
description: one-line summaryaccepts: array of required capabilitiessource: object withpath(relative) and optionallycontentHashresources: object withpathto assets directorysettings: initial configuration that affects renderingmetadata: provenance (who, when, with what model)
Critical rules:
- All paths must be relative, never absolute
additionalProperties: falseat all levelssettingsmay affect rendering,metadatamust never do so
4. Write the parser
Full contract: /specs/mview/parser-contract
Signature:
export default async function parse(input: any, context: any) {
// Return a JSON-serializable data model
}input: normalized data according to the capability declared inacceptscontext: object with{ input, source, settings, resources, workspace }- Must be a pure function: same input → same output
- No filesystem access, no absolute paths
- Safely re-runnable when the source file changes
5. Write the view component
Full contract: /specs/mview/component-contract
Signature:
export default function Component({ data, settings, source, resources }: any) {
// Render only `data` and `settings`
}- Renders only the received data model
- No direct file reads
- No arbitrary
fetchcalls - Degrade gracefully on missing data
6. Validate before delivering
Checklist:
-
mview.jsonvalidates against the JSON Schema - All paths are relative
-
acceptsmatches the source file type - Parser returns data that the component expects
- No
additionalPropertiesoutside the schema
7. Directory structure
Recommended convention: /specs/mview/directory-layout
Option 1 (next to file):
sales.csv
.mviews/
└── sales-dashboard/
├── mview.json
├── parser.ts
├── Dashboard.tsx
└── resources/
Option 2 (centralized):
.mviews/
└── sales-dashboard/
├── mview.json
├── parser.ts
├── Dashboard.tsx
└── resources/
Full worked example
See: /examples/sales-dashboard
Shows a real case with CSV file, complete manifest, functional parser, and React component.
Specification navigation
To dive deeper into specific aspects:
- Security model: sandboxing, permissions, regeneration
- Versioning: schema vs. MView,
/mview/v1/URL scheme - Prompt logs: how to log regenerations
Canonical schema
Validate manifests directly against:
https://schemas.carmenlabs.com/mview/v1/schema.json
Do not hardcode local copies that may become outdated.
Recommended workflow for models
- Read
/specs/mview/overviewto understand the model - Consult
/specs/mview/capabilitiesto identifyaccepts - Reference
/specs/mview/schema-referenceto buildmview.json - Follow
/specs/mview/parser-contractto write the parser - Follow
/specs/mview/component-contractto write the component - Validate against the JSON Schema before delivering
- Review
/examples/sales-dashboardif you need a concrete example
This structure allows you to navigate the documentation according to what you need, instead of processing everything at once.