Data model with an AI assistant
In tutorial 6 you wrote a model by hand. In this tutorial an
AI assistant drafts it for you: it looks up the public Construction Kits
through the MCP server, proposes to reuse what exists, writes
the model files and compiles them with octo-ckc. You keep the decisions: you
review the draft with a checklist, and only then do you import it.
Time: about 45 minutes.
- The concepts of tutorial 6: reuse, extend or design, the files of a model, compiling and versions. The assistant writes the same files you wrote there.
- Access to the MCP server of your installation, connected as in
tutorial 4, and an MCP-capable AI client. The local
stack of getting-started installs an MCP server at
https://mcp.127-0-0-1.nip.io/mcp; its README shows how to connect a client. - The tenant id in your prompts: the tools of the MCP server work on one tenant and ask for its id. Either
name the tenant in the first prompt (
Work in tenant <tenant>., as in step 1) or connect the client tohttps://mcp.<your-domain>/<tenant>/mcp, which fixes the tenant. - An AI client that can also run shell commands in your working folder, so that it can call
octo-ckcitself. If yours cannot, run the compile commands yourself and paste the output back into the chat. octo-ckcandocto-cli3.5.0 or newer, as in tutorial 6, and a local or test tenant.
The assistant can be wrong, and a compiling model is not yet a good model. The compiler checks syntax and references, not whether the model makes sense. Import only after your own review (step 5), and only into a local or test tenant.
How the pieces fit
The MCP server reads the data model: which models and types exist and what
their attributes are. It has no tool that compiles a model; that is octo-ckc on your machine.
The server can import a model into a tenant, but you decide when.
Which tools read and which write
Every tool has a risk class (get_tool_risk_metadata). Approve calls in your client accordingly.
| Tool | What it does | Risk |
|---|---|---|
get_available_models, search_types, get_type_schema, get_association_tree | Look up installed models, search types, read the schema of a type | Low, read-only |
list_ck_catalogs, list_ck_catalog_models, check_ck_dependencies, get_ck_library_status, check_ck_upgrade | What the catalogs offer, what an import would bring in, what is installed | Low, read-only |
prepare_file_upload | Reserves an upload slot for a file; changes no model | Low |
import_ck_from_catalog | Writes: imports a public model and its dependencies into the tenant | Medium |
import_ck_model | Writes: imports a compiled model or a zipped model folder from an uploaded file | Medium |
create_entity, import_runtime_model | Writes runtime data of the model | Medium |
fix_all_ck_models | Writes: imports everything that needs an update | High |
For this tutorial the assistant needs the read-only tools and the shell. Do not approve a Medium or High call before the review in step 5; if you want a hard stop, tell the assistant in the prompt that it must not import.
What you build
The same kind of model as in tutorial 6, but on a bigger public kit: maintenance tasks for machines. A
MaintenanceTask has a planned date, a status and a summary, and belongs to a Machine of the public
Industry.Basic kit. A good result reuses Machine and does not invent a machine type of its own.
Step 1: Ground the assistant and ask for reuse first
An assistant that does not look things up invents type names. The first prompt therefore forces a lookup and a decision before any file is written. Copy it, change the domain sentence and send it:
You help me design a Construction Kit model for OctoMesh. Work in tenant <tenant>.
Task: maintenance tasks for machines.
Each task has a planned date, a status (planned, in progress, done) and a short summary, and
belongs to one machine.
Rules:
1. Before you propose anything, use the OctoMesh tools: list the available models, search the
types for "machine" and "maintenance", and read the schema of every type you want to reuse.
Use only model names, type names, attribute names and versions that the tools returned.
2. Propose reuse first. Give me a table with three columns: types you reuse, types you extend,
types you create. Explain each new type in one sentence. Then stop and wait for my OK.
3. Do not write files, do not compile and do not import anything yet.
What to expect: the assistant calls read-only tools such as get_available_models, search_types and
get_type_schema, and answers with a table. Check the table before you answer:
- It names
Industry.Basic/Machine(or a type derived from the publicBasic/Asset) for the machine and does not create a machine type of its own. - Every model and type it mentions exists. Look it up yourself in the library reference if in doubt.
- It lists new types only for what is really new here: the maintenance task and its status.
Step 2: Refine and let it write the files
Answer the proposal, correct it where it is wrong, and then release the next step:
OK, with these changes: <your corrections, for example "the status is an enum, not a string">.
Now write the model into maintenance/ConstructionKit with one YAML file per element kind:
ckModel.yaml, enums/, attributes/, associations/ and types/, all in the language of the public
models. Use a dependency range for each model you reference, for example Basic-[2.4,3.0).
Name the model Tutorial.Maintenance, version 1.0.0. Then compile it with
`octo-ckc -c Compile -p maintenance/ConstructionKit -o maintenance/out` and show me the result.
Do not import anything.
A good result looks like the following model, which was compiled with octo-ckc for this tutorial. Your
assistant's draft will differ in details; that is fine as long as it passes the checklist.
ckModel.yaml:
$schema: https://schemas.meshmakers.cloud/construction-kit-meta.schema.json
modelId: Tutorial.Maintenance-1.0.0
description: Maintenance tasks for machines, built on the public Industry.Basic Construction Kit.
dependencies:
- Basic-[2.4,3.0)
- Industry.Basic-[2.6,3.0)
enums/maintenance.yaml:
$schema: https://schemas.meshmakers.cloud/construction-kit-elements.schema.json
enums:
- enumId: MaintenanceStatus
values:
- key: 0
name: Planned
- key: 1
name: InProgress
- key: 2
name: Done
attributes/maintenance.yaml:
$schema: https://schemas.meshmakers.cloud/construction-kit-elements.schema.json
attributes:
- id: PlannedFor
valueType: DateTime
description: Date for which the maintenance task is planned.
- id: MaintenanceStatus
valueType: Enum
valueCkEnumId: ${this}/MaintenanceStatus
description: Progress of the maintenance task.
- id: Summary
valueType: String
description: Short description of the work to be done.
associations/maintenance.yaml:
$schema: https://schemas.meshmakers.cloud/construction-kit-elements.schema.json
associationRoles:
- id: MaintenanceOfMachine
inboundName: MaintenanceTasks
inboundMultiplicity: N
outboundName: MaintainedMachine
outboundMultiplicity: One
types/maintenance.yaml:
$schema: https://schemas.meshmakers.cloud/construction-kit-elements.schema.json
types:
- typeId: MaintenanceTask
description: One planned or executed maintenance task of a machine.
derivedFromCkTypeId: ${Basic}/NamedEntity
attributes:
- id: ${this}/PlannedFor
name: PlannedFor
- id: ${this}/MaintenanceStatus
name: Status
- id: ${this}/Summary
name: Summary
isOptional: true
associations:
- id: ${this}/MaintenanceOfMachine
targetCkTypeId: ${Industry.Basic}/Machine
The machine is the public Industry.Basic/Machine, reached through the dependency alias
${Industry.Basic}. The new model owns only what is new: one enum, three attributes, one association
and one type.
Step 3: Compile, and fix errors with the assistant
The assistant should have compiled the model itself. Run the command yourself once, so that you see the result with your own eyes:
octo-ckc -c Compile -p maintenance/ConstructionKit -o maintenance/out
A successful compile ends with Construction kit model directory compiled and writes
maintenance/out/ck-tutorial.maintenance.yaml. If it fails, paste the complete error output into the chat:
The compiler reports errors. Here is the complete output:
<paste the output>
Fix the model files. Before you change a type, attribute or version name, look it up with the
OctoMesh tools again. Do not guess names. Compile again and show me the result. Do not import.
The errors that AI drafts typically run into, with the messages octo-ckc prints:
| What went wrong | Message (shortened) |
|---|---|
A type that does not exist was invented, here Pump instead of Machine | CkTypeId 'Tutorial.Maintenance-1.0.0/MaintenanceTask-1' defines a unknown target CkTypeId 'Industry.Basic-2.6.0/Pump-1' for role id '...'. The type 'Pump' does not exist in model Industry.Basic-2.6.0. Did you mean 'Machine'? |
A real type of the wrong model, here ${Basic}/Machine (Machine is in Industry.Basic) | ... unknown target CkTypeId 'Basic-2.5.0/Machine-1' ... The type 'Machine' does not exist in model Basic-2.5.0, but a type of that name exists in Industry.Basic-2.6.0. Check the model prefix of the reference. |
A version that does not exist, here Industry.Basic-[9.0,10.0) | Dependencies 'Industry.Basic-[9.0,10.0)' are unknown construction kit model libraries: ... does not match any visible version of Industry.Basic (...) |
A dependency that is missing in ckModel.yaml | ... unknown target CkTypeId '${Industry.Basic}/Machine-1' ... This may happen because a dependency to another construction kit model is missing. |
| An attribute used but not defined | CkAttributeId 'Tutorial.Maintenance-1.0.0/Description2-1' of CkTypeId '...' does not exist. |
| An enum that does not exist | CkAttributeId '...' uses unknown CkEnumId 'Tutorial.Maintenance-1.0.0/MaintStatus-1'. |
A value type that does not exist, here Date | Schema validation failed at '/attributes/0/valueType'->'Value should match one of the values specified by the enum. ... Value: "Date"' |
A multiplicity in the wrong case, here one | Schema validation failed at '/associationRoles/0/outboundMultiplicity' ... Value: "one"' |
The first four are the dangerous ones: they come from names the assistant did not look up. A fix that silently replaces the invented name with another invented name just moves the error. That is why the prompt above demands a new lookup.
Step 4: Refine the model
Review and change are the same loop as in step 2. Typical follow-up prompts:
Add an optional attribute "Technician" (string) to MaintenanceTask. Which version number does the model
need now? Explain with the versioning rules, then change ckModel.yaml and compile.
Compatible additions raise the minor version (1.1.0); the rules are in the
versioning rules, and the pitfall of a rebuild
without a new version is described in tutorial 6.
Step 5: Review with the checklist
Do not import before every point is checked. The compiler does not check these.
Reuse and naming
- Every thing that exists in a public kit is reused, not rebuilt: machines, assets, employees, places, documents. Compare with tutorial 6.
- The model name says what it is (for example
Tutorial.Maintenance), has no spaces, and is not the name of a public model. - Type, attribute and enum names are PascalCase, singular, and meaningful without the model name.
- No type, attribute, model or version appears that you cannot find in the library reference or in a tool result.
Attributes
- Each attribute has the right value type: dates are
DateTime, notString; closed lists are enums, not free text; numbers are numbers. - Attributes are required only when every entity really has them. Everything else says
isOptional: true. Check the required attributes of the reused types too:Industry.Basic/MachinerequiresMachineState, so every machine you create needs one. - No attribute duplicates one that the base type already has.
Associations
- Every relation is an association role with sensible names in both directions.
- The multiplicities are right (
One,ZeroOrOne,N): a task belongs to exactly one machine, a machine has many tasks. - The target of an association is the most general public type that fits (here
Machine, not a type of your own).
Versions
- The first version is
1.0.0; every later change raises the version as the versioning rules say. Same version again means invisible. - Dependencies use ranges (
Basic-[2.4,3.0)), not exact versions, and list every model the files refer to.
What the model must not contain
- No secrets and no real values. Credentials, tokens and passwords never go into descriptions,
default values or seed data. An attribute that holds a credential has the value type
Secret(the model then must depend onSystem-[2.5.0,3.0), otherwise the compiler stops with error 75); see Blueprint ownership. - No customer names, personal data or internal host names in descriptions or examples.
- No data in the model. Instances are runtime entities, not part of a Construction Kit.
Step 6: Import
After the review, import into your local or test tenant exactly like in tutorial 6. The public kits must be in the tenant first:
octo-cli -c ImportFromCatalog -cn PublicGitHubCatalog -m Industry.Basic-2.6.0 -w
octo-cli -c ImportCk -f maintenance/out/ck-tutorial.maintenance.yaml -w
octo-cli -c LibraryStatus -io
Industry.Basic brings its dependency Basic with it, and LibraryStatus should list Tutorial.Maintenance
as Available.
If your MCP server offers file transfer, the assistant can import for you with
prepare_file_upload, an HTTP PUT of the file and import_ck_model; see the
tool reference.
Do not send a form content type: curl --data-binary sends application/x-www-form-urlencoded by default, and the
server then reads the body as a form, so the upload fails or arrives empty. Set an explicit Content-Type such as
application/x-yaml; with curl:
curl -X PUT -H "Content-Type: application/x-yaml" --data-binary @maintenance/out/ck-tutorial.maintenance.yaml <upload-url>.
The transferId is the only protection of the file transfer: treat it like a secret, do not paste it
into chats or tickets; it expires after 30 minutes and an upload can be used once. Approve the Medium-risk
import call yourself, after the review.
Limits
- The assistant can be wrong. It can invent names, mix up versions or choose a type that only looks similar. Tool lookups reduce this, they do not remove it.
- Two checks, both required. The compiler validates structure and references, you validate meaning with the checklist. A model that compiles can still be a bad model.
- Never import unreviewed into a shared tenant. A published version cannot be changed, and importing a wrong model costs a version number and a migration.
- The assistant works with your rights. The MCP server forwards your identity (see tutorial 4). Keep the approval prompts of your client switched on for Medium and High risk tools.
Typical pitfalls
- The first answer already contains files. The assistant skipped the lookup. Say: "Stop. Look up the models and types with the OctoMesh tools first, then propose."
- The tools ask for a tenant id. Name the tenant in the prompt or connect to
https://mcp.<your-domain>/<tenant>/mcp. - The file upload fails or arrives empty.
curlsends a form content type by default. Set an explicitContent-Typeon thePUT(-H "Content-Type: application/x-yaml"). - A new type duplicates a public one. Ask: "Which public type is closest? Derive from it or reuse it."
- Compile errors that return after every fix. Ask for a fresh lookup of the exact names, or fix the one line yourself; the error message names the file.
- Versions wander. Fix the model name and version in the prompt, as in step 2.
- The assistant reports success without compiling. Run
octo-ckc -c Compileyourself and look forConstruction kit model directory compiled.
Summary
- Let the assistant look up before it writes: the first prompt asks for a lookup and a reuse proposal and then stops.
- The MCP server reads the model landscape;
octo-ckccompiles; you review and import. - The typical errors come from invented names and versions. The compiler finds them, and the fix prompt asks for a new lookup.
- Review with the checklist (reuse, naming, types, multiplicities, versions, no secrets) before you import, and only into a local or test tenant.
Next: back to tutorial 6 for the details of the model files, or on to the technology guide for Construction Kits.