Summary audio
No audio recap for this lesson.
Study notes
Core Purpose
- Prompts are pre-built, well-tested message templates that MCP servers expose to clients
- They allow server authors to provide specialized, high-quality prompts tailored to the server's domain
- Users can accomplish tasks without prompts, but using server-provided prompts gives better results
The Format Command Example
- Feature: slash command support (e. g. , /format)
- Goal: reformat plain text documents into markdown syntax
- Users could manually ask Claude to do this, but a custom prompt ensures better, consistent results
How Prompts Work in MCP
- Defined using the @prompt decorator in the server code
- Include a name and optional description
- Return a list of messages (user and assistant messages) that can be sent directly to Claude
- Messages can include interpolated values (like document IDs)
Implementation Structure
- Use from mcp. server. fastmcp import prompts and import base
- Function receives arguments (e. g. , doc_id) that get interpolated into the prompt
- Return [base. UserMessage(text=prompt_text)] as a list of messages
- Clients retrieve prompts via the MCP inspector or programmatically
Key Advantage
- Server authors invest time upfront to develop, test, and evaluate prompts
- Clients get reliable, specialized prompts without reinventing them
- Prompts are reusable across any client application connecting to the server
Takeaways
- Prompts are pre-built message templates that MCP servers expose to clients, allowing server authors to provide specialized, high-quality prompts tailored to their domain
- Prompts are defined using the @prompt decorator and return a list of messages that can be sent directly to Claude, with support for interpolated values like document IDs
- Server authors invest upfront effort to develop and test prompts, so clients get reliable, specialized prompts that are reusable across any application connecting to the server
Flashcards 8 cards
Question
click to reveal · ←/→
Answer
click to flip back
Knowledge check 1 questions