Skip to content

Support using WithStreamServerTransport for multiple in-process mcp servers #1172

@raffaeler

Description

@raffaeler

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.

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