Skip to main content
Prompts are user-controlled message templates. Unlike tools (which the LLM calls), prompts are selected by users and rendered into conversation messages. Prompts flow through the MCP protocol like this:
  1. A client discovers prompts via prompts/list (each prompt may include arguments and metadata).
  2. A client renders a prompt via prompts/get with string-valued arguments.
  3. The server executes your prompt renderer.
  4. The server returns a GetPromptResult containing messages (and optional description) per MCP spec.
Define prompts with @prompt(...) and register them with server.collect(...) (or inside with server.binding(): ...).

Decorator signature

  • prompt(...): prompt(name: str, *, description=None, title=None, arguments=None, icons=None, meta=None)
Your renderer is called like:
  • fn(arguments: dict[str, str] | None) → returns messages / mapping / GetPromptResult / None

Basic prompt

The description tells the client/LLM what the prompt is for. arguments=[...] defines what the client should pass to prompts/get.

Arguments (required vs optional)

Dedalus MCP treats arguments as required only if you mark them required=True in the decorator’s arguments=[...].
If required args are missing, Dedalus raises an MCP error with INVALID_PARAMS.

Complex argument values (lists/dicts)

MCP prompt arguments are strings. If you need structured values, pass JSON strings and parse them yourself:

Return formats

Prompt renderers can return:
  • A list/iterable of messages, where each item can be:
    • a (role, content) tuple
    • a mapping like {"role": "...", "content": ...}
    • a PromptMessage instance
  • A mapping with explicit control:
    • required: "messages"
    • optional: "description"
  • GetPromptResult
  • None (produces zero messages)
Not supported: returning a raw str (Dedalus raises TypeError so you always provide role + content).

Explicit control (mapping)


Message content

For message content, you can use:
  • a str (auto-coerced to text content)
  • a full content-block mapping (e.g. {"type": "text", "text": "..."})
  • a content-block instance from dedalus_mcp.types (e.g. TextContent, ImageContent, etc.)

Async prompts

Prefer async def for I/O.

Decorator options


Context access

If a prompt is rendered during an MCP request, it can access context via get_context() (for logging, progress, etc.). Note: get_context() only works inside an active MCP request handler; calling it outside a request raises LookupError.

Testing

Test prompt renderers like normal functions:
Integration-style test via the server API (mirrors prompts/get):
Last modified on June 30, 2026