Class McpResponse

java.lang.Object
org.gridgain.internal.mcp.McpResponse

public class McpResponse extends Object
Represents a response returned by an MCP tool invocation.

An McpResponse consists of:

  • a list of McpContent objects describing the response payload
  • a flag indicating whether the response represents an error

The response follows the MCP protocol convention where content is modeled as a list to allow future extensibility (for example, multiple text blocks, structured data, or rich content types).

Instances are created via static factory methods:

Example usage:


 McpResponse response = McpResponse.success("Connection established");

 if (response.isError()) {
     // handle error
 }
 
  • Method Details

    • success

      public static McpResponse success(String text)
      Creates a successful MCP response containing a single text message.
      Parameters:
      text - success message
      Returns:
      a non-error McpResponse containing the provided text
    • error

      public static McpResponse error(String text)
      Creates an error MCP response containing a single text message.
      Parameters:
      text - error description
      Returns:
      an error McpResponse containing the provided text
    • getContent

      public List<McpContent> getContent()
      Returns the response content payload.
      Returns:
      list of McpContent elements
    • isError

      public boolean isError()
      Indicates whether this response represents an error.
      Returns:
      true if the response is an error, false otherwise