Class ToolResults

java.lang.Object
eu.mrapik.minecraftservermcp.util.ToolResults

public final class ToolResults extends Object
JSON envelopes for MCP McpSchema.CallToolResult payloads and for resource bodies that reuse the same shape. Each tool result uses one text part whose body is UTF-8 JSON with schemaVersion, success, and either data or error.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Version number incremented when the envelope fields or semantics change.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    JSON string for an error envelope.
    static String
    JSON string for a successful envelope (e.g.
    static io.modelcontextprotocol.spec.McpSchema.CallToolResult
    err(String message)
    Error tool result: JSON text body with isError(true).
    static io.modelcontextprotocol.spec.McpSchema.CallToolResult
    ok(Object data)
    Successful tool result: JSON text body with isError(false).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SCHEMA_VERSION

      public static final int SCHEMA_VERSION
      Version number incremented when the envelope fields or semantics change.
      See Also:
  • Method Details

    • ok

      public static io.modelcontextprotocol.spec.McpSchema.CallToolResult ok(Object data)
      Successful tool result: JSON text body with isError(false).
      Parameters:
      data - JSON-serializable value (map, list, string, etc.)
      Returns:
      MCP call result
    • err

      public static io.modelcontextprotocol.spec.McpSchema.CallToolResult err(String message)
      Error tool result: JSON text body with isError(true).
      Parameters:
      message - human-readable error
      Returns:
      MCP call result
    • envelopeOk

      public static String envelopeOk(Object data)
      JSON string for a successful envelope (e.g. MCP resource bodies).
      Parameters:
      data - payload under data
      Returns:
      UTF-8 JSON text
    • envelopeErr

      public static String envelopeErr(String message)
      JSON string for an error envelope.
      Parameters:
      message - error description
      Returns:
      UTF-8 JSON text