Module: MCPClient | Version: 3.1.0 | Studio Pro: 11.9.1 | Severity: High
What happened
While building an agentic Mendix application consuming WooCommerce MCP (via mcp-proxy + mcp-wordpress-remote), calling `ListToolsResult_Get` throws a `ClassCastException` and returns no tools. The MCP connection itself works fine — the issue is in parsing the tool schema response.
Error:
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String at mcpclient.actions.ListToolsResult_Get.createToolArguments(ListToolsResult_Get.java:160) at mcpclient.actions.ListToolsResult_Get.createTool(ListToolsResult_Get.java:132)
Root cause
JSON Schema draft-07 allows `type` to be either a String or an array of strings. WooCommerce MCP returns:
json "type": ["string", "null"]
The current code in `ListToolsResult_Get.java` line 160 assumes `type` is always a `String`:
java
String type = (String) propertyMap.get("type"); // ClassCastException here
This is not WooCommerce-specific. Any MCP server following JSON Schema draft-07 spec can return `type` as an array and will trigger the same crash.
A second bug was found in the same method — String comparison using `==` instead of `.equals()`:
java if (type == "enum") // always false in Java
Fix
Applied and tested in `javasource/mcpclient/actions/ListToolsResult_Get.java`:
java
// Fix 1: Handle type as String OR List (JSON Schema draft-07 compliant)
Object rawType = propertyMap.get("type");
String type;
if (rawType instanceof List<?>) {
List<?> typeList = (List<?>) rawType;
type = typeList.isEmpty() ? "string" : typeList.get(0).toString();
} else {
type = rawType != null ? rawType.toString() : "string";
}
// Fix 2: Correct String comparison
if ("enum".equals(type)) {
createEnumValues(enumValues, toolArg);
}
After applying this fix, tool discovery works correctly and WooCommerce MCP tools load successfully.
Recommendation
Please include this fix in the next MCP Client release and consider reviewing other schema parsing locations for the same assumption. A test case covering MCP servers returning array-type fields would prevent regression.
Full bug report (DOCX) and the fixed Java file are available — happy to contribute if there is a GitHub repo for this module.