Skip to content

Changes MCP_HOST set by toolhive to 0.0.0.0 #1089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aponcedeleonch
Copy link
Contributor

@aponcedeleonch aponcedeleonch commented Jul 17, 2025

Bind MCP_HOST in the container to all interfaces by default so that the mcp server is reachable from the host

@aponcedeleonch aponcedeleonch requested a review from dmjb July 17, 2025 10:50
@yrobla
Copy link
Contributor

yrobla commented Jul 17, 2025

we spin a transparent proxy when we start an MCP server, and the connectivity to that MCP server is done via proxy. So why is that change needed, is there a need to access MCP server from host directly?

@aponcedeleonch aponcedeleonch force-pushed the change-defualt-mcp-host branch from d7d44df to 7f240ad Compare July 17, 2025 12:02
@aponcedeleonch
Copy link
Contributor Author

aponcedeleonch commented Jul 17, 2025

@yrobla then maybe I'm not using toolhive correctly? I'm doing

thv run --name knowledge-mcp --transport streameable-http knowledge-mcp

If knowledge-mcp accepts the MCP_HOST env var, and that env var is defined by ToolHive, without this change the env var value will be MCP_HOST=127.0.0.1. If I try to reach my MCP server with inspector to the IP http://localhost:<toolhive-provided-port>/mcp it will fail.

@aponcedeleonch aponcedeleonch requested a review from yrobla July 17, 2025 12:34
@aponcedeleonch
Copy link
Contributor Author

aponcedeleonch commented Jul 17, 2025

This won't change the binding address of the proxy. Tested with

% go run ./cmd/thv run --name knowledge-mcp --transport streamable-http knowledge-mcp
% ps aux | grep proxy
....
aponcedeleonch   77793   0.0  0.1 412119104  50656   ??  Ss    3:53PM   0:00.17 /Users/aponcedeleonch/Library/Caches/go-build/e6/e6c2b759a96c2efc744281e7d9832f90b5c0db816de8a40e77f2e21840231e1c-d/thv run --foreground --transport streamable-http --proxy-mode sse --name knowledge-mcp --name knowledge-mcp --host 127.0.0.1 --port 11035 --target-port 48474 --target-host 0.0.0.0 --permission-profile /var/folders/m9/1z1wdq4n3ls979bzhtf3l6m00000gn/T/toolhive-knowledge-mcp-permissions-2663938117.json --env MCP_TRANSPORT=streamable-http --env MCP_PORT=48474 --env FASTMCP_PORT=48474 knowledge-mcp
% lsof -Pan -p 77793 -i
COMMAND   PID           USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
thv     77793 aponcedeleonch   12u  IPv4 0x26affa3e401c87a6      0t0  TCP 127.0.0.1:11035 (LISTEN)

@aponcedeleonch aponcedeleonch force-pushed the change-defualt-mcp-host branch from 7f240ad to dc30d94 Compare July 18, 2025 11:18
@aponcedeleonch aponcedeleonch requested a review from yrobla July 18, 2025 11:19
@aponcedeleonch aponcedeleonch force-pushed the change-defualt-mcp-host branch from b886db6 to ede7fc6 Compare August 5, 2025 09:24
Bind MCP_HOST to all interfaces by default so that the mcp server
in the container is reachable from the host
@aponcedeleonch aponcedeleonch force-pushed the change-defualt-mcp-host branch from ede7fc6 to 7177e2e Compare August 5, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants