Package io.modelcontextprotocol.server
Record Class McpServerFeatures.AsyncPromptRegistration
java.lang.Object
java.lang.Record
io.modelcontextprotocol.server.McpServerFeatures.AsyncPromptRegistration
- Record Components:
prompt- The prompt definition including name and descriptionpromptHandler- The function that processes prompt requests and returns formatted templates
- Enclosing class:
- McpServerFeatures
public static record McpServerFeatures.AsyncPromptRegistration(McpSchema.Prompt prompt, Function<McpSchema.GetPromptRequest,reactor.core.publisher.Mono<McpSchema.GetPromptResult>> promptHandler)
extends Record
Registration of a prompt template with its asynchronous handler function. Prompts
provide structured templates for AI model interactions, supporting:
- Consistent message formatting
- Parameter substitution
- Context injection
- Response formatting
- Instruction templating
Example prompt registration:
new McpServerFeatures.AsyncPromptRegistration(
new Prompt("analyze", "Code analysis template"),
request -> {
String code = request.getArguments().get("code");
return Mono.just(new GetPromptResult(
"Analyze this code:\n\n" + code + "\n\nProvide feedback on:"
));
}
)
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncPromptRegistration(McpSchema.Prompt prompt, Function<McpSchema.GetPromptRequest, reactor.core.publisher.Mono<McpSchema.GetPromptResult>> promptHandler) Creates an instance of aAsyncPromptRegistrationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.prompt()Returns the value of thepromptrecord component.Function<McpSchema.GetPromptRequest,reactor.core.publisher.Mono<McpSchema.GetPromptResult>> Returns the value of thepromptHandlerrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AsyncPromptRegistration
public AsyncPromptRegistration(McpSchema.Prompt prompt, Function<McpSchema.GetPromptRequest, reactor.core.publisher.Mono<McpSchema.GetPromptResult>> promptHandler) Creates an instance of aAsyncPromptRegistrationrecord class.- Parameters:
prompt- the value for thepromptrecord componentpromptHandler- the value for thepromptHandlerrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
prompt
Returns the value of thepromptrecord component.- Returns:
- the value of the
promptrecord component
-
promptHandler
public Function<McpSchema.GetPromptRequest,reactor.core.publisher.Mono<McpSchema.GetPromptResult>> promptHandler()Returns the value of thepromptHandlerrecord component.- Returns:
- the value of the
promptHandlerrecord component
-