Skip to content

Support configuring container engine socket path via config file #4612

Description

@kantord

Current Behavior

Socket paths can only be overridden via environment variables:

  • TOOLHIVE_DOCKER_SOCKET
  • TOOLHIVE_PODMAN_SOCKET
  • TOOLHIVE_COLIMA_SOCKET

These are checked in pkg/container/docker/sdk/client_unix.go before falling back to auto-detection of standard socket locations. There is no way to persist this configuration in the ToolHive config file (~/.config/toolhive/config.yaml), meaning users with non-standard socket paths must set environment variables in every shell session or wrapper script.

Proposed Change

Add socket path fields to the Config struct in pkg/config/config.go, allowing users to configure them once via thv config or by editing the YAML file directly:

container_runtime:
  docker_socket: /run/user/1000/docker.sock
  podman_socket: /run/user/1000/podman/podman.sock
  colima_socket: /home/user/.colima/custom/docker.sock

Socket resolution in findPlatformContainerSocket would check sources in this order, preserving existing precedence:

  1. Environment variable (existing)
  2. Config file (new)
  3. Auto-detection of standard paths (existing)

Motivation

Configuring environment variables across GUI and CLI apps can be a bad experience, because there are various ways env variables can be set up, and not all of them are accessible by both GUI and CLI processes - it can actually even depend on how the process is launched.

Misconfiguration is hard to spot, but can lead to confusing, unexpected experiences. This is not user friendly, because users should not need to have a deep understanding of how their operating system handles environment variables across different ways of launching apps just to be able to use ToolHive.

