Class ToolArguments
java.lang.Object
eu.mrapik.minecraftservermcp.util.ToolArguments
Helpers for reading string-keyed maps: MCP
McpSchema.CallToolRequest.arguments() (client JSON) and
ToolAccessConfig.extra() (YAML).
Missing keys return null for strings; booleans and ints use defaults when absent. String fields use
Object.toString() where applicable, matching typical JSON inputs from MCP clients.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReads a boolean argument; accepts Boolean or parses string values withBoolean.parseBoolean(String).static intReads a non-negative int fromargs(tool arguments orToolAccessConfig.extra()).map(io.modelcontextprotocol.spec.McpSchema.CallToolRequest request) Returns the argument map from the request, never null.static @Nullable StringReads a string argument; coerces non-null values withObject.toString().
-
Method Details
-
map
public static Map<String,Object> map(io.modelcontextprotocol.spec.McpSchema.CallToolRequest request) Returns the argument map from the request, never null.- Parameters:
request- MCP tool call request- Returns:
- the arguments map, or an empty map if the SDK passes null
-
string
Reads a string argument; coerces non-null values withObject.toString().- Parameters:
args- argument mapkey- JSON property name- Returns:
- null if the key is missing or the value is null
-
bool
Reads a boolean argument; accepts Boolean or parses string values withBoolean.parseBoolean(String).- Parameters:
args- argument mapkey- JSON property namedef- value when the key is absent- Returns:
- resolved boolean
-
intArg
Reads a non-negative int fromargs(tool arguments orToolAccessConfig.extra()). Negative values and parse failures yield0ordefas described below.- Parameters:
args- map to read fromkey- property namedef- value when the key is absent, null, or the value cannot be parsed as an int- Returns:
- parsed int clamped to
0or higher;defonly when missing, null, or unparsable
-