{"record":{"id":"957c581c10bf34db","repo":"PrefectHQ/fastmcp","slug":"elicitation-schema-field-prop-name-is-an-objec","errorCode":null,"errorMessage":"Elicitation schema field '{prop_name}' is an object, but nested objects are not allowed. Elicitation schemas must be flat objects with primitive properties only.","messagePattern":"Elicitation schema field '(.+?)' is an object, but nested 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":506,"sourceCode":"                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(\n                f\"Elicitation schema field '{prop_name}' is an array, but arrays are only allowed \"\n                \"when items are enums (for multi-select). Only enum arrays are supported in elicitation schemas.\"\n            )\n\n        # Check for nested objects (not allowed)\n        if prop_type == \"object\":\n            raise TypeError(\n                f\"Elicitation schema field '{prop_name}' is an object, but nested objects are not allowed. \"\n                \"Elicitation schemas must be flat objects with primitive properties only.\"\n            )\n\n        # Check if it's a primitive type\n        if prop_type not in ALLOWED_TYPES:\n            raise TypeError(\n                f\"Elicitation schema field '{prop_name}' has type '{prop_type}' which is not \"\n                f\"a primitive type. Only {ALLOWED_TYPES} are allowed in elicitation schemas.\"\n            )\n","sourceCodeStart":488,"sourceCodeEnd":517,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/server/elicitation.py#L488-L517","documentation":"MCP elicitation schemas must be flat: a property whose type is 'object' (a nested object) is not allowed. After passing the array checks, the validator rejects any remaining object-typed property to keep schemas limited to primitive fields.","triggerScenarios":"A response model with a nested BaseModel/dataclass/dict field (e.g. address: Address) whose property schema is {\"type\": \"object\", ...} during get_elicitation_schema validation.","commonSituations":"Composing response models from sub-models; copying a config schema into an elicitation response type; Pydantic models with dict-typed fields.","solutions":["Flatten nested models into primitive properties on the response type (e.g. address_city, address_zip)","Run separate elicitations per nested object","Move structured/nested data collection to a tool with structured output"],"exampleFix":"// before\nclass Address(BaseModel):\n    city: str\nclass Form(BaseModel):\n    address: Address\n// after\nclass Form(BaseModel):\n    address_city: str","handlingStrategy":"validation","validationCode":"def check_no_nested_objects(schema: dict) -> None:\n    for name, prop in schema.get(\"properties\", {}).items():\n        if prop.get(\"type\") == \"object\":\n            raise TypeError(f\"field '{name}' is a nested object; flatten it\")","typeGuard":"def has_nested_object_field(schema: dict) -> bool:\n    return any(\n        isinstance(p, dict) and p.get(\"type\") == \"object\"\n        for p in schema.get(\"properties\", {}).values()\n    )","tryCatchPattern":"try:\n    schema = get_elicitation_schema(response_type)\nexcept TypeError as e:\n    if \"nested objects are not allowed\" in str(e):\n        logger.error(\"flatten nested models into primitive fields\")\n        return None\n    raise","preventionTips":["Keep elicitation response models flat: only str/int/float/bool/Enum/Literal fields","Flatten sub-models into prefixed primitive fields (address_city, address_zip)","Avoid dict-typed fields in elicitation models","Run schema validation in CI to catch nested models before deployment"],"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"}