PrefectHQ/fastmcp · error · TypeError

Elicitation schema field '{prop_name}' is an array of object

Error message

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.

What it means

Arrays in elicitation schemas are allowed only for multi-select over enum-like items. An array whose items schema declares type 'object' (i.e. a list of objects/structs) is rejected, because MCP clients cannot elicit nested structured data.

Source

Thrown at fastmcp_slim/fastmcp/server/elicitation.py:481

        if "oneOf" in prop_schema or "anyOf" in prop_schema:
            union_schemas = prop_schema.get("oneOf", []) + prop_schema.get("anyOf", [])
            for union_schema in union_schemas:
                # Allow const and enum in unions
                if "const" in union_schema or "enum" in union_schema:
                    continue
                union_type = union_schema.get("type")
                if union_type not in ALLOWED_TYPES:
                    raise TypeError(
                        f"Elicitation schema field '{prop_name}' has union type '{union_type}' which is not "
                        f"a primitive type. Only {ALLOWED_TYPES} are allowed in elicitation schemas."
                    )
            continue

        # Check for arrays before checking primitive types
        if prop_type == "array":
            items_schema = prop_schema.get("items", {})
            if items_schema.get("type") == "object":
                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(

View on GitHub (pinned to 1f02114297)

Solutions

  1. Flatten the data: ask for each object field as a separate primitive property, or run multiple elicitations
  2. Restrict list fields to enums/Literals (multi-select), e.g. list[Color] where Color is an Enum
  3. Collect structured data via a tool call with structured output instead of elicitation

Example fix

// before
class Form(BaseModel):
    contacts: list[Contact]  # list of objects
// after
class Form(BaseModel):
    contact_email: str
    contact_phone: str
Defensive patterns

Strategy: validation

Validate before calling

def check_array_items(schema: dict) -> None:
    for prop in schema.get("properties", {}).values():
        if prop.get("type") == "array" and prop.get("items", {}).get("type") == "object":
            raise TypeError("arrays of objects are not allowed in elicitation schemas")

Type guard

def is_object_array(prop_schema: dict) -> bool:
    return (
        isinstance(prop_schema, dict)
        and prop_schema.get("type") == "array"
        and isinstance(prop_schema.get("items"), dict)
        and prop_schema["items"].get("type") == "object"
    )

Try / catch

try:
    schema = get_elicitation_schema(response_type)
except TypeError as e:
    if "array of objects" in str(e):
        logger.error("flatten list[Model] fields into primitive properties or separate elicitations")
        return None
    raise

Prevention

When it happens

Trigger: A response type like list[SomeBaseModel] or a field items: list[dict] whose generated schema is {"type": "array", "items": {"type": "object"}} during get_elicitation_schema validation.

Common situations: Trying to elicit multiple structured records (e.g. a list of address models); converting a form tool to elicitation without flattening the data model; Pydantic models containing nested model lists.

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


AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29). Data as JSON: /api/errors/78899f7d5752a72c. Report an issue: GitHub.