Skip to content
Star -

Prompt Schema

Related Topics: Endpoints (prompt concepts) | Type System (parameter types)

This reference documents the complete YAML schema for prompt definitions in MXCP.

mxcp: 1
prompt:
name: analyze_data
description: Analyze data with customizable focus areas
tags:
- analysis
- data
parameters:
- name: topic
type: string
description: The topic or dataset to analyze
examples: ["sales trends", "user behavior", "performance metrics"]
- name: focus_areas
type: array
description: Specific areas to focus the analysis on
items:
type: string
default: []
- name: output_format
type: string
description: Desired output format
enum: ["summary", "detailed", "bullet_points"]
default: "summary"
messages:
- role: system
type: text
prompt: |
You are an expert data analyst. Provide clear, actionable insights.
{% if focus_areas %}
Focus particularly on: {{ focus_areas | join(', ') }}
{% endif %}
- role: user
type: text
prompt: |
Please analyze the following topic: {{ topic }}
Provide your analysis in {{ output_format }} format.
tests:
- name: basic_analysis
arguments:
- key: topic
value: "quarterly sales"
result_contains_text: "analysis"
enabled: true
FieldTypeRequiredDefaultDescription
mxcpintegerYes-Schema version. Must be 1.
promptobjectYes-Prompt definition object.
metadataobjectNo-Custom metadata (not processed by MXCP).

Note: The mxcp field accepts both integer (1) and string ("1") values - strings are automatically coerced to integers.

FieldTypeRequiredDefaultDescription
namestringYes-Unique identifier. Must start with letter/underscore, alphanumeric only.
descriptionstringNo-Human-readable description for AI clients.
tagsarrayNo-List of tags for categorization.
parametersarrayNo-Template parameter definitions.
returnobjectNo-Return type definition.
messagesarrayYes-Message sequence with Jinja2 templates.
policiesobjectNo-Input and output policy rules.
testsarrayNo-Test case definitions.
enabledbooleanNotrueWhether the prompt is enabled.

Messages define the conversation structure.

FieldTypeRequiredDefaultDescription
promptstringYes-Text content with Jinja2 templates, or resource URI when type: resource.
rolestringNo-Message role: system, user, or assistant.
typestringNo-Content type: text or resource.
messages:
- role: system
type: text
prompt: "You are a helpful assistant specialized in {{ domain }}."
- role: user
type: text
prompt: "{{ user_query }}"

Embed resource content directly into prompts by setting type: resource and putting the URI in the prompt field:

messages:
- role: system
type: text
prompt: "You are a code reviewer."
- role: user
type: resource
prompt: "file://{{ file_path }}"
- role: user
type: text
prompt: "Please review the code above for {{ review_focus }}."

Note: When type: resource, the prompt field contains the resource URI instead of text content.

messages:
- role: system
type: text
prompt: "You are a technical interviewer."
- role: user
type: text
prompt: "I'd like to discuss {{ topic }}."
- role: assistant
type: text
prompt: "I'd be happy to discuss {{ topic }}. Let me start with a question."
- role: user
type: text
prompt: "{{ candidate_response }}"

Prompts support Jinja2 templating for dynamic content.

prompt: "Analyze {{ topic }} for {{ time_period }}."
prompt: |
{% if include_examples %}
Here are some examples:
{{ examples | join('\n') }}
{% endif %}
Now analyze: {{ query }}
prompt: |
Review the following items:
{% for item in items %}
- {{ item.name }}: {{ item.description }}
{% endfor %}

Common Jinja2 filters:

FilterDescriptionExample
upperConvert to uppercase{{ text | upper }}
lowerConvert to lowercase{{ text | lower }}
titleConvert to titlecase{{ text | title }}
trimStrip leading/trailing whitespace{{ text | trim }}
defaultProvide fallback for undefined{{ value | default('N/A') }}
joinJoin array elements with separator{{ items | join(', ') }}
lengthGet array/string length{{ items | length }}
firstGet first element{{ items | first }}
lastGet last element{{ items | last }}
replaceReplace substring{{ text | replace('old', 'new') }}
sortSort an iterable{{ items | sort }}
prompt: |
{% set priority_label = {
'high': 'URGENT',
'medium': 'Standard',
'low': 'When possible'
} %}
Task: {{ task_name }}
Priority: {{ priority_label[priority] | default('Unknown') }}
{% if context %}
Context:
{{ context }}
{% endif %}
{% if constraints %}
Constraints:
{% for constraint in constraints %}
- {{ constraint }}
{% endfor %}
{% endif %}
Please provide your response.

Each parameter defines an input to the prompt template.

FieldTypeRequiredDefaultDescription
namestringYes-Parameter identifier (snake_case).
typestringYes-Data type: string, integer, number, boolean, array, object.
descriptionstringNo-Human-readable description.
defaultanyNo-Default value (makes parameter optional).
examplesarrayNo-Example values for documentation.
enumarrayNo-Allowed values.

String constraints:

FieldTypeDescription
minLengthintegerMinimum string length.
maxLengthintegerMaximum string length.
patternstringRegex pattern to match.
formatstringFormat hint: email, uri, date, time, date-time, duration, timestamp.

Number/Integer constraints:

