--- title: prompt sidebarTitle: prompt --- # `fastmcp.prompts.prompt` Base classes for FastMCP prompts. ## Functions ### `Message` ```python Message(content: str | ContentBlock, role: Role | None = None, **kwargs: Any) -> PromptMessage ``` A user-friendly constructor for PromptMessage. ## Classes ### `PromptArgument` An argument that can be passed to a prompt. ### `Prompt` A prompt template that can be rendered with parameters. **Methods:** #### `enable` ```python enable(self) -> None ``` #### `disable` ```python disable(self) -> None ``` #### `to_mcp_prompt` ```python to_mcp_prompt(self, **overrides: Any) -> MCPPrompt ``` Convert the prompt to an MCP prompt. #### `from_function` ```python from_function(fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, title: str | None = None, description: str | None = None, icons: list[Icon] | None = None, tags: set[str] | None = None, enabled: bool | None = None, meta: dict[str, Any] | None = None) -> FunctionPrompt ``` Create a Prompt from a function. The function can return: - A string (converted to a message) - A Message object - A dict (converted to a message) - A sequence of any of the above #### `render` ```python render(self, arguments: dict[str, Any] | None = None) -> list[PromptMessage] ``` Render the prompt with arguments. This method is not implemented in the base Prompt class and must be implemented by subclasses. ### `FunctionPrompt` A prompt that is a function. **Methods:** #### `from_function` ```python from_function(cls, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, title: str | None = None, description: str | None = None, icons: list[Icon] | None = None, tags: set[str] | None = None, enabled: bool | None = None, meta: dict[str, Any] | None = None) -> FunctionPrompt ``` Create a Prompt from a function. The function can return: - A string (converted to a message) - A Message object - A dict (converted to a message) - A sequence of any of the above #### `render` ```python render(self, arguments: dict[str, Any] | None = None) -> list[PromptMessage] ``` Render the prompt with arguments.