Prompts in the Client
Completing the Client
The final piece of the client is prompt support. This lets the app list the prompts a server offers and retrieve a specific one with its arguments filled in — turning the server's pre-built workflows into commands your users can trigger. After this lesson, the client speaks all three primitives: tools, resources, and prompts.
Two methods, mirroring the others
Just like tools and resources, prompts need a list method (discover what's available) and a get method (retrieve a specific one). The difference is that get_prompt performs variable interpolation — it returns ready-to-send messages, not a definition.
Listing Prompts
list_prompts is straightforward — it asks the session for the available prompts and returns them. The app uses this to populate the slash-command menu so users can see what workflows exist.
async def list_prompts(self) -> list[types.Prompt]:
result = await self.session().list_prompts()
return result.promptsGetting a Prompt with Arguments
get_prompt is the interesting one: you pass the prompt name plus an arguments dictionary, and the server interpolates those values into the template and returns the resulting messages. For example, our format prompt expects a doc_id, so the arguments would be {"doc_id": "plan.md"} — and that value gets substituted into the prompt template on the server.
async def get_prompt(self, prompt_name: str, args: dict[str, str]):
result = await self.session().get_prompt(prompt_name, args)
return result.messagesget_prompt sends the user's arguments; the server interpolates them and returns interpolated messages for Claude.
Prompts in Action
With both methods implemented, prompts work through the CLI. Type '/' and the available prompts appear as commands. Selecting 'format' prompts you to choose a document; after you pick one, the system sends the complete, interpolated prompt to Claude. Claude receives the formatting instructions plus the document id, then uses the available tools (read and edit) to fetch and reformat the content.
- 1.Write and evaluate a high-quality prompt relevant to the server's purpose.
- 2.Define it on the server with @mcp.prompt().
- 3.The client lists it (list_prompts) so users can discover it via '/'.
- 4.The user picks it and supplies arguments; the client calls get_prompt with those args.
- 5.The server interpolates the arguments and returns messages; the app sends them to Claude.
The full circle
Notice how the primitives compose here: a USER triggers the format PROMPT, which instructs Claude to use the edit_document TOOL, operating on content it can read via the document RESOURCE. One workflow, all three primitives, each controlled by the right party — exactly the design from the 'choosing a primitive' lesson.
Section complete
Your client now speaks all three primitives. The final section covers what's beyond the basics: client primitives (sampling, elicitation, logging), remote transports and auth, using MCP inside Claude, and going to production.
Key Takeaways
- ✓Prompt support completes the client: list_prompts to discover server workflows, get_prompt to retrieve a specific one with arguments interpolated.
- ✓list_prompts populates the '/' command menu; get_prompt(name, args) returns ready-to-send messages, not just a definition.
- ✓Arguments passed to get_prompt (e.g. {"doc_id": "plan.md"}) become keyword arguments in the server's prompt function and are interpolated into the template.
- ✓In the CLI, typing '/' shows prompts as commands; selecting one collects its arguments and sends the interpolated messages to Claude.
- ✓The workflow composes all three primitives: a user triggers a prompt that instructs Claude to use a tool on content available via a resource.
- ✓After this, the client speaks all three primitives — tools, resources, and prompts — completing the build.
Check Your Understanding
Test what you learned in this lesson.
Q1.What is the key difference between list_prompts and get_prompt?
Q2.When you call get_prompt('format', {'doc_id': 'plan.md'}), what happens to 'plan.md'?
Q3.How do users typically trigger prompts in the CLI client?
Q4.The format workflow shows the primitives composing. Which roles do they play?
Practice This Lesson