Package org.mcpjava.server.prompts
Annotation Interface Prompt
Marks a method as providing an MCP prompt template.
Prompts are reusable message templates that can be used by MCP clients.
Parameters
Prompt methods may have parameters of the following types:String- eachStringparameter is treated as an argument to the prompt. In most cases these parameters must be annotated withPromptArgwith thenameattribute set, unless the code was compiled with the-parametersoption.PromptArgalso allows other properties of the argument to be configured.McpRequest- to access information about the requestCancellation- to allow processing to be stopped if the client cancels the prompt requestProgress- to send progress reports back to the client- Implementations may define additional types that can be used as parameters
Return Type Handling
The annotated method can return various types that will be converted to prompt responses:
String- Single text message with roleUSERin the responsePromptMessage- Single message in the response- List of
PromptMessage- Multiple messages in the response PromptResponse- Full response with description and messages- Other types - Encoded according to framework-specific rules
- See Also:
-
Field Details
-
ELEMENT_NAME
Constant value forname()indicating that the annotated element's name should be used as-is.- See Also:
-
-
Element Details
-
name
String nameThe unique name of the prompt.Each prompt bound to the same MCP server configuration must have a unique name. This is intended for programmatic or logical use, but may be used for UI display as a fallback if
title()is not present.By default, the name is derived from the annotated method name.
- Returns:
- the prompt name
- Default:
"<<element name>>"
-
title
String titleA human-readable title for the prompt.This is a short, user-friendly display name for the prompt.
- Returns:
- the prompt title
- Default:
""
-
description
String descriptionA human-readable description of what this prompt does.This description will be sent to MCP clients to help them understand when and how to use this prompt.
- Returns:
- the prompt description
- Default:
""
-