Skip to content

Commit 7177e2e

Browse files
Changes MCP_HOST set by toolhive to 0.0.0.0
Bind MCP_HOST to all interfaces by default so that the mcp server in the container is reachable from the host
1 parent ff25621 commit 7177e2e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

cmd/thv/app/run_flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func AddRunFlags(cmd *cobra.Command, config *RunFlags) {
9595
cmd.Flags().StringVar(
9696
&config.TargetHost,
9797
"target-host",
98-
transport.LocalhostIPv4,
98+
transport.TargetHostIPv4,
9999
"Host to forward traffic to (only applicable to SSE or Streamable HTTP transport)")
100100
cmd.Flags().StringVar(
101101
&config.PermissionProfile,

docs/cli/thv_run.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/transport/http.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121
LocalhostName = "localhost"
2222
// LocalhostIPv4 is the standard IPv4 address for localhost
2323
LocalhostIPv4 = "127.0.0.1"
24+
// TargetHostIPv4 is the standard IPv4 address for the target host
25+
TargetHostIPv4 = "0.0.0.0"
2426
)
2527

2628
// HTTPTransport implements the Transport interface using Server-Sent/Streamable Events.
@@ -66,9 +68,9 @@ func NewHTTPTransport(
6668
host = LocalhostIPv4
6769
}
6870

69-
// If targetHost is not specified, default to localhost
71+
// If targetHost is not specified, default to bind to all interfaces
7072
if targetHost == "" {
71-
targetHost = LocalhostIPv4
73+
targetHost = TargetHostIPv4
7274
}
7375

7476
return &HTTPTransport{

0 commit comments

Comments
 (0)