-
Notifications
You must be signed in to change notification settings - Fork 545
Convert EverythingServer to use Streamable HTTP #709
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
Conversation
Well this may not be ideal because you can't comment on unchanged lines, and that's exactly where we probably need comments. So I'll just note here:
|
Maybe put all the server logic in an assembly of its own and then reference it from each a STDIO project and an HTTP project with the requisite (quite slim) boilerplate for each? Makes it much more useful as a sample than more complex ways of keeping it in one project, I think. Also helps it be a reference for porting a server from one transport to another. On the other hand if there is a better and more idiomatic pattern for multi-transport server projects, it should follow that I suppose. |
I like that idea @PederHP. One of the primary goals of this PR is just to show in the sample how advanced features can work with the Streamable HTTP transport. There are some key differences from the STDIO transport, even if you don't rely on any HTTP-specific concepts, primarily because the IMcpServer is a singleton service in STDIO mode, but not in Streamable HTTP mode where there are multiple IMcpServer instances which are not 1:1 with the ASP.NET Core request scope. Splitting this sample so the handlers are all implemented in a class library with slim STDIO and HTTP projects that contain basically just Program.cs seems like the most straightforward way to achieve this. We've also discussed trying to improve the local development experience by adding a command line switch to go between stdio and HTTP transports. This would be nice because while stdio is preferred for most local MCP servers, it's harder to debug during development. We figure that you probably wouldn't need much customization of your ASP.NET Core app in this development-focused mode, and just adding a command line switch would be easier than managing three separate projects. The downside is that it's more complex and requires the ASP.NET Core runtime even if you decide to use just STDIO. For any scenario where you're considering having both a stdio MCP server and an HTTP MCP server for real remote usage rather than just development, I'd definitely go for a multi-project architecture like you suggest, so it's probably worth having at least one sample demonstrates that project structure. |
I think I have addressed all of @halter73 's comments. I am still testing to make sure things work as expected but would appreciate feedback on the SubscriptionManager implementation. |
cf79126
to
4bb26f0
Compare
I reworked the resource subscriptions and I think everything is working now. @halter73, @eiriktsarpalis please have another look and let me know if there is anything else that needs fixing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be interesting to demonstrate how you can share code for an HTTP and stdio everything server. We could create EverythingServer.Http, EverythingSerever.Stdio and EverythingServer.Core projects. And the Core project could have an AddEverythingMcpHandlers(this IMcpServerBuilder builder, ConcurrentDictionary<string, ConcurrentDictionary<string, byte>> subscriptions)
method. It might even make sense to add something like public class SubscriptionCollection : ConcurrentDictionary<string, ConcurrentDictionary<string, byte>>
to the core project.
The only thing that couldn't be shared is Program.cs. The Stdio project would use hosted services to manage subscriptions, and the Http project would do the RunSessionHandler logic.
Co-authored-by: Stephen Halter <[email protected]>
Here's a start at converting the EverythingServer to Streamable HTTP.
There are some things still to fix, but I want to get this posted so folks can have a look.
And we still want to consider how we could make this functional for either STDIO or HTTP.