Most CMS projects define content types in C#. The CMS 13 MCP server adds a second way: an agent calls paas_cms_create_content_type and the type lands in the database with no class behind it. Both routes write to the same tblContentType table. In any project where someone points an agent at a dev site, the two will overlap sooner or later, so I tested what actually happens.
The short version: the CMS never merges an MCP type with a code-first type by name. It creates a twin, and the MCP tools keep editing the one your code ignores.
Test setup
- CMS 13.5.1, .NET 10, Alloy MVC template, SQL Server, no Opti ID
Optimizely.Cms.Opal.Tools13.4.1 with client secret authentication, wired up as in my previous post on MCP property write outcomes- Block types only, one run of each scenario, everything prefixed
Mcpso it is easy to find
I read the database directly after each step. Everything below about tblContentType and tblPropertyDefinition comes from those queries, not from the MCP tools, because the tools hide most of it.
The guard: code-managed types
When a type is bound to a C# class, the update and delete tools refuse to touch it:
Content type is code-managed: Content type 'McpCfCode' is defined in code
and cannot be updated through Opal.
Delete returns the same message. The text still says Opal. This guard is the right idea, but as the next section shows, it only protects a type that is bound to a class.
Scenario 1: a class with the same name
An agent created McpCfAdopt through MCP with four properties. Later a developer adds a class with the same name and no GUID in the attribute:
[ContentType(DisplayName = "McpCfAdopt (code)")]
public class McpCfAdopt : BlockData
{
[Display(Name = "Heading (code)")]
public virtual string Heading { get; set; }
public virtual XhtmlString Body { get; set; }
public virtual string Mismatch { get; set; }
public virtual string CodeOnly { get; set; }
}
On startup the CMS created a second type, McpCfAdopt_1, and left the MCP one alone. The only trace in the log is an Information line:
info: EPiServer.DataAbstraction.RuntimeModel.Internal.ContentTypeSynchronizer
Created content type 'McpCfAdopt_1'
The same thing happened when the class carried a new explicit GUID and the same name (McpCfNewGuid became McpCfNewGuid_1). Both keys now appear in paas_cms_list_content_types, with nothing to say which one has a class. The key the MCP tools use is the database name, so your code type is McpCfAdopt_1 from the agent's point of view, not McpCfAdopt.
What an agent does with the twin
I asked for an update on key McpCfAdopt. It succeeded, and it changed only the MCP copy. The guard did not fire because that type has no class. An agent that was asked to "add a property to McpCfAdopt" reports success, and your code never sees the change.
Creating content works the same way. An item lands on exactly the type key you name, and the two types behave differently:
| Created through key | Heading stored as | Heading with 300 characters |
|---|---|---|
McpCfAdopt (MCP type) | String | item created, property rejected (255 character limit) |
McpCfAdopt_1 (class type) | LongString | written |
The cause is the type mapping. A C# string becomes LongString, while the MCP type name string becomes the 255 character String. The property is called Heading on both types, so an agent has no hint that the limits differ.
The property sets differ as well. CodeOnly does not exist on the MCP copy and McpOnly does not exist on the class type, so a write to the wrong one fails with Property not found. The required check on the MCP copy names the caption, not the property: Property 'Heading (MCP)' is required.
Two more details. Items created before the class existed stay where they are: all 19 stored values on my McpTestAll item remained on the MCP type, and the new McpTestAll_1 had none. And a create that fails on a property still leaves an empty item behind, as I covered in the previous post. I did not test how the site renders an item of the MCP copy, which has no class to bind a controller or view to.
Scenario 2: adopting the MCP type by GUID
The way to attach a class to an existing MCP type is to give the attribute that type's GUID. The MCP tools do not return it, so read it from the database:
SELECT Name, ContentTypeGUID
FROM tblContentType
WHERE CreatedBy = 'MCP Client'
ORDER BY Name
[ContentType(DisplayName = "McpCfGuid", GUID = "6df5fe67-7ed4-41eb-b01c-ba530e7202ae")]
public class McpCfGuid : BlockData
{
public virtual string Heading { get; set; }
public virtual string Title { get; set; }
}
This time there was no twin. The log said Updated content type 'McpCfGuid', and the guard started rejecting MCP edits. The two definitions were merged in place:
| Property | In MCP | In the class | After adoption |
|---|---|---|---|
Heading | String, caption "Heading (MCP)" | string | LongString, caption "Heading (MCP)" kept |
Title | not defined | string | added, LongString |
McpOnly | String | not defined | kept, flagged ExistsOnModel = 0 |
A write to McpOnly still worked after adoption, even though the class has no such property. The value was stored as a String next to the class properties. I did not test whether existing data survives the String to LongString change on Heading, because my test type had no items.
One oddity I cannot explain: for both adopted types the DisplayName column in tblContentType went blank. For McpTestDiscardBlock, get_content_type_details still reported the class display name.
Scenario 3: the class goes away, then comes back
I deleted a class and restarted. In most cases the type row stayed, and so did its content. The exception was McpTestAll_1, a class type with no content, which was gone after the restart. Another empty class type, McpCfNewGuid_1, survived the same restart, and I could not tell why. With the class gone, the guard no longer applied: an update on McpCfCode succeeded, and a delete of McpCfDelete (no instances) succeeded and removed the type. A code-first type with no class behaves like any other MCP type.
Properties were treated differently depending on whether they held data:
- The property with no data (
WipedByHandler) disappeared on the first restart after its class was deleted. - The three properties that held data stayed in the database.
get_content_type_detailskept listing them with nothing to mark them as no longer on the class. TitleandAmountonMcpCfCode, which never held data, were also gone after I removed that class. That check overlaps with one MCP edit I made after the restart, so I treatWipedByHandleras the clean observation.
When I put a class back with the same GUID, the CMS reused the row, logged Updated content type 'McpTestDiscardBlock', added the new property, and kept all six data rows. The guard applied again.
Finding the damage
Twins are easy to find because the CMS appends _1 to the name and CreatedBy still says MCP Client on the original:
SELECT a.Name AS McpType, a.ContentTypeGUID AS McpGuid,
b.Name AS CodeType, b.ContentTypeGUID AS CodeGuid
FROM tblContentType a
JOIN tblContentType b ON b.Name = a.Name + '_1'
WHERE a.CreatedBy = 'MCP Client'
ORDER BY a.Name
On my database this returned three pairs. The same query would also match any two types where an unrelated type happens to end in _1, so read the results before you act on them.
For properties that are no longer on a class:
SELECT ct.Name AS TypeName, pd.Name AS PropertyName
FROM tblPropertyDefinition pd
JOIN tblContentType ct ON ct.pkID = pd.fkContentTypeID
WHERE pd.ExistsOnModel = 0 AND ct.Version <> ''
ORDER BY ct.Name, pd.Name
Treat this as a hint, not a verdict. It listed McpTestDiscardBlock.Normal even after the class returned with a Normal property, so the flag is not refreshed for properties that already existed. It also listed BlankExperience.MetaDescription, a leftover from the Alloy template. CreatedBy is not cleared on adoption either, so McpCfGuid still shows as an MCP type.
What I would do
- Give each type one owner. In a code-first project, use the MCP server for content and leave type creation to developers.
- If an agent has to bootstrap a type that will later move to code, copy the GUID from the database into the attribute before you add the class. Matching the name alone creates a twin.
- After any deployment that adds classes, run the twin query. A list of pairs means an agent may be editing the wrong type.
- Tell agents that a rejected update on one key is not a reason to try the key with or without the
_1suffix. That is how the twin gets edited. - Do not treat a successful type edit as proof that your code changed. It only proves the database row did.
Limits of these tests
- Block types only. Pages and media types may differ.
- One run of each scenario on one machine, package 13.4.1 on CMS 13.5.1.
- I did not test rendering of content on the MCP copy, how the edit UI shows the pairs, or what happens to existing data when a property changes from String to LongString.
- Creating content with the client secret needed a
CmsAdminsaccess row on Root, as described in the previous post. - I do not know why the display name column goes blank on adoption.
The three class files I used, and a snapshot of the type tables after each step, are small enough to reproduce on any Alloy site in an afternoon.