Describe the bug
When [McpServerToolType] class has an constructors with arguments need to be dependency injected, it will throw "Cannot resolve scoped service 'xxx' from root provider." when the function was been called by MCP.
To Reproduce
Steps to reproduce the behavior:
I forked this project and built a branch for the Test: https://github.com/JeffreySu/mcp-csharp-sdk/tree/DI-Error-Test/samples/AspNetCoreSseServer
You can run this project and add the Server to a host(like Cursor), then launch "Echo" function, then you can see the error
Expected behavior
Constructors with arguments should be well supported.
Logs
Additional context
For this test project, I added a new class named MyData, and added it to DI register progress:
Then add MyData as a parameter to ctor. of EchoTool class:
