McpActionResponse.java

package fr.tiogars.chat.domains.mcp.models;

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;
import java.util.Map;

/**
 * Response from an MCP action execution.
 */
@Schema(description = "Response from MCP action execution")
public record McpActionResponse(
        @Schema(description = "Whether the action was successful")
        boolean success,

        @Schema(description = "Result data from the action")
        Map<String, Object> data,

        @Schema(description = "List of resources returned")
        List<McpResource> resources,

        @Schema(description = "Error message if any")
        String error,

        @Schema(description = "Processing time in milliseconds")
        long processingTimeMs
) {
    public McpActionResponse {
        if (data == null) {
            data = Map.of();
        }
        if (resources == null) {
            resources = List.of();
        }
    }
}