Interface McpEndpoint
Common contract implemented by MCP endpoint classes.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull McpJsonRpcErrorhandleError(@NonNull Throwable throwable, @NonNull McpRequestContext context) Maps a non-tool MCP exception to a JSON-RPC error.default @NonNull McpToolResulthandleToolError(@NonNull Throwable throwable, @NonNull McpToolCallContext context) Maps a thrown tool exception to an MCP tool result.default @NonNull McpSessionContextinitialize(@NonNull McpInitializationContext context, @NonNull McpSessionContext session) Initializes a newly-created MCP session.
-
Method Details
-
initialize
default @NonNull McpSessionContext initialize(@NonNull McpInitializationContext context, @NonNull McpSessionContext session) throws Exception Initializes a newly-created MCP session.- Parameters:
context- the initialization request contextsession- the blank or previously-composed session context- Returns:
- the session context that should be persisted for the new session
- Throws:
Exception- if initialization fails
-
handleToolError
default @NonNull McpToolResult handleToolError(@NonNull Throwable throwable, @NonNull McpToolCallContext context) Maps a thrown tool exception to an MCP tool result.- Parameters:
throwable- the thrown exceptioncontext- the tool-call context- Returns:
- the tool result to return to the client
-
handleError
default @NonNull McpJsonRpcError handleError(@NonNull Throwable throwable, @NonNull McpRequestContext context) Maps a non-tool MCP exception to a JSON-RPC error.- Parameters:
throwable- the thrown exceptioncontext- the request context- Returns:
- the JSON-RPC error to return to the client
-