Example
Anatomy of a Prompt
When a client callsprompts/list, the server returns metadata for each prompt including its arguments. Here’s the JSON-RPC response that the example above produces when a client calls prompts/list:
| Python | MCP Schema | Notes |
|---|---|---|
name="code_review" | "name" | Falls back to function name if omitted |
title="Code Review" | "title" | Human-readable display name |
description="Generate a code review..." | "description" | Falls back to docstring if omitted |
language: str (no default) | {"name": "language", "required": true} | Parameters without defaults are required |
focus: str = "general" | {"name": "focus", "required": false} | Parameters with defaults are optional |
context: Context | (not in schema) | Automatically excluded |
Argument Descriptions
You can add descriptions to prompt arguments the same way as tools, usingAnnotated and Field:
description to each argument in the response:
Minimal Definition
At minimum, a prompt only needs a function:Using Context
Access the MCP context for advanced features. Add aContext parameter — it’s automatically excluded from the prompt’s arguments:
Multi-Message Prompts
Return structured messages for complex prompts:Async Prompts
Prompts can be async for dynamic content generation:Prompts vs Tools vs Resources
| Aspect | Prompts | Tools | Resources |
|---|---|---|---|
| Purpose | Guide interactions | Perform actions | Expose data |
| Returns | Message templates | Action results | Content/data |
| Use case | Conversation starters, templates | Operations | Files, configs |
| Invocation | User selects prompt | Agent calls tool | Agent reads resource |