Package org.gridgain.internal.mcp
Class McpResponse
java.lang.Object
org.gridgain.internal.mcp.McpResponse
Represents a response returned by an MCP tool invocation.
An McpResponse consists of:
- a list of
McpContentobjects 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:
success(String)for successful responseserror(String)for error responses
Example usage:
McpResponse response = McpResponse.success("Connection established");
if (response.isError()) {
// handle error
}
-
Method Summary
Modifier and TypeMethodDescriptionstatic McpResponseCreates an error MCP response containing a single text message.Returns the response content payload.booleanisError()Indicates whether this response represents an error.static McpResponseCreates a successful MCP response containing a single text message.
-
Method Details
-
success
Creates a successful MCP response containing a single text message.- Parameters:
text- success message- Returns:
- a non-error
McpResponsecontaining the provided text
-
error
Creates an error MCP response containing a single text message.- Parameters:
text- error description- Returns:
- an error
McpResponsecontaining the provided text
-
getContent
Returns the response content payload.- Returns:
- list of
McpContentelements
-
isError
public boolean isError()Indicates whether this response represents an error.- Returns:
trueif the response is an error,falseotherwise
-