Register List<object> JSON metadata for Native AOT array tool arguments - #1872
Open
girishkvs wants to merge 1 commit into
Open
Register List<object> JSON metadata for Native AOT array tool arguments#1872girishkvs wants to merge 1 commit into
girishkvs wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 982e92aa-0c58-4fa5-a59c-8645c6c241f3
This was referenced Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1846
Problem
Passing an array argument to a tool throws at runtime under Native AOT:
ToArgumentsDictionaryserializes each argument value throughMcpJsonUtilities.JsonContext. AList<object>argument has no generated metadata there, so the source-generated resolver has nothing to return and serialization fails. Trimmed/AOT apps hit this on any array-valued tool parameter.Change
Add
[JsonSerializable(typeof(List<object>))]toMcpJsonUtilities.JsonContext, next to the existingIDictionary<string, object>andIReadOnlyDictionary<string, object>entries.Extend the AOT compatibility test app with a
Join(string[] items)tool and invoke it with a populated and an emptyList<object>, so the scenario is covered bymake test-aot.Validation
make test-aotequivalent —dotnet publishwithPublishAot=truethen run the produced native binary:Success!, exit 0JsonSerializableline revertedNotSupportedExceptionas above, exit non-zeroThe new test app assertions fail without the one-line
McpJsonUtilitieschange, so the regression is covered rather than assumed.dotnet build src/ModelContextProtocol.Coreis clean acrossnetstandard2.0,net8.0,net9.0andnet10.0— 0 warnings, 0 errors.