Repository navigation
Add stdio support for EverythingServer sample (continues #950) - #1880
FengFafa97 wants to merge 13 commits into
Conversation
Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
Co-authored-by: asklar <22989529+asklar@users.noreply.github.com>
- EverythingServerExtensions.cs: SampleAsync's named parameter was renamed to chatOptions upstream; update the call site. - EverythingServer.Core.csproj: suppress MCP9005 (Sampling deprecated per SEP-2577), matching the sibling EverythingServer.Http.csproj. - EverythingServer.Http/Program.cs: suppress MCPEXP002 around the experimental RunSessionHandler assignment, matching the original Program.cs and docs/experimental.md. - launchSettings.json: remove trailing commas that broke JSON parsing and silently disabled both launch profiles. Verified: dotnet build succeeds with 0 warnings/errors, and both transports complete a live MCP initialize handshake (stdio and Streamable HTTP). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Hi @jeffhandley — an update on #950: This PR has been rebased onto the current |
|
Hi @halter73 and @jeffhandley — this part is ready for review. This is the version @asklar split off from #950 and rebased onto the current |
|
Thanks for checking in and following up, @FengFafa97, and for picking up this work and resolving the rebase issues. The Core/HTTP/Stdio split matches the previously discussed direction, and I recommend keeping this PR moving forward. Specifically:
Since the protocol has evolved since the original proposal, @jeffhandley and @halter73, please confirm whether this PR should preserve the existing sample behavior only, or also update the HTTP sample for native Once this PR is completed and merged, we can close #950 as superseded. |
…om main - Core: move the ServerInfo (name/title/description/website/icons) and the multi-icon EchoTool registration from main's Program.cs into AddEverythingMcpHandlers so both the HTTP and stdio hosts expose them. - Http: restore SessionMode = Stateful (and its explanatory comment). The default is now Stateless, so without it sampling, resource subscriptions and RunSessionHandler silently lost their session. - Core: SubscriptionMessageSender sent "notifications/resource/updated"; the spec method is "notifications/resources/updated", so clients never received resource update notifications. Use NotificationMethods.ResourceUpdatedNotification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @tarekgh for the detailed review. I've pushed 91d1b4c (plus a merge of current
¹ The server rejects Two fixes came out of the validation:
On point 3, @jeffhandley @halter73: should this PR only preserve the existing behavior (stateful HTTP, with a note that the session-dependent demonstrations target Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com |
|
A few remaining items before this is ready:
|
| .WithTracing(b => b.AddSource("*").AddHttpClientInstrumentation().SetResourceBuilder(resource)) | ||
| .WithMetrics(b => b.AddMeter("*").AddHttpClientInstrumentation().SetResourceBuilder(resource)) | ||
| .WithLogging(b => b.SetResourceBuilder(resource)) | ||
| .UseOtlpExporter(); |
There was a problem hiding this comment.
Could the OTLP exporter be opt-in, or could the README explain that a collector is expected? The PR author reports that stdio shutdown takes about five seconds when no collector is listening, while the exporter flushes. That can be surprising for a stdio server whose host expects prompt process termination.
| { | ||
| sessionSubscriptions.TryAdd(uri, 0); | ||
|
|
||
| await ctx.Server.SampleAsync([ |
There was a problem hiding this comment.
Could the subscription remain valid when the client does not advertise sampling, or could this code roll back the URI if SampleAsync fails? The URI is added before SampleAsync, which throws when sampling is unsupported. The request then fails, but the subscription remains and the background sender continues notifying it. Since sampling is optional and separate from subscribing, please consider guarding the sample or rolling back on failure.
| ## Running the Server | ||
|
|
||
| ```bash | ||
| dotnet run --project samples/EverythingServer.Http/EverythingServer.csproj |
There was a problem hiding this comment.
This command references EverythingServer.csproj, but the renamed project is EverythingServer.Http.csproj, so it will not run as written. The default-port statement below is stale too: the launch profiles use http://localhost:3001 and https://localhost:7133. Could we update the project paths and port guidance?
| @@ -2,7 +2,7 @@ | |||
| using System.ComponentModel; | |||
| using System.Text.Json; | |||
|
|
|||
There was a problem hiding this comment.
Could we avoid returning the entire process environment from this sample tool? It can expose secrets such as access tokens, connection strings, or cloud credentials to any MCP client that can invoke it. This tool predates the split, but the new stdio server makes it available over that transport too. Please consider safe allowlisted or redacted output, or clearly making this tool unsafe and opt-in.
Continues #950, fixes #889.
This picks up @asklar's branch splitting
EverythingServerintoEverythingServer.Core/EverythingServer.Http/EverythingServer.Stdio,rebases it onto current
main, and fixes the build breaks that surfacedfrom the rebase:
EverythingServerExtensions.cs:SampleAsync's named parameter wasrenamed to
chatOptionsupstream; updated the call site.EverythingServer.Core.csproj: added theMCP9005suppression(Sampling deprecated per SEP-2577) that
EverythingServer.Http.csprojalready had — it doesn't propagate across the project reference.
EverythingServer.Http/Program.cs: restored theMCPEXP002pragmaaround the experimental
RunSessionHandlerassignment, matching theoriginal
Program.csanddocs/experimental.md.launchSettings.json: removed trailing commas that broke JSON parsingand silently disabled both launch profiles.
Verification:
dotnet build: 0 warnings, 0 errors.initializehandshake against each (stdio via piped JSON-RPC, HTTP via a direct
POST to the Streamable HTTP endpoint).
Out of scope for this PR:
main'sProgram.csalso gained newsample content since @asklar's branch was cut (icon/
ServerInfometadatashowcase, explicit stateful
SessionMode). Not ported here to keep thisPR focused on restoring a green build; happy to follow up separately.
Co-Authored-By: Claude Sonnet 5