fastmcp.prompts.base
Base classes for FastMCP prompts.
Classes
Message
Wrapper for prompt message with auto-serialization.
Accepts any content - strings pass through, other types
(dict, list, BaseModel) are JSON-serialized to text.
Methods:
to_mcp_prompt_message
PromptArgument
An argument that can be passed to a prompt.
PromptResult
Canonical result type for prompt rendering.
Provides explicit control over prompt responses: multiple messages,
roles, and metadata at both the message and result level.
Methods:
to_mcp_prompt_result
InputRequiredPromptResult
The full result of a single multi-round-trip prompt leg (SEP-2322).
InputRequiredResult is a result type, not a tools/call feature: any
request may resolve to one. When a prompt returns an InputRequiredResult
from its body to ask the client for input, that ask is the legitimate
result of this prompts/get — so FastMCP wraps it in this PromptResult
subclass, mirroring InputRequiredToolResult, and it flows through the
middleware chain as an ordinary return value.
Invariant: the wrapped InputRequiredResult is never rendered as prompt
messages. messages is always empty; the wire handler (_on_get_prompt)
reads .input_required and returns it to the runner.
Prompt
A prompt template that can be rendered with parameters.
Methods:
to_mcp_prompt
from_function
- str: wrapped as single user Message
- list[Message | str]: converted to list[Message]
- PromptResult: used directly
render
- str: Wrapped as single user Message
- list[Message | str]: Converted to list[Message]
- PromptResult: Used directly
convert_result
TypeError: for unsupported types

