PrefectHQ/fastmcp · error · TypeError
Elicitation schema field '{prop_name}' is an array, but arra
Error message
Elicitation schema field '{prop_name}' is an array, but arrays are only allowed when items are enums (for multi-select). Only enum arrays are supported in elicitation schemas. What it means
Beyond arrays of objects, elicitation arrays must follow the enum multi-select pattern: items with 'enum', or anyOf/oneOf branches that are all const/enum values. Any other array (e.g. list[int], list[str] of free-form strings) is rejected with this error.
Source
Thrown at fastmcp_slim/fastmcp/server/elicitation.py:499
raise TypeError(
f"Elicitation schema field '{prop_name}' is an array of objects, but arrays of objects are not allowed. "
"Elicitation schemas must be flat objects with primitive properties only."
)
# Allow arrays with enum patterns (for multi-select)
if "enum" in items_schema:
continue # Allowed: {"type": "array", "items": {"enum": [...]}}
# Allow arrays with oneOf/anyOf const patterns (SEP-1330)
if "oneOf" in items_schema or "anyOf" in items_schema:
union_schemas = items_schema.get("oneOf", []) + items_schema.get(
"anyOf", []
)
if union_schemas and all("const" in s for s in union_schemas):
continue # Allowed: {"type": "array", "items": {"anyOf": [{"const": ...}, ...]}}
# Reject other array types (e.g., arrays of primitives without enum pattern)
raise TypeError(
f"Elicitation schema field '{prop_name}' is an array, but arrays are only allowed "
"when items are enums (for multi-select). Only enum arrays are supported in elicitation schemas."
)
# Check for nested objects (not allowed)
if prop_type == "object":
raise TypeError(
f"Elicitation schema field '{prop_name}' is an object, but nested objects are not allowed. "
"Elicitation schemas must be flat objects with primitive properties only."
)
# Check if it's a primitive type
if prop_type not in ALLOWED_TYPES:
raise TypeError(
f"Elicitation schema field '{prop_name}' has type '{prop_type}' which is not "
f"a primitive type. Only {ALLOWED_TYPES} are allowed in elicitation schemas."
)
View on GitHub (pinned to 1f02114297)
Solutions
- Change the field to list[Literal[...]] or list[SomeEnum] so items are enum-like
- If free-form strings are needed, use a single string field with a separator, or multiple named primitive fields
- Collect arbitrary lists via a tool call instead of elicitation
Example fix
// before
class Prefs(BaseModel):
scores: list[int]
// after
class Prefs(BaseModel):
tier: list[Literal["basic", "pro"]] # enum multi-select Defensive patterns
Strategy: validation
Validate before calling
def check_enum_array(schema: dict) -> None:
for prop in schema.get("properties", {}).values():
if prop.get("type") != "array":
continue
items = prop.get("items", {})
if "enum" in items:
continue
branches = items.get("anyOf") or items.get("oneOf") or []
if branches and all("const" in b for b in branches):
continue
raise TypeError("arrays in elicitation must have enum/const items (multi-select only)") Type guard
def is_enum_array(prop_schema: dict) -> bool:
if not isinstance(prop_schema, dict) or prop_schema.get("type") != "array":
return False
items = prop_schema.get("items", {})
if "enum" in items:
return True
branches = items.get("anyOf") or items.get("oneOf") or []
return bool(branches) and all("const" in b for b in branches) Try / catch
try:
schema = get_elicitation_schema(response_type)
except TypeError as e:
if "arrays are only allowed" in str(e):
logger.error("use list[Literal[...]] or list[Enum] for multi-select fields")
return None
raise Prevention
- Use list[Literal["a","b"]] or list[MyEnum] — not list[str]/list[int] — for multi-select
- Free-form string lists are not supported; use a delimited string field or multiple fields
- Collect arbitrary lists with a tool call, not elicitation
- Lint response models for non-enum list fields before deployment
When it happens
Trigger: A response type like list[int], list[str], or list[float] that isn't a list[Enum]/list[Literal] — validated via get_elicitation_schema.
Common situations: Asking the user for a list of numbers or free-form tags; assuming list[str] is a multi-select (it must be Literal/Enum values); migrating from a generic JSON-form tool to elicitation.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Elicitation schema must be an object schema, got type '{sche
- Elicitation schema field '{prop_name}' contains a reference
- Elicitation schema field '{prop_name}' has union type '{unio
- Elicitation schema field '{prop_name}' is an array of object
- Elicitation schema field '{prop_name}' is an object, but nes
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/036c54ba6a93bea0.
Report an issue: GitHub.