KentiCopilot with the Management API MCP server generated 31 C# files for me... what have you tried?

The IContentTypesFilter interface, which lets developers limited allowed content types in the Combined content selector, requires specifying the Guid identifiers of all content types you want to allow:

public interface IContentTypesFilter
{
    //
    // Summary:
    //     Provides GUID identifiers of allowed content item types.
    IEnumerable<Guid> AllowedContentTypeIdentifiers { get; }
}

In the past I would grab a Guid from the database and hardcode it in any filter classes I created:

SELECT ClassGUID
FROM CMS_Class
WHERE ClassName = 'MyApp.ContentTypeName'

Not a good practice. It's manual, requires comments to explain what the value represents, and isn't scalable across many content types.

But, Xperience's code generation doesn't include the ClassGuid in the generated C# classes. 🤷

Well, KentiCopilot gives us access to the Management API MCP server which I told my agent to use with the following prompt:

use the xperience management api mcp server to

  • get list of all reusable and page content types and their Class GUID values
  • go through src\App\ContentTypes\ReusableContentTypes and src\App\ContentTypes\PageContentTypes and add partial classes for each type in the same location as the generated code partial class
  • the new partial class should follow C# partial class requirements (ex: be in the same namespace)
  • add a new public static Guid CONTENT_TYPE_GUID { get; } = new Guide("<ClassGUIDValue>"); with the value coming from the content type MCP server response(s)

The agent generated 31 class files that looked like this in about 2 minutes:

namespace App;

public partial class ProductCoffee
{
    /// <summary>
    /// Unique identifier (GUID) of the ProductCoffee content type.
    /// </summary>
    public static Guid CONTENT_TYPE_GUID { get; } = new Guid("fabc3c81-299c-4880-838f-ea123dd4131a");
}

I can now easily use these in a content type filter implementation:

public class ProductTypesFilter : IContentTypesNameFilter, IContentTypesFilter
{
    private static readonly string[] ContentTypeNames =
    [
        ProductCoffee.CONTENT_TYPE_NAME,
        ProductGrinder.CONTENT_TYPE_NAME,
        ProductClothing.CONTENT_TYPE_NAME
    ];

    private static readonly Guid[] ContentTypeGuids =
    [
        ProductCoffee.CONTENT_TYPE_GUID,
        ProductGrinder.CONTENT_TYPE_GUID,
        ProductClothing.CONTENT_TYPE_GUID
    ];

    public IEnumerable<string> AllowedContentTypeNames => ContentTypeNames;
    public IEnumerable<Guid> AllowedContentTypeIdentifiers => ContentTypeGuids;
}

I wouldn't have ever done this manually in the past because it would take too long and be difficult to maintain.

I think this is a great use-case for KentiCopilot!

What have you tried using it for? Any creative ideas you would suggest others try?

Environment

  • Xperience by Kentico version: [31.1.0]

  • .NET version: 10

Tags:
KentiCopilot C# MCP Software development
0

Answers

Interesting exploration idea. Though I'd have done this differently: if you use CI/CD you already have this info in your code repository, so there's no need to call this through MCP 😉

I think it is a good idea for Kentico to include it into code generation next to CONTENT_TYPE_NAME

On the projects where I'm involved as an architect, I'm using this Management API to validate the existing schema against new requirements for reuse of existing types and extraction of schemas rather than introducing new types every time.

1

if you use CI/CD you already have this info in your code repository, so there's no need to call this through MCP 😉

There's been a lot of recent discussions about AI agents and their use of CLI/code tools vs MCP servers.

I might normally tell the agent to get the data from the filesystem (CI repository) but because that file structure and the file XML structure is undocumented (it's effectively the database on the filesystem), I find AI agents are not that skilled at navigating and working with it.

I already had the content type MCP server available in the project, so I didn't need to validate the AI agent got the correct GUID identifiers.

But, if Xperience's documentation is ever updated to detail how the repo is structured, I probably could rely entirely on the file system!

I'm using this Management API to validate the existing schema against new requirements for reuse of existing types and extraction of schemas rather than introducing new types every time.

That's a great idea! I've seen many projects which just create "another CTA" content type because teams are unsure how the existing types are designed or used.

0

To response this discussion, you have to login first.