Class McpArgs

java.lang.Object
com.codename1.backend.mcp.McpArgs

public final class McpArgs extends Object

The conversions the build's generated tool and operation adapters use: one argument out of a call's argument map, as the type the method declares.

Accepts what an agent or an HTTP client actually sends -- a JSON number or a numeric string, a JSON boolean or "true" -- and refuses anything else with an IllegalArgumentException naming the argument, which the MCP endpoint reports to the agent as a tool error it can correct.

  • Method Details

    • property

      public static Map property(String type, String description, String[] values)
      One property of an input schema.
    • object

      public static Map object(Map properties, String[] required)
      An object schema.
    • any

      public static Object any(Map args, String name, boolean required)
    • string

      public static String string(Map args, String name, boolean required)
      A string argument. A number or boolean is taken as its text, as Jackson coerces a scalar for Spring; an array or object is refused. Its Java text -- [value], {id=value} -- is not what the caller sent, and a malformed call would run a side-effecting tool with an identifier nobody meant, where the schema promised a JSON string.
    • longValue

      public static long longValue(Map args, String name, boolean required)
    • intValue

      public static int intValue(Map args, String name, boolean required)
    • shortValue

      public static short shortValue(Map args, String name, boolean required)
      A short argument, refused outside the short range rather than narrowed: a cast would turn 40000 into -25536 and run the tool with a number nobody sent.
    • byteValue

      public static byte byteValue(Map args, String name, boolean required)
      A byte argument, refused outside the byte range for the same reason.
    • doubleValue

      public static double doubleValue(Map args, String name, boolean required)
    • booleanValue

      public static boolean booleanValue(Map args, String name, boolean required)
    • charValue

      public static char charValue(Map args, String name, boolean required)
    • integerObject

      public static Integer integerObject(Map args, String name, boolean required)
    • longObject

      public static Long longObject(Map args, String name, boolean required)
    • shortObject

      public static Short shortObject(Map args, String name, boolean required)
    • byteObject

      public static Byte byteObject(Map args, String name, boolean required)
    • doubleObject

      public static Double doubleObject(Map args, String name, boolean required)
    • floatObject

      public static Float floatObject(Map args, String name, boolean required)
    • floatValue

      public static float floatValue(Map args, String name, boolean required)
      A float argument, refused when it has no float value: a finite number such as 1e100 would otherwise narrow to infinity, and the method would run with a number nobody sent.
    • booleanObject

      public static Boolean booleanObject(Map args, String name, boolean required)
    • characterObject

      public static Character characterObject(Map args, String name, boolean required)
    • map

      public static Map map(Map args, String name, boolean required)
    • list

      public static List list(Map args, String name, boolean required)
    • enumValue

      public static Object enumValue(Object[] values, Map args, String name, boolean required)
      The constant of values -- an enum's values() -- that the argument names.
    • toDouble

      public static double toDouble(Object value)
      A boxed number as a double, NaN for null.