Annotation Interface McpElicitation


@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented public @interface McpElicitation
Annotation for methods that handle elicitation requests from MCP servers. This annotation is applicable only for MCP clients.

Methods annotated with this annotation can be used to process elicitation requests from MCP servers.

For synchronous handlers, the method must return ElicitResult. For asynchronous handlers, the method must return Mono<ElicitResult>.

Example usage:


 &#64;McpElicitation(clients = "my-client-id")
 public ElicitResult handleElicitationRequest(ElicitRequest request) {
     return ElicitResult.builder()
         .message("Generated response")
         .requestedSchema(
             Map.of("type", "object", "properties", Map.of("message", Map.of("type", "string"))))
         .build();
 }

 &#64;McpElicitation(clients = "my-client-id")
 public Mono<ElicitResult> handleAsyncElicitationRequest(ElicitRequest request) {
     return Mono.just(ElicitResult.builder()
         .message("Generated response")
         .requestedSchema(
             Map.of("type", "object", "properties", Map.of("message", Map.of("type", "string"))))
         .build());
 }
 
Author:
Christian Tzolov
See Also:
  • McpSchema.ElicitRequest
  • McpSchema.ElicitResult
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Used as connection or client identifier to select the MCP clients, the elicitation method is associated with.
  • Element Details

    • clients

      String[] clients
      Used as connection or client identifier to select the MCP clients, the elicitation method is associated with.