stacklok / stacklok/toolhive

MCPRemoteProxy in Kubernetes fails to Initialize when transport `!= stdio`

Open
#4,293 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug kubernetes operator proxy transport
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Bug description

The MCPRemoteProxy runs the proxyrunner container to proxy connections to a upstream MCP server.
The proxyrunner container will always fail to initialise as it is trying to connect to localhost, it does not attempt to connect to the upstream remoteURL but will use the configured port.

Flow:

The remoteURL is setup and configured here but the value is then not used or overwritten to generate the serverURL.

Steps to reproduce

Deploy a MCPRemoteProxy with streamable-http in Kubernetes using the Operator (mine was using ghcr.io/stacklok/toolhive/proxyrunner:v0.12.2)
e.g Deploy a Github MCPRemoteProxy

Expected behavior

When the container is initialising it should be initialising with the upstream MCP server

Actual behavior

When the container is initialising it is hardcoded to contact localhost

Environment (if relevant)

  • ToolHive version: v0.12.2 of the Operator and associated CRDs

Additional context

Unsure if this intended functionality but it will always error out after 5mins. This does not affect the MCPRemoteProxy functionality, as far as can be told.

Logs:

{"time":"2026-03-19T18:37:49Z","level":"INFO","msg":"Successfully loaded configuration from /etc/runconfig/runconfig.json"}
{"time":"2026-03-19T18:37:49Z","level":"INFO","msg":"auto-discovered and loaded configuration from runconfig.json file"}
{"time":"2026-03-19T18:37:49Z","level":"WARN","msg":"Secret manager not available, OAuth tokens will not be persisted","error":"secrets provider not configured. Please run 'thv secret setup' to configure a secrets provider first"}
{"time":"2026-03-19T18:37:49Z","level":"INFO","msg":"Waiting for MCP server to be ready","endpoint":"http://localhost:8081/mcp","timeout":300000000000}
...
{"time":"2026-03-19T18:42:50Z","level":"WARN","msg":"initialize not successful, but continuing","error":"initialize not successful after 5m1.300990965s (155 attempts)"}
Workload started successfully. Press Ctrl+C to stop.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/runner/runner.go around the remoteURL setup (lines 329-384), the localhost reference near line 403, and waitForInitializeSuccess near line 757; also read pkg/transport/url.go. Reproduce a streamable-http MCPRemoteProxy in Kubernetes with the Operator, then verify initialization targets the configured upstream remoteURL instead of localhost and does not wait five minutes before continuing.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.