Describe the bug
Cannot run an HttpListenerSseServerTransport server
System.InvalidOperationException: No constructor for type 'ModelContextProtocol.Protocol.Transport.HttpListenerSseServerTransport' can be instantiated using services from the service container and default values.
The extension method attempts to register a Singleton, but the constructor requires server and port
To Reproduce
Steps to reproduce the behavior:
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddMcpServer()
.WithHttpListenerSseServerTransport()
.WithToolsFromAssembly();
Expected behavior
The HTTP SSE server should run.
Logs
Mcp.Server[0]
Host terminated unexpectedly
System.InvalidOperationException: No constructor for type 'ModelContextProtocol.Protocol.Transport.HttpListenerSseServerTransport' can be instantiated using services from the service container and default values.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, ServiceIdentifier serviceIdentifier, Type implementationType, CallSiteChain cal
Additional context
I'm really new to MCP- it's awesome, thanks for all the hard work - great to have a c# SDK so early. I'll probably get the source down and see if I can fix it - I'll submit a PR if I can. Cheers!
|
public static IMcpServerBuilder WithHttpListenerSseServerTransport(this IMcpServerBuilder builder) |
|
public HttpListenerSseServerTransport(string serverName, int port, ILoggerFactory loggerFactory) |
Describe the bug
Cannot run an HttpListenerSseServerTransport server
The extension method attempts to register a Singleton, but the constructor requires server and port
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The HTTP SSE server should run.
Logs
Additional context
I'm really new to MCP- it's awesome, thanks for all the hard work - great to have a c# SDK so early. I'll probably get the source down and see if I can fix it - I'll submit a PR if I can. Cheers!
csharp-sdk/src/ModelContextProtocol/Configuration/McpServerBuilderExtensions.cs
Line 358 in 330e526
csharp-sdk/src/ModelContextProtocol/Protocol/Transport/HttpListenerSseServerTransport.cs
Line 46 in 330e526