How do you fetch an MCP prompt with variable interpolation?
Using MCP Prompts in a Client Application
Audio flashcard · 0:31Nortren·
How do you fetch an MCP prompt with variable interpolation?
0:31
The get prompt method is more interesting because it handles variable interpolation. When you request a prompt, you provide an arguments dictionary that gets passed to the prompt function as keyword arguments. For example, if your server has a format document prompt that expects a doc ID parameter, the arguments dictionary would contain doc ID mapped to a value like plan dot markdown. The session sends both the prompt name and the arguments to the server, the server runs your prompt function with those keyword arguments, and you get back the fully interpolated list of messages, ready to send to Claude.
modelcontextprotocol.io