Prompts
The Directus MCP Server supports stored prompts, allowing you to create reusable interactions for AI assistants. This feature is particularly useful for standardizing responses, creating guided workflows, and ensuring consistent content creation.
Setting Up Prompts
Before you can create reusable prompts and use them in your AI conversations, you need to set up a collection to store them.
Create or Configure the Collection
- Go to Settings → AI → Model Context Protocol.
- Find AI Prompts Collection.
- You have two options:
Option 1: Generate New Collection- Click "Generate AI Prompts collection..."
- This creates a new collection with all the right fields automatically.
Option 2: Use Existing Collection- Select an existing collection from the dropdown.
- Directus will validate the collection and prompt you to create any missing fields needed for prompts.
- If you approve, Directus will create the required fields for you
Creating Effective Prompts
When creating prompts in your collection, focus on these key elements:
- Name: Use a clear, descriptive name that indicates the prompt's purpose.
- Description: Include details about when and how to use the prompt.
- System Prompt: Define the role and context for the AI assistant.
- Messages: (Optional) Add predefined messages to guide the conversation flow.
Example Prompt
Here's an example of a prompt for creating blog post content:
Name: Create Blog Post
Description: Generate a blog post with specified topic and tone
System Prompt:
You are a professional content writer creating a blog post for a technology company. Maintain a helpful, authoritative tone while making complex topics accessible.
Messages:
[
{
"role": "user",
"content": "Please write a blog post about {{topic}} with a {{tone}} tone. The post should be around {{length}} words and target {{audience}}."
}
]
Dynamic Templating with Variables
Prompts support dynamic templating using double curly braces: {{variable_name}}
. This allows you to create flexible templates with placeholders that can be filled at runtime.
How Templating Works
- Define variables in your prompts using double curly braces:
Hello, {{name}}!
- When calling the prompt, provide values for these variables
- The MCP server automatically replaces the variables with the provided values
Using Variables
The {{topic}}
, {{tone}}
, {{length}}
and {{audience}}
are placeholders. When you use the prompt, you'll fill those in:
"Use the Create Blog Post prompt. Topic is 'AI in small business', tone is 'professional', length is '800', and audience is 'small business owners'."
More Complex Example
For product descriptions:
Name: Product Description
Messages:
[
{
"role": "user",
"content": "Write a product description for {{product_name}}. It's a {{category}} that {{main_benefit}}. Price is {{price}}. Target audience: {{audience}}."
}
]
Use Cases for Stored Prompts
Stored prompts are particularly useful for:
- Standardizing Content Creation: Ensure consistent formatting and style across content
- Guided Workflows: Create step-by-step processes for common tasks
- Templates: Provide reusable templates for recurring content needs
- Role-Based Interactions: Define different personas for the AI assistant based on tasks
- Compliance: Ensure content follows specific guidelines or requirements
Best Practices
When working with prompts:
- Start with a clear, specific system prompt that defines the role and context
- Use variables for elements that will change between uses
- Test prompts with different inputs to ensure they work as expected
- Organize prompts by category or purpose for easier discovery
- Update prompts regularly based on feedback and changing needs
Get once-a-month release notes & real‑world code tips...no fluff. 🐰