Skip to content

feat(http): support custom listen address#2655

Open
pyama86 wants to merge 1 commit into
github:mainfrom
pyama86:feature/http-listen-address
Open

feat(http): support custom listen address#2655
pyama86 wants to merge 1 commit into
github:mainfrom
pyama86:feature/http-listen-address

Conversation

@pyama86

@pyama86 pyama86 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • Add a --listen-address flag (env: GITHUB_LISTEN_ADDRESS) to the http command so the MCP HTTP server can bind to an explicit host:port instead of always listening on every interface (:<port>).
  • The existing --port flag is preserved. When --listen-address is set it takes precedence; otherwise behavior is unchanged.
  • Listen address resolution is factored into a small resolveListenAddress helper with unit tests covering empty, host:port, :port, and IPv6 forms.

Motivation

Today the HTTP server hard-codes addr := fmt.Sprintf(":%d", cfg.Port), which binds to 0.0.0.0 on every interface. When this server runs inside Kubernetes (or any shared network), the Pod IP is reachable from anywhere that can route to the cluster network: if an attacker (or just another workload) discovers the Pod IP, they can hit the MCP HTTP server directly and bypass any Service / Ingress / NetworkPolicy that was supposed to gate it. This is especially risky because the MCP server proxies authenticated GitHub API calls.

Allowing operators to bind to 127.0.0.1:8082 (sidecar / loopback-only consumers) or to a specific interface address closes that gap and lets the standard "only the localhost / sidecar can talk to it" deployment pattern work without extra network plumbing.

Test plan

  • go build ./...
  • go test ./pkg/http/... (new TestResolveListenAddress + existing tests pass)
  • Manual: run github-mcp-server http --listen-address 127.0.0.1:8082 and confirm the server only accepts connections on loopback
  • Manual: run github-mcp-server http --port 9090 (no --listen-address) and confirm existing :9090 behavior is unchanged

Add --listen-address flag (env: GITHUB_LISTEN_ADDRESS) so the HTTP
server can bind to a specific host:port instead of always listening on
all interfaces. When unset the server keeps the existing :PORT behavior.
@pyama86 pyama86 requested a review from a team as a code owner June 9, 2026 14:36
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.

1 participant