feat(mcp): add --host flag (and QMD_HOST env) to the HTTP server#677
Open
djalmajr wants to merge 1 commit into
Open
feat(mcp): add --host flag (and QMD_HOST env) to the HTTP server#677djalmajr wants to merge 1 commit into
djalmajr wants to merge 1 commit into
Conversation
The MCP HTTP server hardcoded listen(port, "localhost"), so it is unreachable from any non-loopback address. In a container, a liveness probe connects from the pod IP rather than 127.0.0.1, and the bind refuses that connection. Add a --host flag with a QMD_HOST environment-variable fallback. The default stays "localhost", so out-of-the-box behavior is unchanged. Set --host 0.0.0.0 to accept off-host connections (e.g. k8s probes). - server.ts: startMcpHttpServer binds options.host ?? QMD_HOST ?? "localhost" - cli: --host flag, forwarded to the daemon spawn and shown in startup logs - README: document --host / QMD_HOST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
startMcpHttpServerhardcodeshttpServer.listen(port, "localhost", …), so the HTTP MCP server only accepts loopback connections. Whenqmd mcp --httpruns inside a container, a Kubernetes liveness/readiness probe connects from the pod IP (e.g.10.42.x.x), not127.0.0.1— the bind refuses it and the probe fails, so the pod never goes ready.Today the only workaround is to patch the published
dist/mcp/server.jsat image-build time:which is brittle and breaks on every release.
Change
Add a
--hostflag toqmd mcp --http, with aQMD_HOSTenvironment-variable fallback:localhost) — no behavior change out of the box.--host 0.0.0.0(orQMD_HOST=0.0.0.0) binds all interfaces for container/probe reachability.--daemonmode and reflected in the startup log /Started on …message.Files:
src/mcp/server.ts—startMcpHttpServerresolves and bindshost; JSDoc + listening log updated.src/cli/qmd.ts—--hostflag parsed, forwarded to daemon spawn, shown in logs.README.md— documents--host/QMD_HOST.Verification
npm run test:types— passes.test/mcp.test.ts— 57/57 pass (existing HTTP test uses the default and still bindslocalhost).