Skip to content

Error when using: .WithHttpListenerSseServerTransport() #168

@shoshin-labs

Description

@shoshin-labs

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions