apache/shardingsphere · error · MCPInvalidMetadataObjectTypesException
Unsupported object_types value `%s`.
Error message
Unsupported object_types value `%s`.
What it means
Thrown by MCPToolArguments.resolveObjectType as MCPInvalidMetadataObjectTypesException when an object_types entry is neither a valid SupportedMCPMetadataObjectType enum name (case-insensitive) nor one supported by the specific tool. The exception message interpolates the offending value and the exception carries the list of allowed values for the tool, so the caller can self-correct.
Source
Thrown at mcp/core/src/main/java/org/apache/shardingsphere/mcp/core/tool/request/MCPToolArguments.java:81
for (Object each : objectTypes) {
result.add(resolveObjectType(each, supportedObjectTypes));
}
return result;
}
private SupportedMCPMetadataObjectType resolveObjectType(final Object objectType, final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {
String actualValue = Objects.toString(objectType, "").trim();
if (actualValue.isEmpty()) {
throw new MCPInvalidRequestException("object_types cannot contain blank values.");
}
try {
SupportedMCPMetadataObjectType result = SupportedMCPMetadataObjectType.valueOf(actualValue.toUpperCase(Locale.ENGLISH));
if (supportedObjectTypes.contains(result)) {
return result;
}
} catch (final IllegalArgumentException ignored) {
}
throw new MCPInvalidMetadataObjectTypesException(actualValue, createAllowedObjectTypes(supportedObjectTypes));
}
private List<String> createAllowedObjectTypes(final Set<SupportedMCPMetadataObjectType> supportedObjectTypes) {
return supportedObjectTypes.stream().map(each -> each.name().toLowerCase(Locale.ENGLISH)).toList();
}
/**
* Get string argument.
*
* @param name argument name
* @return argument value
*/
public String getStringArgument(final String name) {
return Objects.toString(arguments.get(name), "").trim();
}
/**
* Get bounded integer argument.View on GitHub (pinned to e952770a21)
Solutions
- Read the allowed values from the exception payload (createAllowedObjectTypes lists them lowercased) and use exactly those
- Use singular, lowercased enum-style names (e.g. table, view, schema) as emitted by the tool's descriptor
- Fetch the tool's input schema/descriptor first and build validation from it dynamically
Example fix
// before
list_metadata({"object_types": ["tables"]})
// after
list_metadata({"object_types": ["table"]}) Defensive patterns
Strategy: try-catch
Validate before calling
// Validate against the tool descriptor's declared enum before calling
Set<String> allowed = toolDescriptor.getAllowedObjectTypes(); // e.g. [table, view, schema]
List<String> values = (List<String>) arguments.getOrDefault("object_types", List.of());
if (!allowed.containsAll(values.stream().map(v -> v.toLowerCase(Locale.ENGLISH)).toList())) {
throw new IllegalArgumentException("Allowed object_types: " + allowed);
} Type guard
const ALLOWED = new Set(["table", "view", "schema"]); // sync from tool descriptor const isValidObjectType = (v: unknown): v is string => typeof v === "string" && ALLOWED.has(v.trim().toLowerCase());
Try / catch
try {
listMetadata(arguments);
} catch (MCPInvalidMetadataObjectTypesException e) {
// e lists allowed values; retry with the intersection
listMetadata(Map.of("object_types", intersect(values, e.getAllowedObjectTypes())));
} Prevention
- Use exact singular enum names (table, not tables) from the tool descriptor
- Build validation dynamically from each tool's declared allowed values
When it happens
Trigger: SupportedMCPMetadataObjectType.valueOf(uppercased value) throws IllegalArgumentException, or the parsed enum is not in supportedObjectTypes for the current tool. Examples: "tables" (plural not matching the enum), "index" when the tool only supports table/view/schema, "tbl".
Common situations: Guessing type names (plural vs singular mismatches like tables/table); tool-specific support subsets — a value valid for one metadata tool rejected by another; version upgrades renaming enum constants.
Related errors
- object_types must be an array.
- object_types cannot contain blank values.
- Statement is not a transaction command.
- %s must be an integer between %d and %d.
- %s execution_mode must be one of %s.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/32ec43b7f2794548.
Report an issue: GitHub.