This feature implements the MCP Prompts specification. FrontMCP handles all protocol details automatically.
Why Prompts?
In the Model Context Protocol, prompts serve a distinct purpose from tools and resources:| Aspect | Prompt | Tool | Resource |
|---|---|---|---|
| Purpose | Provide templated instructions | Execute actions | Provide data |
| Output | Messages for the model | Execution results | Content to read |
| Arguments | Named string parameters | Typed schema inputs | URI parameters |
| Use case | Conversation templates, workflows | Side effects, mutations | Context loading |
- System instructions — reusable persona definitions, behavior guidelines
- Conversation starters — standardized ways to begin specific tasks
- Workflow templates — multi-turn interaction patterns
- Task scaffolding — structured prompts for code review, summarization, translation
- Consistent messaging — ensure uniform tone and format across interactions
Creating Prompts
Class Style
Use class decorators for prompts that need dependency injection, lifecycle hooks, or complex logic:Function Style
For simpler prompts, use the functional builder:Registering Prompts
Add prompts to your app via theprompts array:
Return Values
Prompts return messages that clients can render or send to a model. The SDK supports multiple return formats.Simple String Return
Message Array
Full MCP Format
For complete control, return the fullGetPromptResult structure:
Object Return
Objects are automatically JSON-serialized:Prompt Metadata
| Field | Description |
|---|---|
name | Programmatic identifier used internally and in MCP responses |
title | Human-friendly name for UI display |
description | Helps clients and models understand when to use this prompt |
arguments | Named parameters that can be filled in by clients |
icons | Array of icons for visual representation in clients |
Prompt Context
Class-based prompts have access to a rich execution context viathis:
Using Providers
Inject services via theget() method:
Real-World Examples
Code Review Prompt
Translation Prompt
Multi-Turn Conversation Starter
Dynamic Prompt with Provider
MCP Protocol Integration
Prompts integrate with the MCP protocol via two flows:| Flow | Description |
|---|---|
prompts/list | Returns all available prompts with their metadata |
prompts/get | Returns the messages for a specific prompt with arguments filled in |
prompts/get with a name and arguments:
- The SDK locates the prompt by name
- Arguments are validated against the prompt’s definition
- The
execute()method is called with the arguments - The return value is converted to MCP
GetPromptResultformat
Capabilities
FrontMCP automatically advertises prompt capabilities during MCP initialization:| Capability | Description |
|---|---|
listChanged | When true, the server will send notifications/prompts/list_changed when the prompt list changes (prompts added/removed dynamically) |
listChanged: true when you have any prompts registered, enabling clients to receive real-time notifications when prompts are dynamically added or removed.
Change Notifications
When prompts change dynamically (e.g., via adapters or plugins), FrontMCP automatically sendsnotifications/prompts/list_changed to connected clients. Clients that support this notification will refresh their prompt list.
Best Practices
Do:- Use descriptive
nameanddescriptionfields to help clients understand prompt purpose - Define clear
argumentswith descriptions to guide users - Keep prompts focused on a single task or interaction pattern
- Use the
titlefield for user-friendly display names - Return structured messages with appropriate roles
- Create prompts that perform side effects (use tools instead)
- Hardcode values that should be arguments
- Create overly complex prompts—split into multiple prompts if needed
- Ignore argument validation—mark required fields appropriately
- Mix concerns—keep prompts focused on message generation

