Interface McpReadResourceResultConverter

All Known Implementing Classes:
DefaultMcpReadResourceResultConverter

public interface McpReadResourceResultConverter
Interface for converting method return values to McpSchema.ReadResourceResult.

This interface defines a contract for converting various return types from resource methods to a standardized McpSchema.ReadResourceResult format.

Author:
Christian Tzolov
  • Method Details

    • convertToReadResourceResult

      io.modelcontextprotocol.spec.McpSchema.ReadResourceResult convertToReadResourceResult(Object result, String requestUri, String mimeType, AbstractMcpResourceMethodCallback.ContentType contentType)
      Converts the method's return value to a McpSchema.ReadResourceResult.

      This method handles various return types and converts them to a standardized McpSchema.ReadResourceResult format.

      Parameters:
      result - The method's return value
      requestUri - The original request URI
      mimeType - The MIME type of the resource
      contentType - The content type of the resource
      Returns:
      A McpSchema.ReadResourceResult containing the appropriate resource contents
      Throws:
      IllegalArgumentException - if the return type is not supported