Interface McpCompleteToolHandler<A,R>
- Type Parameters:
A- bound argument typeR- structured result type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Programmatic handler for a tool that always completes with a structured
Java result.
Soklet derives the output schema and intrinsic conversion plan from the
result type declared by McpToolRegistration.ArgumentTypeStage.argumentAndOutputTypes(Class, Class). A bare String result type is rejected; return prose
through an advanced McpToolHandler and
McpCompleteResult.fromToolText(String) instead.
For an operation that creates a durable task while retaining its eventual
typed output contract, use
McpToolRegistration.CompleteHandlerStage.operationHandler(McpToolHandler).
For an inline operation that needs explicit content or an isError
result while retaining the typed output contract, use
McpToolRegistration.CompleteHandlerStage.inlineOperationHandler(McpToolHandler).
Implementations must be safe for concurrent invocation.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionhandle(@NonNull McpRequestContext requestContext, @NonNull McpToolArguments<@NonNull A> toolArguments, @NonNull McpInvocationFeatures invocationFeatures) Handles one tool invocation.
-
Method Details
-
handle
@NonNull R handle(@NonNull McpRequestContext requestContext, @NonNull McpToolArguments<@NonNull A> toolArguments, @NonNull McpInvocationFeatures invocationFeatures) throws Exception Handles one tool invocation.- Parameters:
requestContext- request metadatatoolArguments- converted and raw tool argumentsinvocationFeatures- invocation-scoped optional features- Returns:
- non-null structured result
- Throws:
Exception- if application handling fails
-