See [this Discord thread for a concrete user report that illustrates the problem.

Activity

  1. added
    enhancement
    on Apr 7, 2026
  2. added
    cli
    on Apr 7, 2026
  3. value-added-korea commented on Apr 8, 2026

    @value-added-korea

    What I have observed is that the Toolhive UI WILL not work at all with docker rootless, for me not an issue truly never a fan of docker really.

    following the Discord chat I used thv cli to set up a group, then added the mcp servers to that group and then finally the mcp-optimizer.

    thv run --group optimizer --network host -e TOOLHIVE_HOST=127.0.0.1 mcp-optimizer      19:30:52
    
    {"time":"2026-04-08T19:31:05+09:00","level":"INFO","msg":"Image not found locally, pulling...","image":"ghcr.io/stackloklabs/mcp-optimizer:0.2.7"}
    {"time":"2026-04-08T19:31:05+09:00","level":"INFO","msg":"pulling image","image":"ghcr.io/stackloklabs/mcp-optimizer:0.2.7"}
    Successfully pulled ghcr.io/stackloklabs/mcp-optimizer:0.2.7
    {"time":"2026-04-08T19:32:06+09:00","level":"INFO","msg":"logging to","path":"/home/none/.local/share/toolhive/logs/mcp-optimizer.log"}
    ~ ❯ thv list -a                                                                     1m 12s 19:32:06
    NAME            PACKAGE                                    STATUS    URL                          PORT    GROUP       CREATED
    mcp-optimizer   ghcr.io/stackloklabs/mcp-optimizer:0.2.7   running   http://127.0.0.1:43930/mcp   43930   optimizer   2026-04-08 19:32:06.399867566 +0900 KST
    ~ ❯ thv list -a                                                                            19:32:15
    

    added more to the group using thv

    ~ ❯ thv list -a                                                                                                                                                               19:46:55
    NAME                        PACKAGE                                        STATUS    URL                          PORT    GROUP       CREATED
    context7-optimizer          ghcr.io/stacklok/dockyard/npx/context7:2.1.4   running   http://127.0.0.1:25466/mcp   25466   optimizer   2026-04-08 19:36:16.586096615 +0900 KST
    fetch-optimizer             ghcr.io/stackloklabs/gofetch/server:1.0.3      running   http://127.0.0.1:37065/mcp   37065   optimizer   2026-04-08 19:34:59.779432492 +0900 KST
    io-github-stacklok-memory   docker.io/mcp/memory:latest                    running   http://127.0.0.1:45149/mcp   45149   optimizer   2026-04-08 19:45:26.199069946 +0900 KST
    mcp-optimizer               ghcr.io/stackloklabs/mcp-optimizer:0.2.7       running   http://127.0.0.1:43930/mcp   43930   optimizer   2026-04-08 19:32:06.399867566 +0900 KST
    

    In Toolhive UI, I was able to add mcp server, they would be added to the default group, I had to them copy them to the "optimizer" group and then delete them from the default group including the mcp-optimizer:

               ghcr.io/stackloklabs/mcp-optimizer:0.2.7     http://127.0.0.1:43930/mcp   43930   optimizer  
    

    THEN I attempted to use the Toolhive UI Manage Clients, and there was no mcp configuration produced.

    I switched to the optimizer group, tried to manage clients, no mcp configuration generated, no error message no log messages.

    Under settings, I enable the MCP Optimizer, set the group from default to the thv cli "optimizer" group,

    Then this was thv list

    ~ ❯ thv list -a                                                                                                                                                               19:50:05
    NAME                        PACKAGE                                        STATUS    URL                          PORT    GROUP               CREATED
    context7-optimizer          ghcr.io/stacklok/dockyard/npx/context7:2.1.4   running   http://127.0.0.1:25466/mcp   25466   optimizer           2026-04-08 19:36:16.586096615 +0900 KST
    fetch-optimizer             ghcr.io/stackloklabs/gofetch/server:1.0.3      running   http://127.0.0.1:37065/mcp   37065   optimizer           2026-04-08 19:34:59.779432492 +0900 KST
    io-github-stacklok-memory   docker.io/mcp/memory:latest                    running   http://127.0.0.1:45149/mcp   45149   optimizer           2026-04-08 19:45:26.199069946 +0900 KST
    mcp-optimizer               ghcr.io/stackloklabs/mcp-optimizer:0.2.7       running   http://127.0.0.1:43930/mcp   43930   optimizer           2026-04-08 19:32:06.399867566 +0900 KST
    toolhive-mcp-optimizer      ghcr.io/stackloklabs/mcp-optimizer:0.2.7       running   http://127.0.0.1:29747/mcp   29747   __mcp-optimizer__   2026-04-08 19:49:43.969295596 +0900 KST
    

    This was the produced client management json for the mcp servers

    {
    	"servers": {
    		"toolhive-mcp-optimizer": {"url": "http://127.0.0.1:29747/mcp", "type": "http"}
    	}
    }

    Went back to the Settings in the Toolhive UI, disable the experimental settings.

    NAME                        PACKAGE                                        STATUS    URL                          PORT    GROUP       CREATED
    context7-optimizer          ghcr.io/stacklok/dockyard/npx/context7:2.1.4   running   http://127.0.0.1:25466/mcp   25466   optimizer   2026-04-08 19:36:16.586096615 +0900 KST
    fetch-optimizer             ghcr.io/stackloklabs/gofetch/server:1.0.3      running   http://127.0.0.1:37065/mcp   37065   optimizer   2026-04-08 19:34:59.779432492 +0900 KST
    io-github-stacklok-memory   docker.io/mcp/memory:latest                    running   http://127.0.0.1:45149/mcp   45149   optimizer   2026-04-08 19:45:26.199069946 +0900 KST
    mcp-optimizer               ghcr.io/stackloklabs/mcp-optimizer:0.2.7       running   http://127.0.0.1:43930/mcp   43930   optimizer   2026-04-08 19:32:06.399867566 +0900 KST
    

    And this is the output of Manage Clients.

    {
    	"servers": {
    		"context7-optimizer":        {"url": "http://127.0.0.1:25466/mcp", "type": "http"},
    		"mcp-optimizer":             {"url": "http://127.0.0.1:43930/mcp", "type": "http"},
    		"fetch-optimizer":           {"url": "http://127.0.0.1:37065/mcp", "type": "http"},
    		"io-github-stacklok-memory": {"url": "http://127.0.0.1:45149/mcp", "type": "http"}
    	}
    }

    Then using the thv cli to set up the clients:

    {
    	"mcpServers": {
    		"context7-optimizer":        {"serverUrl": "http://127.0.0.1:25466/mcp"},
    		"mcp-optimizer":             {"serverUrl": "http://127.0.0.1:43930/mcp"},
    		"fetch-optimizer":           {"serverUrl": "http://127.0.0.1:37065/mcp"},
    		"io-github-stacklok-memory": {"serverUrl": "http://127.0.0.1:45149/mcp"}
    	}
    }

    The above issues pertain too:

    1. Environment variable (existing)
    2. Config file (new)
    3. Auto-detection of standard paths (existing

    Both thv cli and Toolhive UI are failing to "read" the current configurations which each have created by either the command line or the UI.

    For the client configuration, if there is a ghcr.io/stackloklabs/mcp-optimizer:0.2.7 present then the client configuration should only be using:

    "mcp-optimizer":             {"serverUrl": "http://127.0.0.1:43930/mcp"},

    That behavior should be reviewed/considered with the proposed changes.

    The UI should really only be issuing commands to the cli.
    If the intent is to have the ability to run a systmed Toolhive server AND a User space server then that behavior needs to have configuration options available and really, it is very complex, there should be configuration files which direct the behavior with both thv cli and Toolhive UI.

    I think the project is very promising but until some of these issues are addressed it is a wee bit too "bouncy" for large scale adoption.

    Good work really,

    Cheers

  4. self-assigned this
    on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

clienhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions