Skip to content

handle impetulant client config changes #2499

Closed

Description

@therealnb

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.

Activity

  1. added
    bug
    enhancement
    cli
    on Nov 7, 2025
  2. self-assigned this
    on Nov 7, 2025
  3. added a commit that references this issue on Nov 7, 2025
    8ce251a
  4. therealnb commented on Nov 7, 2025

    @therealnb
    Author

    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.

  5. therealnb commented on Nov 10, 2025

    @therealnb
    Author

    The fix cannot currently be merged due to #2504 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugclienhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions