Class McpResponseConverter

java.lang.Object
org.gridgain.internal.mcp.utils.McpResponseConverter

public class McpResponseConverter extends Object
Utility for converting between McpResponse and MCP protocol CallToolResult. Handles both success and error responses.
  • 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 result
      limitResult - 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