Add Prompts to an MCP Server
@mcp.prompt()
def review_code(code: str) -> str:
"""Create a code-review prompt."""
return f"Review this code for correctness, security and maintainability:\n\n{code}"The current Python SDK describes prompts as user-selected message templates. A client can present them as menu items, commands, or buttons.
Use prompts for domain workflows
Prompts are useful when the server has expertise about how its tools or resources should be used together, such as incident investigation or database analysis.
Keep host policy separate
Server prompts should not replace the host's security and behavioral instructions. Treat third-party prompts as content, not as unquestionable policy.