Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Disallow integer values for string enums in MCP serialization - #2073

Open
Japkutija wants to merge 1 commit into
modelcontextprotocol:mainfrom
Japkutija:fix/disallow-integer-enum-values
Open

Japkutija wants to merge 1 commit into
modelcontextprotocol:mainfrom
Japkutija:fix/disallow-integer-enum-values

Conversation

@Japkutija

Copy link
Copy Markdown

Fixes #2071.

Changes

  • Configured McpJsonUtilities.CreateDefaultOptions with new JsonStringEnumConverter(namingPolicy: null, allowIntegerValues: false).
  • Added [EditorBrowsable(EditorBrowsableState.Never)] public sealed class DisallowIntegerJsonStringEnumConverter<TEnum> in ModelContextProtocol.Protocol (public so external JsonSerializerContexts like McpSkillsJsonContext avoid SYSLIB1220) and applied it to Role, LoggingLevel, CacheScope, ContextInclusion, and McpTaskStatus. Left CacheScopeConverter unchanged for SEP-2549 compatibility.
  • Added unit and tool-invocation tests covering integer/numeric-string rejection, valid strings/[Flags], and undefined enum serialization.

Verification

  • ModelContextProtocol.Tests (net10.0, non-Node): 3,653 passed, 0 failed.
  • Targeted enum/task/tool tests with JsonSerializerIsReflectionEnabledByDefault=false: 154 passed, 0 failed.
  • ModelContextProtocol.AotCompatibility.TestApp (Release) and multi-TFM dotnet pack (ApiCompat) for Core and Extensions.Tasks: 0 warnings, 0 errors.

Note

Prepared with AI assistance.

Copilot AI balanced review requested due to automatic review settings December 3, 2026 19:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool arguments accept integers for string enum parameters, including undefined values

2 participants