Skip to content

UI/CLI coexistence issue: thv restart doesn't re-start a missing proxy process for a server started via the UI #2305

@danbarr

Description

@danbarr

Bug description

A few of my proxy processes got killed through some other testing. These servers were last started/restarted using the UI. I thought that thv restart --all on the CLI would bring the proxy processes back in one shot, but it did not.

Discovered that it's a UI/CLI coexistence issue. For MCPs started using the CLI, thv restart does detect the missing proxy process (even though the container is still running) and successfully restart them.

For MCPs started using the UI, it does not.

Steps to reproduce

Run an MCP server using the UI, then kill its thv process but leave the container running. For this, I used fetch.

# confirm the process ran from the UI's copy of `thv`
pgrep -lf "thv .* fetch"
# output: 37100 /Applications/ToolHive.app/Contents/Resources/bin/darwin-arm64/thv restart fetch --foreground

# this should kill the fetch server's `thv` process:
pkill -f "thv .* fetch"

# confirm it's gone:
pgrep -lf "thv .* fetch"

# now try to restart using the CLI
thv restart fetch

The restart checks the container status, but does not notice the missing thv process to re-start it:

12:25PM	INFO	Container fetch is already running
Workload fetch restarted successfully

Expected behavior

I would expect that the CLI and UI can coexist, and that the CLI restart would detect the missing proxy process even though it was last started using the UI.

Compare to the output from a thv restart for the same MCP started using the CLI:

12:27PM	INFO	Loaded configuration from state for fetch
12:27PM	INFO	Container fetch is running but workload is not in running state. Stopping container...
12:27PM	INFO	Container fetch stopped
12:27PM	INFO	Starting tooling server fetch...
12:27PM	INFO	Logging to: /Users/dan/Library/Application Support/toolhive/logs/fetch.log
12:27PM	INFO	MCP server is running in the background (PID: 38204)
12:27PM	INFO	Use 'thv stop fetch' to stop the server
Workload fetch restarted successfully

Actual behavior

The thv restart sees the container is already running but doesn't notice the missing proxy process.

Environment (if relevant)

  • OS/version: macOS, Docker Desktop
  • ToolHive version: CLI v0.4.0, UI v0.11.0

Additional context

I could individually toggle the broken MCPs in the UI to bring them back, or use thv stop --all and THEN run thv restart --all, but I also expected that a simple thv restart --all would work to reconcile their status.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliChanges that impact CLI functionalityproxy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions