Skip to content

Commit 663ebfb

Browse files
committed
feat: IPv6 dual-stack support for server bind addresses (#863)
Change default bind address from 0.0.0.0/127.0.0.1 to :: (dual-stack) across all server components, enabling deployment on IPv6-only Kubernetes clusters (e.g. EKS in hybrid VPC where pods have only IPv6 addresses). Binding to :: on Linux accepts both IPv4 and IPv6 connections by default, so existing IPv4-only deployments continue to work without changes. Closes #863 Made-with: Cursor
1 parent e9cc00c commit 663ebfb

6 files changed

Lines changed: 16 additions & 9 deletions

File tree

charts/mcpgw/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ spec:
5050
{{- end }}
5151
env:
5252
- name: HOST
53-
value: 0.0.0.0
53+
value: "::"
5454
{{- if .Values.app.embeddingsApiKeyExistingSecret }}
5555
- name: EMBEDDINGS_API_KEY
5656
valueFrom:

docker/auth-entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ while True:
7575
echo "MongoDB is ready."
7676
fi
7777

78-
echo "Starting Auth Server..."
78+
BIND_HOST="${BIND_HOST:-::}"
79+
80+
echo "Starting Auth Server (host=$BIND_HOST)..."
7981
cd /app
8082
source .venv/bin/activate
81-
exec uvicorn server:app --host 0.0.0.0 --port 8888 --proxy-headers --forwarded-allow-ips='*'
83+
exec uvicorn server:app --host "$BIND_HOST" --port 8888 --proxy-headers --forwarded-allow-ips='*'

docker/registry-entrypoint.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,14 @@ export EMBEDDINGS_PROVIDER=$EMBEDDINGS_PROVIDER
255255
export EMBEDDINGS_MODEL_NAME=$EMBEDDINGS_MODEL_NAME
256256
export EMBEDDINGS_MODEL_DIMENSIONS=$EMBEDDINGS_MODEL_DIMENSIONS
257257

258+
BIND_HOST="${BIND_HOST:-::}"
259+
258260
echo "Starting MCP Registry in the background..."
259261
cd /app
260262
source /app/.venv/bin/activate
261-
uvicorn registry.main:app --host 0.0.0.0 --port 7860 --proxy-headers --forwarded-allow-ips='*' &
262-
echo "MCP Registry started."
263+
uvicorn registry.main:app --host "$BIND_HOST" --port 7860 --proxy-headers --forwarded-allow-ips='*' &
264+
UVICORN_PID=$!
265+
echo "MCP Registry started (PID=$UVICORN_PID, host=$BIND_HOST)."
263266

264267
# Wait for nginx config to be generated (check that placeholders are replaced)
265268
echo "Waiting for nginx configuration to be generated..."

registry/core/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Settings(BaseSettings):
3333
extra="ignore", # Ignore extra environment variables
3434
)
3535

36+
# Network binding: "::" for dual-stack IPv4+IPv6, "0.0.0.0" for IPv4 only
37+
bind_host: str = "::"
38+
3639
# Auth settings
3740
secret_key: str = ""
3841
session_cookie_name: str = "mcp_gateway_session"

registry/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ async def serve_react_app(full_path: str):
10671067

10681068
uvicorn.run(
10691069
"registry.main:app",
1070-
host=os.getenv("REGISTRY_HOST", "127.0.0.1"), # nosec B104
1070+
host=settings.bind_host, # nosec B104 - dual-stack IPv4+IPv6 by default
10711071
port=7860,
10721072
reload=True,
10731073
log_level="info",

servers/currenttime/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ def get_config() -> str:
137137

138138

139139
def main():
140-
# Use configurable host with secure default (127.0.0.1)
141-
# Set HOST=0.0.0.0 in environment for Docker deployments
142-
host = os.environ.get("HOST", "127.0.0.1")
140+
# Use configurable host - "::" enables dual-stack IPv4+IPv6
141+
host = os.environ.get("HOST", "::")
143142

144143
# Log startup information
145144
logger.info(f"Starting CurrentTime server on {host}:{args.port}")

0 commit comments

Comments
 (0)