Skip to content

Schema attribute enum type hint does not allow null values #270

@acantepie

Description

@acantepie

The Schema attribute's enum property is typed as ?array<int, float|string|int>, which does not allow null values in the array.

The following syntax is correct and is the way to allow a nullable enum value :

  #[Schema(description: 'Sort by property', enum: [null, "foo", "bar"])]
  ?string $sort = null,

Current type hint (src/Capability/Attribute/Schema.php line 67-69):

/** @var ?array<int, float|string|int> */
public ?array $enum = null;

Suggested fix:

/** @var ?array<int, float|string|int|null> */
public ?array $enum = null;

Version: mcp/sdk v0.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featureSchemaIssues & PRs related to the Schema componentbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions