Skip to main content
Prompts are reusable message templates that help AI agents interact with your server effectively. They provide structured ways to guide conversations and standardize common interactions.

Example

Anatomy of a Prompt

When a client calls prompts/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:
Here’s what maps to what:

Argument Descriptions

You can add descriptions to prompt arguments the same way as tools, using Annotated and Field:
This adds description to each argument in the response:

Minimal Definition

At minimum, a prompt only needs a function:
The function name becomes the prompt name, and the docstring becomes the description.

Using Context

Access the MCP context for advanced features. Add a Context 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