Skip to content

Spawn a container per client for stdio #428

@JAORMX

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestp0High

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions