Skip to content

Spawn a container per client for stdio #428

Open

Description

@JAORMX

Feature

In order to support multiple clients, we will need to spawn a new STDIO container per client connecting to the MCP proxy.
This should be transparent to the end user, and they can treat it as a single MCP server.

Background

The STDIO transport was not made to handle multiple client connection and may be behave in unexpected ways if multiple clients are connected to the same STDIO MCP server.

One of the issues that arrises is if multiple clients send an initialize request, ToolHive currently forwards the request to the STDIO workload, which may reject the request or behave unexpectedly, since this is not described by the protocol.

The proxy will need to detect when it gets a new client connection and spawn a new server when this happens. We also need to be able to remove an MCP server if a client disconnects.

This was initiated from a conversation with Bob Dickinson [1]

[1] https://discord.com/channels/1184987096302239844/1358845587189006367/1373186442129440788

Future Enhancements

Once we have this functionality, it's possible to reuse it for:

  1. Scaling in k8s
  2. Enhancing authorization in k8s, by creating a new STDIO container for each user, with their appropriate credentials.

Activity

  1. added
    enhancement
    p0
    on May 28, 2025
  2. self-assigned this
    on May 28, 2025
  3. ChrisJBurns commented on Jul 21, 2025

    @ChrisJBurns
    Collaborator

    This is being investigated under #1062. When we have confirmed findings, we can go forward with a solution. I've already got a "attach per request" implementation working locally. I just need to work on it some more

  4. removed theissue type on Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementp0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions