modelcontextprotocol / modelcontextprotocol/csharp-sdk

Support using WithStreamServerTransport for multiple in-process mcp servers

Open
#1,172 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs confirmation P3
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

The current implementation register the stream support as a singleton:

builder.Services.AddSingleton<ITransport>(new StreamServerTransport(inputStream, outputStream));

This prevents declaring multiple MCP Server classes in-process and using them with a separate channels.

Reasons for this choice:

  • creating MCP servers in a separate class library so that they can be instantiated in-process or out-of-process depending on the app
  • ability to clearly separate the tools, prompts and resources. Currently I have to mix all the in-process prompts, resources and tools in a single MCP server to be used in-process.
  • avoid creating a separate process just because of the library limitation (performance reasons)

As I mentioned in a discussion, the Model Context Protocol adhere to the "transparency" principle, but the library makes it very difficult to reach. This is the reason why I tagged this as a bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the builder.Services.AddSingleton(new StreamServerTransport(inputStream, outputStream)) registration and inspect how StreamServerTransport is wired to an in-process MCP Server. Trace the channel and service-lifetime assumptions, then verify that multiple MCP Server classes can be declared in-process with separate channels.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.