Class SyncMcpElicitationProvider
java.lang.Object
org.springaicommunity.mcp.provider.elicitation.SyncMcpElicitationProvider
Provider for synchronous elicitation callbacks.
This class scans a list of objects for methods annotated with McpElicitation
and creates Function callbacks for them. These callbacks can be used to handle
elicitation requests from MCP servers.
Example usage:
// Create a provider with a list of objects containing @McpElicitation methods
SyncMcpElicitationProvider provider = new SyncMcpElicitationProvider(List.of(elicitationHandler));
// Get the elicitation handler
Function<ElicitRequest, ElicitResult> elicitationHandler = provider.getElicitationHandler();
// Add the handler to the client features
McpClientFeatures.Sync clientFeatures = new McpClientFeatures.Sync(
clientInfo, clientCapabilities, roots,
toolsChangeConsumers, resourcesChangeConsumers, promptsChangeConsumers,
loggingConsumers, samplingHandler, elicitationHandler);
- Author:
- Christian Tzolov
- See Also:
-
McpElicitationSyncMcpElicitationMethodCallbackMcpSchema.ElicitRequestMcpSchema.ElicitResult
-
Constructor Summary
ConstructorsConstructorDescriptionSyncMcpElicitationProvider(List<Object> elicitationObjects) Create a new SyncMcpElicitationProvider. -
Method Summary
Modifier and TypeMethodDescriptionprotected Method[]doGetClassMethods(Object bean) Returns the methods of the given bean class.Get the elicitation specifications.
-
Constructor Details
-
SyncMcpElicitationProvider
Create a new SyncMcpElicitationProvider.- Parameters:
elicitationObjects- the objects containing methods annotated withMcpElicitation
-
-
Method Details
-
getElicitationSpecifications
Get the elicitation specifications.- Returns:
- the elicitation specifications
- Throws:
IllegalStateException- if no elicitation methods are found or if multiple elicitation methods are found
-
doGetClassMethods
Returns the methods of the given bean class.- Parameters:
bean- the bean instance- Returns:
- the methods of the bean class
-