Skip to content

CLI allows a duplicate thv run when you don't specify --name #1704

@danbarr

Description

@danbarr

Bug description

In the ToolHive CLI, you can run the same MCP server from the registry twice, resulting in a broken workload.

Steps to reproduce

thv run fetch
thv list

Observe the MCP starts OK. Then run the same command:

thv run fetch
thv list -a

The CLI does not block the second attempt to start the workload with the auto-generated name of "fetch", and instead the existing server is broken, and stuck in "starting" state.

Expected behavior

When you explicitly use the --name parameter, thv stops you.

$ thv run fetch

$ thv run --name fetch fetch
Error: workload with name 'fetch' already exists

The same thing should happen with auto-generated names.

Actual behavior

thv attempts to start a second instance of fetch even though it already exists.

After the second thv run fetch command, thv list -a shows:

thv list -a
NAME    PACKAGE                                     STATUS     URL                          PORT    TOOL TYPE   GROUP     CREATED AT
fetch   ghcr.io/stackloklabs/gofetch/server:0.0.5   starting   http://127.0.0.1:27018/mcp   27018   mcp         default   2025-09-03 12:08:32.961647 -0400 EDT

And the log file at ~/Library/Application Support/toolhive/logs/fetch.log shows:

12:08PM	INFO	Container fetch and proxy are already running
Workload fetch restarted successfully

Running thv restart fetch does bring it back into a healthy state.

Environment (if relevant)

  • OS/version: macOS, Docker Desktop
  • ToolHive version: v0.2.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions