Provides the defprompt macro for declaring MCP prompts alongside their handlers.
Prompts are user-controlled message templates surfaced to MCP clients via
prompts/list and prompts/get (MCP spec 2025-11-25).
Example
defprompt "code_review", "Ask the model to review code",
arguments: [code: {:string!, "The code to review"}] do
{:ok, [
%{role: "user",
content: %{type: "text", text: "Please review:\n" <> params["code"]}}
]}
endInside the do block, params and session are bound.
Arguments
The :arguments keyword uses the same DSL as tool params (see NexusMCP.Server.Schema):
arguments: [
code: :string!, # required string, no description
language: {:string, "Lang hint"}, # optional string with description
max_lines: {:integer, "Cap lines"}
]Required arguments are validated by the session before the handler is invoked;
missing required args produce a -32602 JSON-RPC error.
Summary
Functions
Converts the DSL arguments: keyword list to MCP prompt argument objects.
Returns the names of arguments marked required.