modelcontextprotocol / modelcontextprotocol/csharp-sdk
McpServerToolCreateOptions miss MarshalResult option.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Description
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);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100