mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-15 10:09:11 +02:00
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
122 lines
4.7 KiB
Text
122 lines
4.7 KiB
Text
---
|
|
title: prompts
|
|
sidebarTitle: prompts
|
|
---
|
|
|
|
# `fastmcp.client.mixins.prompts`
|
|
|
|
|
|
Prompt-related methods for FastMCP Client.
|
|
|
|
## Classes
|
|
|
|
### `ClientPromptsMixin` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
|
|
Mixin providing prompt-related methods for Client.
|
|
|
|
|
|
**Methods:**
|
|
|
|
#### `list_prompts_mcp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L36" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
list_prompts_mcp(self: Client) -> mcp.types.ListPromptsResult
|
|
```
|
|
|
|
Send a prompts/list request and return the complete MCP protocol result.
|
|
|
|
**Args:**
|
|
- `cursor`: Optional pagination cursor from a previous request's nextCursor.
|
|
|
|
**Returns:**
|
|
- mcp.types.ListPromptsResult: The complete response object from the protocol,
|
|
containing the list of prompts and any additional metadata.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If called while the client is not connected.
|
|
- `McpError`: If the request results in a TimeoutError | JSONRPCError
|
|
|
|
|
|
#### `list_prompts` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L59" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
list_prompts(self: Client, max_pages: int = AUTO_PAGINATION_MAX_PAGES) -> list[mcp.types.Prompt]
|
|
```
|
|
|
|
Retrieve all prompts available on the server.
|
|
|
|
This method automatically fetches all pages if the server paginates results,
|
|
returning the complete list. For manual pagination control (e.g., to handle
|
|
large result sets incrementally), use list_prompts_mcp() with the cursor parameter.
|
|
|
|
**Args:**
|
|
- `max_pages`: Maximum number of pages to fetch before raising. Defaults to 250.
|
|
|
|
**Returns:**
|
|
- list\[mcp.types.Prompt]: A list of all Prompt objects.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If the page limit is reached before pagination completes.
|
|
- `McpError`: If the request results in a TimeoutError | JSONRPCError
|
|
|
|
|
|
#### `get_prompt_mcp` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_prompt_mcp(self: Client, name: str, arguments: dict[str, Any] | None = None, meta: dict[str, Any] | None = None) -> mcp.types.GetPromptResult
|
|
```
|
|
|
|
Send a prompts/get request and return the complete MCP protocol result.
|
|
|
|
**Args:**
|
|
- `name`: The name of the prompt to retrieve.
|
|
- `arguments`: Arguments to pass to the prompt. Defaults to None.
|
|
- `meta`: Request metadata (e.g., for SEP-1686 tasks). Defaults to None.
|
|
|
|
**Returns:**
|
|
- mcp.types.GetPromptResult: The complete response object from the protocol,
|
|
containing the prompt messages and any additional metadata.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If called while the client is not connected.
|
|
- `McpError`: If the request results in a TimeoutError | JSONRPCError
|
|
|
|
|
|
#### `get_prompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L176" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_prompt(self: Client, name: str, arguments: dict[str, Any] | None = None) -> mcp.types.GetPromptResult
|
|
```
|
|
|
|
#### `get_prompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L187" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_prompt(self: Client, name: str, arguments: dict[str, Any] | None = None) -> PromptTask
|
|
```
|
|
|
|
#### `get_prompt` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/src/fastmcp/client/mixins/prompts.py#L199" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
get_prompt(self: Client, name: str, arguments: dict[str, Any] | None = None) -> mcp.types.GetPromptResult | PromptTask
|
|
```
|
|
|
|
Retrieve a rendered prompt message list from the server.
|
|
|
|
**Args:**
|
|
- `name`: The name of the prompt to retrieve.
|
|
- `arguments`: Arguments to pass to the prompt. Defaults to None.
|
|
- `version`: Specific prompt version to get. If None, gets highest version.
|
|
- `meta`: Optional request-level metadata.
|
|
- `task`: If True, execute as background task (SEP-1686). Defaults to False.
|
|
- `task_id`: Optional client-provided task ID (auto-generated if not provided).
|
|
- `ttl`: Time to keep results available in milliseconds (default 60s).
|
|
|
|
**Returns:**
|
|
- mcp.types.GetPromptResult | PromptTask: The complete response object if task=False,
|
|
or a PromptTask object if task=True.
|
|
|
|
**Raises:**
|
|
- `RuntimeError`: If called while the client is not connected.
|
|
- `McpError`: If the request results in a TimeoutError | JSONRPCError
|
|
|