Skip to main content
Welcome back. In this lesson we cover prompts and prompt templates in the Model Context Protocol (MCP) and how clients discover and fetch them. Prompts are a distinct server-side primitive: they are templates the application exposes for users to choose. Unlike tools and some resources, prompts are user-controlled — the model will not invoke them automatically, and the application reads them only when a user requests one.
Prompts are templates the user picks. The model does not call them by itself, and the application only reads them when the user asks for one.

How a client discovers prompts

Clients enumerate available prompts by calling the prompts/list RPC method. The server responds with a list of prompt templates and metadata. After the user chooses a prompt and provides any required arguments, the client requests a filled-in prompt with prompts/get. Example (simplified) JSON-RPC response for prompts/list:
Notes on the prompts/list response:
  • _meta provides server identity and versioning.
  • prompts is an array of templates the client can present to the user.
  • Each prompt includes name, description, and an arguments schema the client can use to render a form or elicitation UI.
When the user selects a prompt (for example, escalate_shipment with ref = "PL-4417"), the client calls prompts/get. The server returns the assembled prompt content and metadata. Example (simplified) request and response for prompts/get: Request (client -> server):
Response (server -> client):
Important: the messages array contains the assembled prompt text and its role. The client should surface this message as the user input to the model (or otherwise present it in the UI).
Prompts are not tools. They are user-facing templates and must be selected and filled by a user (or user-driven UI). Do not assume the model will request or use prompts automatically.

Example server implementation (server.py)

Below is a focused example showing how to register a prompt template on the server side using the MCP server API. This demonstrates a prompt that builds a short escalation note for a shipment reference.
What this function demonstrates:
  • The @server.prompt decorator registers a prompt template called escalate_shipment.
  • The prompt function accepts ref: str and returns a concrete text prompt based on application data.
  • Returning a factual, specific prompt helps reduce model hallucination by grounding the prompt in known data.

Prompts vs. Tools vs. Resources — quick comparison

Example mcp.json snippet (register server)

Below is an example client-side MCP config to launch the server locally:

Typical client workflow

  1. Discover available servers (server discovery).
  2. Client calls prompts/list to enumerate available prompt templates.
  3. User selects a prompt and provides any required arguments (for example, ref = "PL-4417").
  4. Client calls prompts/get to fetch the filled-in prompt text.
  5. Client presents the returned messages text as the user input to a model or surfaces it in the UI.

References and further reading

This article covered how to define prompt templates on the server, how clients discover and fetch them, and how returning specific, factual prompt text helps reduce model hallucination.

Watch Video