Skip to content

Change the schema

Add, change and remove collections through MCP, with a preview before anything is applied.

The schema is the list of your app's collections and the fields in each one. Two tools read and change it: get_schema and change_schema. A third, undo_schema_change, takes back the last change.

What a collection looks like#

A collection has a name, a set of fields, a list of required fields, and two switches that control guest access.

A collection definition
{"name":"ContactMessage","properties":{"name":{"type":"string","maxLength":120},"email":{"type":"email"},"message":{"type":"text"},"status":{"type":"enum","values":["new","answered"]}},"required":["email","message"],"publicRead":false,"publicCreate":true}
namestringrequired

The collection name, for example ContactMessage.

propertiesobject

The fields, keyed by field name. Each one has a type and, depending on the type, extra options.

requiredarray of strings

The names of the fields a record must have.

publicReadboolean

Guests may read records without signing in.

publicCreateboolean

Guests may create records without signing in. This is what a public form needs.

Field types#

A field's type is one of string, text, number, integer, boolean, date, datetime, enum, relation, array, object, email, phone or url.

Three types take an extra option:

TypeOptionWhat it sets
stringmaxLengthThe longest value allowed
enumvaluesThe list of allowed values
relationrefThe collection the field points to

Preview, then apply#

  1. Ask for the plan

    Call change_schema with the collection and without apply. The response lists each change with its kind and the number of records it affects. Nothing has changed yet.

  2. Read the plan

    The assistant shows you what would change. This is the moment to catch a field that was left out by mistake.

  3. Apply

    Call change_schema again with apply set to true. An additive change, such as a new collection or a new optional field, goes through. A breaking or security change also needs user_confirmed.

Changes that need your confirmation#

These changes are applied only with user_confirmed set to true, and the assistant sets it only after you agree in the conversation:

  • Changing a field's type
  • Removing a field
  • Making an existing field required
  • Turning on publicRead or publicCreate

Remove a collection#

Pass remove_collection with the collection's name instead of collection. The collection leaves the schema. Its records stay.

Undo the last change#

undo_schema_change puts back the schema from before the last change_schema. Records that were converted by that change stay converted.