mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 21:44:18 +02:00
84 lines
2.4 KiB
Text
84 lines
2.4 KiB
Text
---
|
|
title: prompt
|
|
sidebarTitle: prompt
|
|
---
|
|
|
|
# `fastmcp.prompts.prompt`
|
|
|
|
|
|
Base classes for FastMCP prompts.
|
|
|
|
## Functions
|
|
|
|
### `Message` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L32"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
```python
|
|
Message(content: str | MCPContent, role: Role | None = None, **kwargs: Any) -> PromptMessage
|
|
```
|
|
|
|
|
|
A user-friendly constructor for PromptMessage.
|
|
|
|
|
|
## Classes
|
|
|
|
### `PromptArgument` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L54"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
|
|
An argument that can be passed to a prompt.
|
|
|
|
|
|
### `Prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L66"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
|
|
A prompt template that can be rendered with parameters.
|
|
|
|
|
|
**Methods:**
|
|
|
|
#### `to_mcp_prompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L73"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
```python
|
|
to_mcp_prompt(self, **overrides: Any) -> MCPPrompt
|
|
```
|
|
|
|
Convert the prompt to an MCP prompt.
|
|
|
|
|
|
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L91"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
```python
|
|
from_function(fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | 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
|
|
|
|
|
|
### `FunctionPrompt` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L119"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
|
|
A prompt that is a function.
|
|
|
|
|
|
**Methods:**
|
|
|
|
#### `from_function` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/prompts/prompt.py#L125"><Icon icon="github" size="14" /></a></sup>
|
|
|
|
```python
|
|
from_function(cls, fn: Callable[..., PromptResult | Awaitable[PromptResult]], name: str | None = None, description: str | None = None, tags: set[str] | None = None, enabled: bool | 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
|
|
|