Prompts
Create resuable prompt templates and workflows
Prompts enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs. They provide a powerful way to standardize and share common LLM interactions.
Prompts are designed to be user-controlled, meaning they are exposed from servers to clients with the intention of the user being able to explicitly select them for use.
Overview
Prompts in MCP are predefined templates that can:
- Accept dynamic arguments
- Include context from resources
- Chain multiple interactions
- Guide specific workflows
- Surface as UI elements (like slash commands)
Prompt structure
Each prompt is defined with:
Discovering prompts
Clients can discover available prompts through the prompts/list
endpoint:
Using prompts
To use a prompt, clients make a prompts/get
request:
Dynamic prompts
Prompts can be dynamic and include:
Embedded resource context
When handling the prompts/get
request:
Multi-step workflows
Example implementation
Here’s a complete example of implementing prompts in an MCP server:
Best practices
When implementing prompts:
- Use clear, descriptive prompt names
- Provide detailed descriptions for prompts and arguments
- Validate all required arguments
- Handle missing arguments gracefully
- Consider versioning for prompt templates
- Cache dynamic content when appropriate
- Implement error handling
- Document expected argument formats
- Consider prompt composability
- Test prompts with various inputs
UI integration
Prompts can be surfaced in client UIs as:
- Slash commands
- Quick actions
- Context menu items
- Command palette entries
- Guided workflows
- Interactive forms
Updates and changes
Servers can notify clients about prompt changes:
- Server capability:
prompts.listChanged
- Notification:
notifications/prompts/list_changed
- Client re-fetches prompt list
Security considerations
When implementing prompts:
- Validate all arguments
- Sanitize user input
- Consider rate limiting
- Implement access controls
- Audit prompt usage
- Handle sensitive data appropriately
- Validate generated content
- Implement timeouts
- Consider prompt injection risks
- Document security requirements