Skip to content

Error removing client config for servers built from protocol scheme and auto-generated name #360

Closed
@danbarr

Description

@danbarr

Scenario:

  1. Run an MCP server using a protocol scheme, but no --name parameter
  2. ToolHive auto-generates a name, but there's a mismatch between the name shown in thv list and the name added to client configs
  3. Remove the server; ToolHive fails to remove from the client config because of the mismatch

Reproduction:

$ thv run uvx://mcp-server-fetch

$ thv list
CONTAINER ID   NAME                                            IMAGE                                               STATE     TRANSPORT   PORT    URL
666aa88c52bf   toolhivelocal-uvx-mcp-server-fetch-1746827186   toolhivelocal/uvx-mcp-server-fetch:20250509174618   running   stdio       19639   http://localhost:19639/sse#toolhivelocal-uvx-mcp-server-fetch-1746827186

Note the name: toolhivelocal-uvx-mcp-server-fetch-1746827186. Compare to the name in the client config file, example for roo-code, which omits the (random?) -1746827186 suffix:

{
	"mcpServers": {
		"toolhivelocal-uvx-mcp-server-fetch": {"url": "http://localhost:19639/sse#toolhivelocal-uvx-mcp-server-fetch"}
	}
}

Then try to remove the server:

$ thv stop toolhivelocal-uvx-mcp-server-fetch-1746827186
<snipped>
$ thv rm toolhivelocal-uvx-mcp-server-fetch-1746827186
5:47PM INF Removing container toolhivelocal-uvx-mcp-server-fetch-1746827186...
5:47PM INF Deleted run configuration for toolhivelocal-uvx-mcp-server-fetch
5:47PM INF Saved state for toolhivelocal-uvx-mcp-server-fetch removed
5:47PM INF Container toolhivelocal-uvx-mcp-server-fetch-1746827186 removed
5:47PM INF Removing MCP server from client configuration: /Users/dan/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json
5:47PM ERR Failed to patch file: hujson: patch operation 0: value not found
5:47PM INF Successfully removed the MCPServer toolhivelocal-uvx-mcp-server-fetch-1746827186 from the client config file
5:47PM INF Successfully removed MCP server from client configuration: /Users/dan/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json

Note: 5:47PM ERR Failed to patch file: hujson: patch operation 0: value not found is followed by two "Successfully removed" messages, which are not true.

Result:

Entry remains in the mcp_settings.json file:

{
	"mcpServers": {
		"toolhivelocal-uvx-mcp-server-fetch": {"url": "http://localhost:19639/sse#toolhivelocal-uvx-mcp-server-fetch"}
	}
}

Activity

added theissue type on May 12, 2025
ChrisJBurns

ChrisJBurns commented on May 13, 2025

@ChrisJBurns
Collaborator

@danbarr This has been fixed in #372 feel free to give it a quick test and if you're happy feel free to close

danbarr

danbarr commented on May 13, 2025

@danbarr
CollaboratorAuthor

LGTM, thanks for the fix!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp1Medium

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JAORMX@danbarr@ChrisJBurns

        Issue actions

          Error removing client config for servers built from protocol scheme and auto-generated name · Issue #360 · stacklok/toolhive