Claude With The Anthropic Api
← All lessons
Lesson 69Claude With The Anthropic Api

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 formatted conversation to send to Claude
  • Arguments passed to get_prompt become keyword arguments in the prompt function

Prompt Workflow

  • Define a prompt in the MCP server with placeholders for arguments (e. g. , document ID)
  • Client requests the prompt by name and provides argument values
  • Server interpolates arguments into the prompt template
  • Client receives formatted messages ready to send to Claude
  • Claude receives both the prompt instructions and the interpolated data (e. g. , document ID)
  • Claude can then use available tools to complete the task

Example: Format Document Prompt

  • Prompt name: "format"
  • Argument: document ID
  • Claude receives instructions to format a document and the ID of which document to format
  • Claude uses the get_document tool to fetch content, then returns formatted result

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 get formatted messages ready for Claude
  • Prompts use argument interpolation: client provides values that get inserted into the prompt template, allowing Claude to receive both instructions and specific data (like document IDs) needed to complete tasks
Flashcards 8 cards
Question
click to reveal · ←/→
Answer
click to flip back
Export to Anki (.tsv) ↓
Knowledge check 1 questions