Vault / wiki/201/mcp-prompts.md
updated 2026-05-28MCP Prompts
Parameterized prompt templates exposed by an MCP server. User-controlled — typically surfaced as slash commands in the host UI.
Concept
A prompt is a named, parameterized message template. The server returns a ready-to-send list of messages when the user invokes it.
Example: a /review-pr prompt in a GitHub MCP server takes a pr_url argument and returns a structured review prompt populated with the PR body and diff.
Definition
from mcp.types import Prompt, PromptArgument
@server.list_prompts()
async def list_prompts():
return [
Prompt(
name="review_pr",
description="Generate a code-review prompt for a GitHub pull request",
arguments=[
PromptArgument(name="pr_url", description="GitHub PR URL", required=True),
PromptArgument(name="focus", description="Optional focus area", required=False),
],
)
]
@server.get_prompt()
async def get_prompt(name: str, arguments: dict):
if name == "review_pr":
pr = await github.get_pr(arguments["pr_url"])
return {
"messages": [
{"role": "user", "content": [{"type": "text", "text": f"Review this PR:\n{pr.body}\n\nDiff:\n{pr.diff}"}]}
]
}
Argument autocomplete
A server can implement completion/complete so the host UI offers autocomplete as the user types arguments. Example: typing /review_pr pr_url= could autocomplete from a list of recent open PRs.
Prompts vs tools
| Aspect | Prompt | Tool |
|---|---|---|
| Invoked by | User (slash command) | Model |
| Returns | Messages to seed the conversation | Tool result |
| Side effects | No | Often |
| Discovery | Slash command menu | LLM reads tool list |
CCA-F angle
The exam tests whether you can pick the right primitive:
- "User wants a reusable 'analyze this customer churn' workflow with a churn-data input." → Prompt.
- "Model should be able to query the churn database on demand." → Tool (returning either text or resource).
- "User wants to attach the latest churn report PDF as context." → Resource.