Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677---title: function_promptsidebarTitle: function_prompt---
# `fastmcp.prompts.function_prompt`
Standalone @prompt decorator for FastMCP.
## Functions
### `prompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L403" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonprompt(name_or_fn: str | Callable[..., Any] | None = None) -> Any```
Standalone decorator to mark a function as an MCP prompt.
Returns the original function with metadata attached. Register with a serverusing mcp.add_prompt().
## Classes
### `DecoratedPrompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L43" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Protocol for functions decorated with @prompt.
### `PromptMeta` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L52" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
Metadata attached to functions by the @prompt decorator.
### `FunctionPrompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L67" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
A prompt that is a function.
**Methods:**
#### `from_function` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L73" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonfrom_function(cls, fn: Callable[..., Any]) -> FunctionPrompt```
Create a Prompt from a function.
**Args:**- `fn`: The function to wrap- `metadata`: PromptMeta object with all configuration. If provided,individual parameters must not be passed.- `name, title, etc.`: Individual parameters for backwards compatibility.Cannot be used together with metadata parameter.
The function can return:- str: wrapped as single user Message- list\[Message | str]: converted to list\[Message]- PromptResult: used directly
#### `render` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/prompts/function_prompt.py#L321" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonrender(self, arguments: dict[str, Any] | None = None) -> PromptResult```
Render the prompt with arguments.