Skip to content

Error when using: .WithHttpListenerSseServerTransport() #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shoshin-labs opened this issue Mar 31, 2025 · 1 comment
Closed

Error when using: .WithHttpListenerSseServerTransport() #168

shoshin-labs opened this issue Mar 31, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@shoshin-labs
Copy link

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)

@shoshin-labs shoshin-labs added the bug Something isn't working label Mar 31, 2025
@shoshin-labs shoshin-labs changed the title Error when using: builder.Services.AddMcpServer().WithHttpListenerSseServerTransport() Error when using: .WithHttpListenerSseServerTransport() Mar 31, 2025
@IshamMohamed
Copy link

IshamMohamed commented Apr 3, 2025

This is removed in #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants