Sub topic 9
Reusable prompts for common workflows
This chapter assumes you have a working FastMCP server with at least one tool, as built earlier in this tutorial. You should also know the difference between a tool and a resource.
What an MCP prompt is
A prompt is a named, parameterized message template that your server publishes. The user picks it in the host application, often from a slash-command menu. The host fills in the arguments, asks your server for the finished messages, and sends them to the model.
The control model is what separates prompts from the other two features:
| Feature | Who decides to use it | Typical use |
|---|---|---|
| Tool | The model | Take an action or run a query |
| Resource | The application or user | Supply read-only context |
| Prompt | The user | Start a standard workflow |
Use a prompt when your team repeats the same request with small variations, such as an incident summary or a deploy review. A prompt keeps the wording consistent. It can also tell the model which of your tools to use.
Writing a prompt
The simplest prompt is a function that returns a string. FastMCP wraps the string as a single user message. The function name becomes the prompt name, the docstring becomes the description, and the parameters become the prompt's arguments.
from mcp.server.fastmcp import FastMCP
from mcp.server.fastmcp.prompts.base import Message, UserMessage
mcp = FastMCP("team-tools")
@mcp.prompt()
def incident_summary(service: str) -> str:
"""Ask the model to draft an incident summary for a service."""
return (
f"Draft a short incident summary for the {service} service. "
"Include impact, current status, and next steps."
)
@mcp.prompt()
def review_deploy(environment: str, version: str = "latest") -> list[Message]:
"""Review a deploy using the team's tools."""
return [
UserMessage(
f"Review the {version} deploy to {environment}. "
"Call list_deploys to see recent versions, then call "
"get_service_owner for any service you mention. "
"Finish with a go or no-go recommendation and your reasons."
),
]
if __name__ == "__main__":
mcp.run()Returning a list of messages lets you set roles and build a multi-turn starting point. The second prompt names the tools it expects the model to call, so the user does not need to remember them.
How a host uses a prompt
The host first calls prompts/list to show the menu. After the user chooses one, it calls prompts/get with the arguments.
Your server only builds text. It does not call the model, and it does not run the workflow itself.
Design guidelines
- Keep arguments few and plain. Prompt arguments are strings that a person types or picks, so avoid nested structures.
- Give defaults to optional arguments. In the example,
versionfalls back to"latest". - Write the description for the person. The user reads it in a menu, so say what the prompt produces.
- Name tools explicitly when you depend on them. A model follows "call list_deploys" more reliably than "look at recent deploys".
- Ask for a specific output shape. Fields like impact, status, and next steps make responses comparable across incidents.
Testing
Open the server in the MCP Inspector and use the Prompts tab. List the prompts, fill in the arguments, and read the messages that come back. Check that the roles are right and the text reads as you intended. A wrong argument name or a missing description shows up immediately.
Exercise
Your team often asks the model to check who owns a service before paging someone. Should you implement this as a tool, a resource, or a prompt? Describe what you would write.
Show answer
Use a prompt for the repeated request, and keep the lookup as a tool. getserviceowner already performs the lookup, and the model calls it. A prompt such as pagecheck(service: str) returns a message like "Find the owner of {service} with getservice_owner, then summarize the runbook steps and who to page." The user starts the workflow and the model decides how to call the tool. A resource would fit only if the owner list were static read-only context, not something to query.