You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ToolHive doesn't immediately update clients when creating proxies and containers, but it is too quick for some clients leading to issues like #2271. There was a bit of investigation here. Basically, initialise needs to be ready 0.1s after the cursor client is updated.
The current sequence:
Step 1: Container Deployment
Calls runtime.Setup() to deploy the container
For Kubernetes: Waits up to 2 minutes for the StatefulSet to become ready
For Docker: Containers are created and started synchronously, but there's no explicit readiness check beyond Docker's API confirmation
Step 2: Transport/Proxy Start
Creates and starts the HTTP proxy server
Only proceeds if this succeeds
Step 3: Client Update
ONLY AFTER both container deployment AND transport start succeed
Calls clientManager.AddServerToClients() to update client configurations
To make this work we could get the proxy/toolhive to only update clients after it has called a successful initialise.
Alternatively, we could do the equivalent of a k8s health check and not set up the proxy until after it completes health checks. This does have the disadvantage or requiring MCP server to know about health checks. The other approach should work with any MCP server.
I tried a wait loop for the initialise function in this PR.
waitingforinit.mov
The video shows a thv command the rms optimizer, then installs it again.
The left panel is the thv proxy log.
The middle is the cursor/vscode log.
The right is the optimizer container log
You can see the proxy retrying several times, the http server becoming available on the docker container and the client finally updating and able to connect.
This was prompted by optimizer, but the problem and the solution should be fairly generic. Ultimately, this is a bug in the clients, but we can fix it well here.
Activity
fix: wait for initialize endpoint before updating client configs
therealnb commentedon Nov 7, 2025
I tried a wait loop for the initialise function in this PR.
waitingforinit.mov
The video shows a thv command the rms optimizer, then installs it again.
The left panel is the thv proxy log.
The middle is the cursor/vscode log.
The right is the optimizer container log
You can see the proxy retrying several times, the http server becoming available on the docker container and the client finally updating and able to connect.
This was prompted by optimizer, but the problem and the solution should be fairly generic. Ultimately, this is a bug in the clients, but we can fix it well here.
therealnb commentedon Nov 10, 2025
The fix cannot currently be merged due to #2504 (comment)