feat(server): add MarshalResult to McpServerToolCreateOptions - #1874
Open
jstar0 wants to merge 1 commit into
Open
feat(server): add MarshalResult to McpServerToolCreateOptions#1874jstar0 wants to merge 1 commit into
jstar0 wants to merge 1 commit into
Conversation
Tools created via McpServerTool.Create from MethodInfo/Delegate could not customize AIFunctionFactoryOptions.MarshalResult because the factory options were built internally with an identity pass-through; the only workaround was reflecting into private DeriveOptions/CreateAIFunctionFactoryOptions methods. Add a MarshalResult delegate property that is threaded through option cloning and CreateAIFunctionFactoryOptions, defaulting to the existing identity pass-through when unset. Closes modelcontextprotocol#1602
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.
Summary
MarshalResultdelegate property toMcpServerToolCreateOptions, matching the shape ofAIFunctionFactoryOptions.MarshalResult.CreateAIFunctionFactoryOptions, so tools created fromMethodInfo/Delegatecan customize result marshaling without reflecting into the privateDeriveOptions/CreateAIFunctionFactoryOptionsmethods.Motivation and context
Closes #1602. Tools created from a method previously had no supported way to set
AIFunctionFactoryOptions.MarshalResult; the options class is built internally with a hard-coded pass-through, and the only workaround was invoking private methods via reflection, which is not stable across versions. The previous attempt (#1761) was closed by its author for lack of review rather than technical objections; this PR resubmits the same narrow shape on the currentmain.Validation
dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --filter "Execution!=Manual"— 2,361 passed, 3 skipped, 0 failed.dotnet build— 0 warnings, 0 errors.Breaking changes
None. The new option is nullable and unset by default.