Skip to content

handle impetulant client config changes #2499

@therealnb

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcliChanges that impact CLI functionalityenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions