stacklok / stacklok/toolhive

Spawn a container per client for stdio

Open
#428 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement p0
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

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.

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 by tracing the MCP proxy's STDIO connection handling and container lifecycle entry points; the issue does not name specific files or tests. Define the behavior for a new client connection, client disconnection, and multiple initialize requests, then add coverage showing that each client receives an isolated STDIO server.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.