{"record":{"id":"78899f7d5752a72c","repo":"PrefectHQ/fastmcp","slug":"elicitation-schema-field-prop-name-is-an-array","errorCode":null,"errorMessage":"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.","messagePattern":"Elicitation schema field '(.+?)' is an array of objects, but arrays of objects are not allowed\\. Elicitation schemas must be flat objects with primitive properties only\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/server/elicitation.py","lineNumber":481,"sourceCode":"        if \"oneOf\" in prop_schema or \"anyOf\" in prop_schema:\n            union_schemas = prop_schema.get(\"oneOf\", []) + prop_schema.get(\"anyOf\", [])\n            for union_schema in union_schemas:\n                # Allow const and enum in unions\n                if \"const\" in union_schema or \"enum\" in union_schema:\n                    continue\n                union_type = union_schema.get(\"type\")\n                if union_type not in ALLOWED_TYPES:\n                    raise TypeError(\n                        f\"Elicitation schema field '{prop_name}' has union type '{union_type}' which is not \"\n                        f\"a primitive type. Only {ALLOWED_TYPES} are allowed in elicitation schemas.\"\n                    )\n            continue\n\n        # Check for arrays before checking primitive types\n        if prop_type == \"array\":\n            items_schema = prop_schema.get(\"items\", {})\n            if items_schema.get(\"type\") == \"object\":\n                raise TypeError(\n                    f\"Elicitation schema field '{prop_name}' is an array of objects, but arrays of objects are not allowed. \"\n                    \"Elicitation schemas must be flat objects with primitive properties only.\"\n                )\n\n            # Allow arrays with enum patterns (for multi-select)\n            if \"enum\" in items_schema:\n                continue  # Allowed: {\"type\": \"array\", \"items\": {\"enum\": [...]}}\n\n            # Allow arrays with oneOf/anyOf const patterns (SEP-1330)\n            if \"oneOf\" in items_schema or \"anyOf\" in items_schema:\n                union_schemas = items_schema.get(\"oneOf\", []) + items_schema.get(\n                    \"anyOf\", []\n                )\n                if union_schemas and all(\"const\" in s for s in union_schemas):\n                    continue  # Allowed: {\"type\": \"array\", \"items\": {\"anyOf\": [{\"const\": ...}, ...]}}\n\n            # Reject other array types (e.g., arrays of primitives without enum pattern)\n            raise TypeError(","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/elicitation.py#L463-L499","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Flatten the data: ask for each object field as a separate primitive property, or run multiple elicitations","Restrict list fields to enums/Literals (multi-select), e.g. list[Color] where Color is an Enum","Collect structured data via a tool call with structured output instead of elicitation"],"exampleFix":"// before\nclass Form(BaseModel):\n    contacts: list[Contact]  # list of objects\n// after\nclass Form(BaseModel):\n    contact_email: str\n    contact_phone: str","handlingStrategy":"validation","validationCode":"def check_array_items(schema: dict) -> None:\n    for prop in schema.get(\"properties\", {}).values():\n        if prop.get(\"type\") == \"array\" and prop.get(\"items\", {}).get(\"type\") == \"object\":\n            raise TypeError(\"arrays of objects are not allowed in elicitation schemas\")","typeGuard":"def is_object_array(prop_schema: dict) -> bool:\n    return (\n        isinstance(prop_schema, dict)\n        and prop_schema.get(\"type\") == \"array\"\n        and isinstance(prop_schema.get(\"items\"), dict)\n        and prop_schema[\"items\"].get(\"type\") == \"object\"\n    )","tryCatchPattern":"try:\n    schema = get_elicitation_schema(response_type)\nexcept TypeError as e:\n    if \"array of objects\" in str(e):\n        logger.error(\"flatten list[Model] fields into primitive properties or separate elicitations\")\n        return None\n    raise","preventionTips":["Never use list[BaseModel] or list[dict] fields in elicitation response types","Restrict list fields to Enum or Literal item types for multi-select","Flatten structured data into primitive fields or split into multiple elicitations","Use tools with structured output when you genuinely need lists of objects"],"tags":["elicitation","json-schema","nested-objects","fastmcp"],"backgroundTag":"schema-validation-failed","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}