Annotation Interface Prompt


@Retention(RUNTIME) @Target(TYPE) public @interface Prompt
Marks a McpPrompt subclass as an MCP prompt template and declares its metadata, discovered by
invalid reference
McpConfig#toolsPackage(String)
.

 @Prompt(name = "summarize", args = @PromptArg(name = "text", required = true))
 public class SummarizePrompt extends McpPrompt {
     @Override
     public PromptMessage render(PromptArguments args) {
         return PromptMessage.withUserRole(new TextContent("Summarize: " + args.getString("text")));
     }
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Unique prompt name (used by clients in prompts/get).
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Arguments accepted by the prompt template — always strings per the MCP specification.
     
  • Element Details

    • name

      String name
      Unique prompt name (used by clients in prompts/get).
    • description

      String description
      Default:
      ""
    • args

      PromptArg[] args
      Arguments accepted by the prompt template — always strings per the MCP specification.
      Default:
      {}