---
title: "Generate code from semantic type definitions"
method: POST
path: "/api/mcp/generate"
tags: ["Mcp"]
---

# Generate code from semantic type definitions

`POST /api/mcp/generate`

Generates production-ready code files from structured type definitions using semantic type understanding.
            
Supports 10 languages: TypeScript, Python, Go, C#, Java, Kotlin, Groovy, Scala, Swift, PHP.
            
This endpoint is used by the MetaEngine MCP Server for AI-assisted code generation via Claude Code and other MCP-compatible tools.
            
The submitted configuration is processed in memory only: it is never written to the application log.
Failures are logged as an exception type against an incident id, which is returned to the caller.

## Request body

- McpCodeConfiguration
  - `language` 'TypeScript' | 'Python' | 'Go' | 'CSharp' | 'Java' | 'Kotlin' | 'Groovy' | 'Scala' | 'Swift' | 'Php' | 'Rust'
  - `initialize` boolean, nullable
  - `packageName` string, nullable
  - `skipEnumMembersValidation` boolean, nullable
  - `typeScriptOptions` TypeScriptOptions
    - `relativeImportExtension` 'none' | 'js'
  - `classes` ClassType[], nullable
    - `name` string, nullable
    - `path` string, nullable
    - `fileName` string, nullable
    - `typeIdentifier` string, nullable
    - `isAbstract` boolean, nullable
    - `comment` string, nullable
    - `genericArguments` GenericArgumentType[], nullable
      - `name` string, nullable
      - `constraintTypeIdentifier` string, nullable
      - `propertyName` string, nullable
      - `isArrayProperty` boolean
    - `baseClassTypeIdentifier` string, nullable
    - `interfaceTypeIdentifiers` string[], nullable
    - `properties` PropertyType[], nullable
      - `name` string, nullable
      - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
      - `typeIdentifier` string, nullable
      - `type` string, nullable
      - `isOptional` boolean
      - `isInitializer` boolean
      - `comment` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
      - `commentTemplateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
      - `decorators` Decorator[], nullable
        - `code` string, nullable
        - `templateRefs` TemplateRef[], nullable
          - `placeholder` string, nullable
          - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
          - `typeIdentifier` string, nullable
    - `constructorParameters` ConstructorParameter[], nullable
      - `name` string, nullable
      - `typeIdentifier` string, nullable
      - `type` string, nullable
      - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
      - `isOptional` boolean, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
    - `customCode` CodeBlock[], nullable
      - `code` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
    - `customImports` Import[], nullable
      - `path` string, nullable
      - `types` string[], nullable
    - `decorators` Decorator[], nullable
      - `code` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
  - `interfaces` InterfaceType[], nullable
    - `name` string, nullable
    - `typeIdentifier` string, nullable
    - `path` string, nullable
    - `fileName` string, nullable
    - `comment` string, nullable
    - `genericArguments` GenericArgumentType[], nullable
      - `name` string, nullable
      - `constraintTypeIdentifier` string, nullable
      - `propertyName` string, nullable
      - `isArrayProperty` boolean
    - `interfaceTypeIdentifiers` string[], nullable
    - `properties` PropertyType[], nullable
      - `name` string, nullable
      - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
      - `typeIdentifier` string, nullable
      - `type` string, nullable
      - `isOptional` boolean
      - `isInitializer` boolean
      - `comment` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
      - `commentTemplateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
      - `decorators` Decorator[], nullable
        - `code` string, nullable
        - `templateRefs` TemplateRef[], nullable
          - `placeholder` string, nullable
          - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
          - `typeIdentifier` string, nullable
    - `customCode` CodeBlock[], nullable
      - `code` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
    - `customImports` Import[], nullable
      - `path` string, nullable
      - `types` string[], nullable
    - `decorators` Decorator[], nullable
      - `code` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
  - `enums` EnumType[], nullable
    - `name` string, nullable
    - `typeIdentifier` string, nullable
    - `path` string, nullable
    - `fileName` string, nullable
    - `comment` string, nullable
    - `members` EnumMemberType[], nullable
      - `name` string, nullable
      - `value` integer, nullable
      - `stringValue` string, nullable
  - `arrayTypes` ArrayType[], nullable
    - `typeIdentifier` string, nullable
    - `elementTypeIdentifier` string, nullable
    - `elementPrimitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
  - `dictionaryTypes` DictionaryTypes[], nullable
    - `typeIdentifier` string, nullable
    - `keyTypeIdentifier` string, nullable
    - `valueTypeIdentifier` string, nullable
    - `keyPrimitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
    - `valuePrimitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
  - `customFiles` CustomFile[], nullable
    - `name` string, nullable
    - `path` string, nullable
    - `fileName` string, nullable
    - `identifier` string, nullable
    - `customCode` CodeBlock[], nullable
      - `code` string, nullable
      - `templateRefs` TemplateRef[], nullable
        - `placeholder` string, nullable
        - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
        - `typeIdentifier` string, nullable
    - `customImports` Import[], nullable
      - `path` string, nullable
      - `types` string[], nullable
  - `concreteGenericClasses` ConcreteGenericClassType[], nullable
    - `identifier` string, nullable
    - `genericClassIdentifier` string, nullable
    - `genericArguments` GenericArgumentForConcreteImplementation[], nullable
      - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
      - `typeIdentifier` string, nullable
  - `concreteGenericInterfaces` ConcreteGenericInterfaceType[], nullable
    - `identifier` string, nullable
    - `genericClassIdentifier` string, nullable
    - `genericArguments` GenericArgumentForConcreteImplementation[], nullable
      - `primitiveType` 'String' | 'Number' | 'Boolean' | 'Date' | 'Any'
      - `typeIdentifier` string, nullable

## Response `200`

Code generated successfully. Returns array of file paths and contents with execution metrics.

- CodeGenerationResult
  - `executionTimeInMilliseconds` integer
  - `files` CodeFileResult[], nullable
    - `name` string, nullable
    - `path` string, nullable
    - `content` string, nullable
  - `warnings` string[], nullable
  - `additionalInfo` AdditionalInfo
    - `message` string, nullable, required
    - `level` string, nullable — Severity level: info, warning, or critical
    - `actionUrl` string, nullable — Optional URL for the client to act on (e.g., migration guide, changelog)

## Other responses

- `400` — Invalid configuration or validation errors
- `422` — Type limit exceeded (max 100 types per request)

---

[API](https://skmtc.dev/metaengine/apis/metaengine-api.md) · [All operations](https://skmtc.dev/metaengine/apis/metaengine-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/metaengine/metaengine-api/revisions/7bba577610ce/schema)
