Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

McpServerToolCreateOptions miss MarshalResult option.

Open
#1,602 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start with McpServerToolCreateOptions, AIFunctionFactoryOptions, McpServerTool.Create, DeriveOptions, and CreateAIFunctionFactoryOptions to trace how creation settings flow. Add a supported way to configure MarshalResult through the tool creation options, then verify that the configured callback reaches AIFunctionFactoryOptions without reflection.

Written by the indexing model from the issue text.

Description

enhancement P2 ready for work

Is your feature request related to a problem? Please describe.
i need MarshalResult for AIFunctionFactoryOptions, but the CreateAIFunctionFactoryOptions assign the MarshalResult=new ValueTask(result).
i without any solution to reset it, i just can to create a AIFunction,then use the AIFunction to create McpServerTool.

but i will loss many settings from DeriveOptions and CreateAIFunctionFactoryOptions(private methods).

Describe the solution you'd like
please add a MarhsalResult option in McpServerToolCreateOptions, then i can initialize the AIFunctionFactoryOptions.MarshalResult.

or add a Action< AIFunctionFactoryOptions > initailizeAIFunctionOptions, then call after CreateAIFunctionFactoryOptions, give me a chance to update the aifunction options.

        public new static AIFunctionMcpServerResource Create(MethodInfo method, object? target, McpServerResourceCreateOptions? options
            , Action<AIFunctionFactoryOptions> initializeAIFunctionFactoryOptions = null)
        {
            Throw.IfNull(method, "method");
            options = DeriveOptions(method, options);

            var aioptions = CreateAIFunctionFactoryOptions(method, options);
            initializeAIFunctionFactoryOptions?.Invoke(aioptions);

            return Create(AIFunctionFactory.Create(method, target, aioptions), options);
        }
        public new static AIFunctionMcpServerTool Create(MethodInfo method, object? target, McpServerToolCreateOptions? options
            , Action<AIFunctionFactoryOptions> initializeAIFunctionFactoryOptions = null)
        {
            Throw.IfNull(method, "method");
            options = DeriveOptions(method, options);

            var aioptions = CreateAIFunctionFactoryOptions(method, options);
            initializeAIFunctionFactoryOptions?.Invoke(aioptions);

            return Create(AIFunctionFactory.Create(method, target, aioptions), options);
        }`
        public new static AIFunctionMcpServerPrompt Create(MethodInfo method, object? target, McpServerPromptCreateOptions? options
            , Action<AIFunctionFactoryOptions> initializeAIFunctionFactoryOptions = null)
        {
            Throw.IfNull(method, "method");
            options = DeriveOptions(method, options);

            var aioptions = CreateAIFunctionFactoryOptions(method, options);
            initializeAIFunctionFactoryOptions?.Invoke(aioptions);

            return Create(AIFunctionFactory.Create(method, target, aioptions), options);
        }

Describe alternatives you've considered
currently , i just can use reflection to invoke DeriveOptions and CreateAIFunctionFactoryOptions,
but this was not stable in the future version. please add a standard MarshalResult options for my feature.

                    var createoptions = new McpServerToolCreateOptions()
                    {
                        Name = mcpname,
                        SerializerOptions = serializeroptions,
                    };
                    createoptions = (McpServerToolCreateOptions)DummyInstance.Value.Tool_DeriveOptions.Invoke(null, [mcpmethod, createoptions]);

                    var aifuncoptions = (AIFunctionFactoryOptions)DummyInstance.Value.Tool_CreateAIFunctionFactoryOptions.Invoke(null, [mcpmethod, createoptions]);
                    aifuncoptions.MarshalResult = OnToolMarshalResult;

                    var aifunc = AIFunctionFactory.Create(mcpmethod, instance, aifuncoptions);
                    var tool = McpServerTool.Create(aifunc, createoptions);
                    log.Info($"McpTool 已建立 - tool:{tool}。\r\n{mcpmethod}");

                    tools.Add(tool);

Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/csharp-sdk

All issues in modelcontextprotocol/csharp-sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.