FieldTypeDescription
minimumnumberMinimum value (inclusive).
maximumnumberMaximum value (inclusive).
exclusiveMinimumnumberMinimum value (exclusive).
exclusiveMaximumnumberMaximum value (exclusive).
multipleOfnumberValue must be multiple of this.

Array constraints:

FieldTypeDescription
itemsobjectType definition for array items.
minItemsintegerMinimum array length.
maxItemsintegerMaximum array length.
uniqueItemsbooleanWhether items must be unique.

Object constraints:

FieldTypeDescription
propertiesobjectMap of property names to type definitions.
requiredarrayList of required property names.
additionalPropertiesbooleanWhether extra (unspecified) object properties are accepted and preserved. Default: true (if omitted). Use false to reject unknown keys.

Note: If additionalProperties is omitted, MXCP treats it as true (extra keys are allowed and preserved). Set additionalProperties: false to forbid unknown keys.

# Allow unknown keys (default behavior)
type: object
properties:
objid:
type: integer
required: ["objid"]
# Forbid unknown keys
type: object
properties:
objid:
type: integer
required: ["objid"]
additionalProperties: false
parameters:
# Required string
- name: query
type: string
description: The user's question or request
minLength: 1
maxLength: 10000
# Optional with default
- name: tone
type: string
description: Response tone
enum: ["formal", "casual", "technical"]
default: "formal"
# Array parameter
- name: topics
type: array
description: Topics to cover
items:
type: string
minItems: 1
maxItems: 10
# Object parameter
- name: context
type: object
description: Additional context
properties:
user_role:
type: string
preferences:
type: array
items:
type: string

Define the expected structure of the prompt’s output:

return:
type: object
properties:
summary:
type: string
description: Brief summary of the analysis
findings:
type: array
items:
type: object
properties:
category:
type: string
insight:
type: string
confidence:
type: number
recommendations:
type: array
items:
type: string

Tests verify prompt behavior.

tests:
- name: basic_prompt
description: Test basic prompt generation
arguments:
- key: topic
value: "machine learning"
result_contains_text: "machine learning"
- name: with_options
description: Test with all options
arguments:
- key: topic
value: "data analysis"
- key: output_format
value: "detailed"
- key: focus_areas
value: ["trends", "anomalies"]
result_contains_text: "trends"
FieldTypeRequiredDescription
namestringYesUnique test identifier.
descriptionstringNoHuman-readable description.
argumentsarrayYesInput arguments as key-value pairs.
user_contextobjectNoSimulated user context for policy testing.
FieldTypeDescription
resultanyExpected exact result.
result_containsanyPartial match - fields must exist with values.
result_contains_textstringOutput must contain substring.
result_not_containsarrayField names that must NOT exist.

See Testing for complete documentation.

Policies control access and data filtering for prompts.

policies:
input:
- condition: "user.role == 'guest'"
action: deny
reason: "Guests cannot use this prompt"
output:
- condition: "user.role != 'admin'"
action: filter_fields
fields: ["internal_notes"]
reason: "Internal fields restricted"
FieldTypeRequiredDescription
conditionstringYesCEL expression to evaluate.
actionstringYesAction to take: deny, filter_fields, mask_fields, filter_sensitive_fields.
reasonstringNoHuman-readable reason.
fieldsarrayNoFields to filter/mask (for filter_fields, mask_fields).

See Policies for complete documentation.

mxcp: 1
prompt:
name: analyze_document
description: Analyze a document for key insights
parameters:
- name: document
type: string
description: The document content to analyze
- name: analysis_type
type: string
enum: ["summary", "sentiment", "key_points", "full"]
default: "summary"
messages:
- role: system
type: text
prompt: |
You are an expert document analyst.
Provide {{ analysis_type }} analysis.
- role: user
type: text
prompt: |
Please analyze the following document:
{{ document }}
mxcp: 1
prompt:
name: code_review
description: Review code for quality and issues
parameters:
- name: code
type: string
description: Code to review
- name: language
type: string
description: Programming language
- name: focus
type: array
items:
type: string
enum: ["security", "performance", "readability", "best_practices"]
default: ["best_practices"]
messages:
- role: system
type: text
prompt: |
You are an expert {{ language }} code reviewer.
Focus on: {{ focus | join(', ') }}
- role: user
type: text
prompt: |
Please review this {{ language }} code:
```{{ language }}
{{ code }}
```
mxcp: 1
prompt:
name: contextual_qa
description: Answer questions with provided context
parameters:
- name: context
type: string
description: Background information
- name: question
type: string
description: The question to answer
- name: response_style
type: string
enum: ["concise", "detailed", "eli5"]
default: "concise"
messages:
- role: system
type: text
prompt: |
Answer questions based on the provided context.
Style: {{ response_style }}
Only use information from the context.
- role: user
type: text
prompt: |
Context:
{{ context }}
Question: {{ question }}
  • Prompt names: Use snake_case (e.g., analyze_data, code_review)
  • Parameter names: Use snake_case (e.g., user_query, output_format)
  • File paths: Relative to the YAML file location

Validate your prompt definitions:

Terminal window
mxcp validate
mxcp validate prompts/my-prompt.yml