Skip to content

Add custom tool result marshaling - #1761

Closed
andyst-dev wants to merge 1 commit into
modelcontextprotocol:mainfrom
andyst-dev:feat/tool-marshal-result
Closed

Add custom tool result marshaling#1761
andyst-dev wants to merge 1 commit into
modelcontextprotocol:mainfrom
andyst-dev:feat/tool-marshal-result

Conversation

@andyst-dev

Copy link
Copy Markdown

Summary

  • add a MarshalResult delegate to McpServerToolCreateOptions
  • pass the custom delegate to AIFunctionFactoryOptions while preserving the existing pass-through default
  • preserve the delegate when deriving tool options
  • add a regression test covering the result value, declared return type, cancellation token, and transformed tool response

Motivation and context

This lets reflection-created MCP tools customize AIFunction result marshaling without recreating the SDK's private option-derivation logic.

Closes #1602.

Validation

  • dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --framework net10.0 --filter FullyQualifiedName~SupportsCustomResultMarshaling — 1 passed
  • dotnet test tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj --framework net10.0 --filter "Execution!=Manual" — 2,335 passed, 3 skipped
  • make generate-docs — Release build and DocFX succeeded with 0 warnings and 0 errors
  • git diff --check

Breaking changes

None. The new option is nullable and the existing pass-through behavior remains the default.

@andyst-dev
andyst-dev force-pushed the feat/tool-marshal-result branch from 782c2fc to a7fbc11 Compare August 6, 2026 06:35
@andyst-dev

Copy link
Copy Markdown
Author

Closing as abandoned: this PR has had no maintainer review for over a month in an otherwise active repo, and the maintainers have not engaged with it. The work remains available in the fork branch if the team ever wants it (reopen anytime).

@andyst-dev andyst-dev closed this Sep 4, 2026
@andyst-dev
andyst-dev deleted the feat/tool-marshal-result branch September 4, 2026 08:05
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.

McpServerToolCreateOptions miss MarshalResult option.

2 participants