What this thread does
Do first: Decorate a function with @mcp.prompt, type its parameters and return a string or messages.
Short answer
The function name becomes the prompt name; its docstring supplies the description. Inputs without defaults are required. A returned str becomes one user message.
What to do
from fastmcp import FastMCP
mcp = FastMCP(name="PromptServer")
@mcp.prompt
def ask_about_topic(topic: str) -> str:
return f"Can you please explain the concept of '{topic}'?"
| Need | API / current behavior |
|---|---|
| Metadata overrides | name, title, description: optional str; explicit description overrides the prompt docstring summary |
| Categorization / access | tags: optional set[str]; auth: AuthCheck or list[AuthCheck] or None |
| Static metadata | meta: optional dict[str, Any], since 2.11.0; returned on the listed prompt definition |
| Icons / versions | icons: optional list[Icon], since 2.13.0; version: str, int or None, since 3.0.0; clients receive the highest version |
| Typed arguments | Since 2.9.0, clients send strings; encode non-string values as JSON. Prefer list[int], dict[str, str], float, bool |
| Optional inputs | Function defaults are used when omitted; the example has analysis_type="summary", include_charts=False, required data_uri |
| Argument descriptions | Since 3.2.4, Google, NumPy, Sphinx docstrings are parsed; explicit Annotated[x, "..."] or Field(description=...) takes precedence |
| Argument titles | Since 4.2.0, Field(title=...) supplies the protocol argument title; no explicit title means none listed |
| Multiple messages | Return list[Message | str]; Message from fastmcp.prompts has content and role, accepting user (default) or assistant; non-string ordinary objects become JSON text |
| Full result | Since 3.0.0, PromptResult(messages=..., description=..., meta=...); result meta is runtime _meta, separate from decorator metadata. Explicit result description stays unset unless passed |
| Context | Since 2.2.5, add a parameter annotated Context from fastmcp |
Visibility, 3.0.0 | mcp.disable(names={"internal_prompt"}), mcp.disable(tags={"internal"}), or mcp.enable(tags={"public"}, only=True); disabled prompts cannot be listed or called |
Exact duplicates, 2.1.0 | FastMCP(on_duplicate=...): warn default replaces with warning; error raises ValueError; replace replaces silently; ignore keeps original |
Both def and async def are supported; synchronous functions run in a threadpool. Prefer async for I/O. A duplicate means the same component type, name and version, so different prompt versions may coexist.
Limits and open questions
No *args or **kwargs; deeply nested types, custom classes and complex Pydantic models may not convert reliably from strings. Since 2.9.1, server/provider prompt changes do not automatically notify clients: they see changes on their next listing. As of November 2026, FastMCP 4.2.5 can notify listening MCP 2026-07-28 clients in the same process with await mcp.notify_prompts_changed(). For handshake-era clients, a request handler may send notifications/prompts/list_changed using ctx.send_notification(PromptListChangedNotification()) from mcp_types, reaching only its session; ctx.enable_components() and ctx.disable_components() notify automatically. On MCP 2026-07-28, InputRequiredResult can request input; the client reissues prompts/get and answers appear in ctx.input_responses. The page gives feature versions but no release dates.
Not for: FastMCP tools that execute model-selected actions or resource content.
Sources
Checked
2026-11-17; read Prompts; Prompts (input URL); Prompts (HTML); no command was run.
Started from a post by @FastMCP, packaged by the editor. Original post