Package org.gridgain.internal.mcp.utils
Class McpResponseConverter
java.lang.Object
org.gridgain.internal.mcp.utils.McpResponseConverter
Utility for converting between McpResponse and MCP protocol CallToolResult.
Handles both success and error responses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic io.modelcontextprotocol.spec.McpSchema.CallToolResultaddRateLimitWarning(io.modelcontextprotocol.spec.McpSchema.CallToolResult result, RateLimitResult limitResult) Adds rate limit warning to successful result if remaining tokens are low.static io.modelcontextprotocol.spec.McpSchema.CallToolResultcreateErrorResult(String message) Create an error CallToolResult with the given message.static io.modelcontextprotocol.spec.McpSchema.CallToolResultcreateErrorResult(Throwable throwable) Create an error CallToolResult from an exception.static io.modelcontextprotocol.spec.McpSchema.CallToolResultCreates an error result for rate limit exceeded.static io.modelcontextprotocol.spec.McpSchema.CallToolResulttoCallToolResult(McpResponse response) Convert McpResponse to CallToolResult.
-
Constructor Details
-
McpResponseConverter
public McpResponseConverter()
-
-
Method Details
-
toCallToolResult
public static io.modelcontextprotocol.spec.McpSchema.CallToolResult toCallToolResult(McpResponse response) Convert McpResponse to CallToolResult.- Parameters:
response- The response to convert- Returns:
- CallToolResult containing the response content and error status
-
createRateLimitErrorResult
public static io.modelcontextprotocol.spec.McpSchema.CallToolResult createRateLimitErrorResult(RateLimitResult result) Creates an error result for rate limit exceeded.- Parameters:
result- Rate limit check result- Returns:
- CallToolResult with rate limit error
-
addRateLimitWarning
public static io.modelcontextprotocol.spec.McpSchema.CallToolResult addRateLimitWarning(io.modelcontextprotocol.spec.McpSchema.CallToolResult result, RateLimitResult limitResult) Adds rate limit warning to successful result if remaining tokens are low.- Parameters:
result- Original tool resultlimitResult- Rate limit check result- Returns:
- Modified result with warning, or original if no warning needed
-
createErrorResult
public static io.modelcontextprotocol.spec.McpSchema.CallToolResult createErrorResult(String message) Create an error CallToolResult with the given message.- Parameters:
message- Error message- Returns:
- CallToolResult with error flag set
-
createErrorResult
public static io.modelcontextprotocol.spec.McpSchema.CallToolResult createErrorResult(Throwable throwable) Create an error CallToolResult from an exception.- Parameters:
throwable- The exception to convert- Returns:
- CallToolResult with error flag set
-