fix: Use Message function and PromptResult type in docs (#1515)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Jeremiah Lowin 2025-08-15 11:33:36 -04:00 committed by GitHub
commit 2547243038
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -188,10 +188,10 @@ FastMCP intelligently handles different return types from your prompt function:
- **`Any`**: If the return type is not one of the above, the return value is attempted to be converted to a string and used as a `PromptMessage`.
```python
from fastmcp.prompts.prompt import PromptMessage
from fastmcp.prompts.prompt import Message, PromptResult
@mcp.prompt
def roleplay_scenario(character: str, situation: str) -> list[PromptMessage]:
def roleplay_scenario(character: str, situation: str) -> PromptResult:
"""Sets up a roleplaying scenario with initial messages."""
return [
Message(f"Let's roleplay. You are {character}. The situation is: {situation}"),