Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Is there a way to run multiple stateful MCP servers?

Open
#814 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, redis

Research direction

Start with StatefulSessionManager and the ISessionStorage, SessionMiddleware, and MapMcp entry points shown in the issue. Trace how session IDs are stored and retrieved across multiple server instances, then determine what shared storage behavior is needed so multiple stateful MCP servers no longer produce "Session id not found" errors.

Written by the indexing model from the issue text.

Description

enhancement needs confirmation

As the title says, is there anyway to operate multiple stateful MCP servers without running into "Session id not found" errors?

It looks like the "session id not found" error stems from caching session ids in an in-memory dictionary in StatefulSessionManager. Is there a way in the API to, may be, swap that with Redis or use AspNetCore's default session management with a shared cache with the MCP server?

Something along the lines of (which is not working at the moment)

class Program
{
    static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        builder.Services.Configure<SessionSettings>(
            builder.Configuration.GetSection(SessionSettings.SectionName));

        var sessionConfig = builder.Configuration
            .GetSection(SessionSettings.SectionName)
            .Get<SessionSettings>() ?? new SessionSettings();

        if (sessionConfig.StorageType.Equals("Redis", StringComparison.OrdinalIgnoreCase))
        {
            if (string.IsNullOrEmpty(sessionConfig.RedisConnectionString))
                throw new InvalidOperationException("Redis connection string is required");
            builder.Services.AddSingleton<ISessionStorage>(_ =>
                new RedisSessionStorage(sessionConfig.RedisConnectionString));
        }

        builder.Services.AddMcpServer()
            .WithHttpTransport()
            .WithToolsFromAssembly();

        var app = builder.Build();

        app.UseMiddleware<SessionMiddleware>();
        app.MapMcp();
        app.Run("http://localhost:3000");
    }
}
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

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.

More from modelcontextprotocol/csharp-sdk

All issues in modelcontextprotocol/csharp-sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.