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.

Basic prompt

from dedalus_mcp import MCPServer, prompt

@prompt(
    "code-review",
    description="Review code for issues",
    arguments=[{"name": "language", "required": True}],
)
def code_review(arguments):
    lang = arguments.get("language", "python")
    return [
        ("assistant", "You are a senior code reviewer."),
        ("user", f"Review the following {lang} code for bugs and style issues."),
    ]

server = MCPServer("assistant")
server.collect(code_review)
The decorator defines the prompt. collect() registers it. Clients list prompts with prompts/list and render them with prompts/get.

Return formats

Return a list of role/content tuples:
@prompt("summarize", description="Summarize a document")
def summarize(arguments):
    return [
        ("assistant", "You summarize documents concisely."),
        ("user", "Summarize this document in 3 bullet points."),
    ]
Or a mapping for explicit control:
@prompt("status")
def status_prompt(arguments):
    return {
        "description": "Status template",
        "messages": [
            ("assistant", "You summarize status reports."),
        ],
    }
Return None for prompts that produce no messages.

Arguments

Define arguments the user must provide:
from dedalus_mcp.types import PromptArgument

@prompt(
    "translate",
    description="Translate text",
    arguments=[
        PromptArgument(name="text", description="Text to translate", required=True),
        PromptArgument(name="target_lang", description="Target language", required=False),
    ],
)
def translate(arguments):
    text = arguments["text"]
    lang = arguments.get("target_lang", "English")
    return [("user", f"Translate this to {lang}: {text}")]
Missing required arguments raise an MCP error.

Async prompts

@prompt("db-summary", description="Summarize database state")
async def db_summary(arguments):
    stats = await fetch_db_stats()
    return [
        ("assistant", "You analyze database metrics."),
        ("user", f"Here are the current stats: {stats}"),
    ]

Decorator options

@prompt(
    "analyze",
    description="Analyze code",       # Shown to users
    title="Code Analysis",            # Human-friendly name
    arguments=[...],                  # User inputs
    icons=[{"type": "url", "url": "https://example.com/icon.png"}],
    meta={"category": "code"},        # Custom metadata
)
def analyze(arguments):
    ...

Testing

Test prompts as functions:
def test_code_review_prompt():
    result = code_review({"language": "python"})
    assert len(result) == 2
    assert "python" in result[1][1]
Integration test:
async def test_prompt_rendering():
    server = MCPServer("test")
    server.collect(code_review)

    result = await server.invoke_prompt("code-review", arguments={"language": "rust"})
    assert result.messages[1].content.text == "Review the following rust code for bugs and style issues."