MCP prompts
The third and final capability: prompts. These are pre-built workflow templates that users can select. Think of them as recipes the server provides, where the user chooses which one to use.
@mcp.prompt()
def generate_wiki_game_prompt(
topic: str, difficulty: str = "medium"
) -> str:
"""Generate a prompt for creating a word game from Wikipedia articles."""
return f"""Create an interactive "Hidden Word Wiki" game about '{topic}'.
1. Use search_articles(topic='{topic}', max_results=3)
2. Use get_article_content() for the most relevant result
3. Extract 5-8 key terms (difficulty: {difficulty})
4. Build an interactive game with:
- Word blanks showing only first letter and length
- Alphabet buttons for guessing
- Hint system using article content
- Score tracking (6 wrong guesses = game over)
"""A prompt template that orchestrates tools into a complete workflow.
# Discover available prompts
prompts = await session.list_prompts()
# Get a prompt with arguments
prompt = await session.get_prompt(
"generate_wiki_game_prompt",
arguments={"topic": "Python", "difficulty": "hard"}
)Same pattern as tools and resources: discover, then use.
Now your server has all three capabilities: - Tools: search_articles(), get_article_content(), called by the LLM - Resources: wiki://topics, wiki://{topic}, read by the app - Prompts: generate_wiki_game_prompt(), selected by the user Three decorators. Zero boilerplate. The complete MCP server.
Matching exercise: Capabilities to decorators
Loading practice…
AI prompt: Build your own complete MCP Server
Loading practice…
Quiz: Quiz
Loading practice…