Introduction To Model Context Protocol
← All lessons
Lesson 12Introduction To Model Context Protocol

Prompts in the client

Summary audio

No audio recap for this lesson.

Study notes

List Prompts Functionality

  • Call self. session. list_prompts() to retrieve all prompts defined in the MCP server
  • Return result. prompts to get the list of available prompts

Get Prompt Functionality

  • Call self. session. get_prompt() with two parameters:
  • prompt name: identifies which prompt to retrieve
  • arguments: dictionary of variables to interpolate into the prompt
  • Return result. messages which contains the conversation messages to send to Claude

Prompt Arguments and Interpolation

  • Arguments passed to get_prompt() are provided as a dictionary
  • These arguments are matched to placeholder variables in the prompt template
  • Example: a "format_document" prompt expects a "document_id" key in the arguments dictionary
  • The values are interpolated into the prompt before being sent to Claude

Prompt Workflow

  • Write a prompt relevant to the MCP server's purpose
  • Define the prompt inside the MCP server
  • Client requests the prompt by name and provides arguments
  • Server interpolates arguments into the prompt template
  • Messages are returned and fed directly to Claude for processing
  • Claude can use any tools provided by the server to complete the task

Testing Prompts

  • Use CLI to select a prompt by name (e. g. , "format")
  • Provide required arguments when prompted (e. g. , select a document)
  • Claude receives the interpolated prompt and can invoke server tools to fulfill the request

Takeaways

  • Call self. session. list_prompts() to retrieve all available prompts from the MCP server
  • Call self. session. get_prompt(prompt_name, arguments) with a prompt name and dictionary of variables to interpolate into the prompt template
  • Arguments passed to get_prompt() are matched to placeholder variables in the prompt and interpolated before being sent to Claude
  • The prompt workflow: write prompt → define in server → client requests by name with arguments → server interpolates → Claude receives messages and can invoke server tools
  • Test prompts via CLI by selecting a prompt name and providing required arguments
Flashcards 10 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 6 questions