Skip to content

Commit 74c3627

Browse files
committed
Ensure mcpgateway cli listens on 127.0.0.1 by default
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 9f3830d commit 74c3627

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ python3 -m venv .venv
6363
# Install mcp-contextforge-gateway
6464
pip install mcp-contextforge-gateway
6565

66-
# Run mcpgateway with default options, listening on port 4444 with admin:changeme
67-
mcpgateway
66+
# Run mcpgateway with default options (binds to 127.0.0.1:4444) with admin:changeme
67+
mcpgateway # login to http://127.0.0.1:4444
6868

69-
# Optional: run in background with configured password/key - login at http://127.0.0.1:4444/admin
70-
BASIC_AUTH_PASSWORD=password JWT_SECRET_KEY=my-test-key mcpgateway --host 127.0.0.1 --port 4444 & bg
69+
# Optional: run in background with configured password/key and listen to all IPs
70+
BASIC_AUTH_PASSWORD=password JWT_SECRET_KEY=my-test-key mcpgateway --host 0.0.0.0 --port 4444 & bg
7171

7272
# List all options
7373
mcpgateway --help
@@ -116,6 +116,10 @@ curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/s
116116
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers/1
117117

118118
# You can now use http://localhost:4444/servers/1 as an SSE server with the configured JWT token in any MCP client
119+
120+
# To stop the running process, you can either:
121+
fg # Return the process to foreground, you can not Ctrl + C, or:
122+
pkill mcpgateway
119123
```
120124

121125
See [.env.example](.env.example) for full list of ENV variables you can use to override the configuration.
@@ -658,6 +662,7 @@ echo ${MCPGATEWAY_BEARER_TOKEN}
658662
659663
# Quickly confirm that authentication works and the gateway is healthy
660664
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/health
665+
# {"status":"healthy"}
661666
662667
# Quickly confirm the gateway version & DB connectivity
663668
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/version | jq

mcpgateway/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
─────────
1818
* Injects the default FastAPI application path (``mcpgateway.main:app``)
1919
when the user doesn't supply one explicitly.
20-
* Adds sensible default host/port (0.0.0.0:4444) unless the user passes
20+
* Adds sensible default host/port (127.0.0.1:4444) unless the user passes
2121
``--host``/``--port`` or overrides them via the environment variables
2222
``MCG_HOST`` and ``MCG_PORT``.
2323
* Forwards *all* remaining arguments verbatim to Uvicorn's own CLI, so
@@ -26,7 +26,7 @@
2626
Typical usage
2727
─────────────
2828
```console
29-
$ mcpgateway --reload # dev server on 0.0.0.0:4444
29+
$ mcpgateway --reload # dev server on 127.0.0.1:4444
3030
$ mcpgateway --workers 4 # production-style multiprocess
3131
$ mcpgateway 127.0.0.1:8000 --reload # explicit host/port keeps defaults out
3232
$ mcpgateway mypkg.other:app # run a different ASGI callable
@@ -45,7 +45,7 @@
4545
# Configuration defaults (overridable via environment variables)
4646
# ---------------------------------------------------------------------------
4747
DEFAULT_APP = "mcpgateway.main:app" # dotted path to FastAPI instance
48-
DEFAULT_HOST = os.getenv("MCG_HOST", "0.0.0.0")
48+
DEFAULT_HOST = os.getenv("MCG_HOST", "127.0.0.1")
4949
DEFAULT_PORT = int(os.getenv("MCG_PORT", "4444"))
5050

5151
# ---------------------------------------------------------------------------

mcpgateway/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Settings(BaseSettings):
7575
token_expiry: int = 10080 # minutes
7676

7777
# Encryption key phrase for auth storage
78-
auth_encryption_secret: str = "my-test-key"
78+
auth_encryption_secret: str = "my-test-salt"
7979

8080
# UI/Admin Feature Flags
8181
mcpgateway_ui_enabled: bool = True

0 commit comments

Comments
 (0)