Skip to content

Commit 446d1ba

Browse files
authored
Merge pull request #66 from IBM/full-doc-review
Full doc review, JWT auth for examples and make the CLI listen on 127.0.0.1
2 parents 4bbc492 + 75ae7e1 commit 446d1ba

File tree

10 files changed

+125
-28
lines changed

10 files changed

+125
-28
lines changed

.github/.renovate.json5

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* 1️⃣ General bot behaviour
55
* ──────────────────────────
66
*/
7+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
78
"extends": [
89
"config:base", /* sensible defaults, but no major-bumps or grouping magic */
9-
":weekly" /* run once a week, early Monday UTC (≈ Sun night US / Mon AM EU) */
10+
"schedule:daily" /* run once a day */
1011
],
1112

1213
/* Only open one brand-new branch or PR during the weekly window */

DEVELOPING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
```
44
export MCP_GATEWAY_BASE_URL=http://localhost:4444
55
export MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/1
6-
export MCP_AUTH_USER=admin
7-
export MCP_AUTH_PASS=changeme
6+
export MCP_AUTH_TOKEN="your_bearer_token"
87
98
109
npx @modelcontextprotocol/inspector # SSE

README.md

Lines changed: 112 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,77 @@ MCP Gateway is [published on PyPi](https://pypi.org/project/mcp-contextforge-gat
5656

5757
```bash
5858
# Create a virtual environment and activate it
59+
mkdir mcpgateway && cd mcpgateway # directory to store Python venv and mcp.db
5960
python3 -m venv .venv
6061
. ./.venv/bin/activate
6162

6263
# Install mcp-contextforge-gateway
6364
pip install mcp-contextforge-gateway
6465

65-
# Run mcpgateway with default options, listening on port 4444
66-
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
6768

68-
# Optional: configure env, and login with admin:password at http://127.0.0.1:9999/admin
69-
BASIC_AUTH_PASSWORD=password mcpgateway --host 127.0.0.1 --port 9999
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
7071

7172
# List all options
7273
mcpgateway --help
74+
75+
# Generate your JWT token from the key
76+
export MCPGATEWAY_BEARER_TOKEN=$(python3 -m mcpgateway.utils.create_jwt_token --username admin --exp 10080 --secret my-test-key)
77+
78+
# Run a local MCP Server (github) listening on SSE http://localhost:8000/sse
79+
pip install uvenv
80+
npx -y supergateway --stdio "uvenv run mcp-server-git"
81+
82+
#--------------------------------------------
83+
# Register the MCP Server with the gateway and test it
84+
# The curl steps can also from the admin ui: http://localhost:4444/admin
85+
# For more info on the API see /docs and /redoc *after* login to /admin
86+
#---------------------------------------------
87+
# Test the API (assume you have curl and jq installed)
88+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/version | jq
89+
90+
# Register the MCP server as a new gateway provider
91+
curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
92+
-H "Content-Type: application/json" \
93+
-d '{"name":"github_mcp_server","url":"http://localhost:8000/sse"}' \
94+
http://localhost:4444/gateways
95+
96+
# List gateways - you should see [{"id":1,"name":"github_mcp_server","url":"http://localhost:8000/sse" ...
97+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways | jq
98+
99+
# Get gateway by ID
100+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways/1
101+
102+
# List the global tools
103+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools | jq
104+
105+
# Create a virtual server with tool 1,2,3 form global tools catalog
106+
# You can configure virtual servers with multiple tools/resources/prompts from registered MCP server (gateways)
107+
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
108+
-H "Content-Type: application/json" \
109+
-d '{"name":"devtools_mcp_server","description":"My developer tools","associatedTools": ["1","2","3"]}' \
110+
http://localhost:4444/servers
111+
112+
# List servers
113+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers
114+
115+
# Get an individual server
116+
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers/1
117+
118+
# 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
73123
```
74124

75-
## Quick Start (Pre-built Image)
125+
See [.env.example](.env.example) for full list of ENV variables you can use to override the configuration.
76126

77-
If you just want to run the gateway using the official image from GitHub Container Registry:
127+
## Quick Start (Pre-built Container Image)
128+
129+
If you just want to run the gateway using the official OCI container image from GitHub Container Registry:
78130

79131
```bash
80132
docker run -d --name mcpgateway \
@@ -93,6 +145,8 @@ docker logs mcpgateway
93145
You can now access the UI at [http://localhost:4444/admin](http://localhost:4444/admin)
94146

95147
> 💡 You can also use `--env-file .env` if you have a config file already. See the provided [.env.example](.env.example)
148+
> 💡 To access local tools, consider using `--network=host`
149+
> 💡 Consider using a stable / release version of the image, ex: `ghcr.io/ibm/mcp-context-forge:v0.1.0`
96150
97151
### Optional: Mount a local volume for persistent SQLite storage
98152

@@ -120,7 +174,7 @@ curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
120174

121175
### Running the mcpgateway-wrapper
122176

123-
The mcpgateway-wrapper lets you connect to the gateway over stdio.
177+
The mcpgateway-wrapper lets you connect to the gateway over stdio, while retaining authentication using the JWT token when the wrapper connect to a remote gateway. You should run this from a MCP client. You can test this from a shell with:
124178

125179
```bash
126180
docker run -i --name mcpgateway-wrapper \
@@ -130,10 +184,15 @@ docker run -i --name mcpgateway-wrapper \
130184
-e MCP_AUTH_TOKEN=$MCPGATEWAY_BEARER_TOKEN \
131185
ghcr.io/ibm/mcp-context-forge:latest \
132186
run --directory mcpgateway-wrapper mcpgateway-wrapper
187+
# You'll see a message similar to: Installed 21 packages in 6ms - it's now expecting input from an MCP client
133188
```
134189

135190
### Running from a MCP Client
136191

192+
The `mcpgateway-wrapper` should be used with an MCP Client that does not support SSE. You can configure it as such.
193+
194+
Remember to replace the `MCP_SERVER_CATALOG_URL` with the actual URL of your MCP Gateway. Consider container networking - when running this via a container engine, this should represent a network accessible from Docker/Podman, ex: `http://host.docker.internal:4444/servers/1`
195+
137196
```json
138197
{
139198
"servers": {
@@ -142,9 +201,10 @@ docker run -i --name mcpgateway-wrapper \
142201
"args": [
143202
"run",
144203
"--rm",
204+
"--network=host",
145205
"-i",
146206
"-e",
147-
"MCP_SERVER_CATALOG_URLS=http://host.docker.internal:4444/servers/1",
207+
"MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/1",
148208
"-e",
149209
"MCP_AUTH_TOKEN=${MCPGATEWAY_BEARER_TOKEN}",
150210
"--entrypoint",
@@ -162,14 +222,53 @@ docker run -i --name mcpgateway-wrapper \
162222
}
163223
}
164224
```
225+
226+
## Quick Start (Claude Desktop)
227+
228+
To add the mcpgateway to Claude Desktop (or similar MCP Clients) go to `File > Settings > Developer > Edit Config` and add:
229+
230+
```json
231+
{
232+
"mcpServers": {
233+
"mcpgateway-wrapper": {
234+
"command": "docker",
235+
"args": [
236+
"run",
237+
"--rm",
238+
"--network=host",
239+
"-i",
240+
"-e",
241+
"MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/1",
242+
"-e",
243+
"MCP_AUTH_TOKEN=${MCPGATEWAY_BEARER_TOKEN}",
244+
"--entrypoint",
245+
"uv",
246+
"ghcr.io/ibm/mcp-context-forge:latest",
247+
"run",
248+
"--directory",
249+
"mcpgateway-wrapper",
250+
"mcpgateway-wrapper"
251+
],
252+
"env": {
253+
"MCPGATEWAY_BEARER_TOKEN": "<place your token here>"
254+
}
255+
}
256+
}
257+
}
258+
```
259+
260+
Restart Claude Desktop (exiting from system tray). Go back to `File > Settings > Developer > Edit Config` to check on your configuration and view the logs.
261+
262+
For more details, see the [Claude MCP quickstart](https://modelcontextprotocol.io/quickstart/server). For issues, see [MCP Debugging](https://modelcontextprotocol.io/docs/tools/debugging).
263+
165264
---
166265

167266
## Quick Start (manual install)
168267

169268
### Prerequisites
170269

171270
* **Python ≥ 3.10**
172-
* **GNU Make** (all common workflows are Make targets)
271+
* **GNU Make** (optional, but all common workflows are available as Make targets)
173272
* Optional: **Docker / Podman** for containerised runs
174273

175274
### One-liner (dev)
@@ -260,6 +359,8 @@ docker run --name mcp-postgres \
260359
-p 5432:5432 -d postgres
261360
```
262361

362+
A `make compose-up` target is provided along with a [docker-compose.yml](docker-compose.yml) file to make this process simpler.
363+
263364
---
264365

265366
## Configuration (`.env` or env vars)
@@ -563,6 +664,7 @@ echo ${MCPGATEWAY_BEARER_TOKEN}
563664
564665
# Quickly confirm that authentication works and the gateway is healthy
565666
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/health
667+
# {"status":"healthy"}
566668
567669
# Quickly confirm the gateway version & DB connectivity
568670
curl -s -k -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" https://localhost:4444/version | jq
@@ -812,7 +914,7 @@ curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/s
812914
# Create server
813915
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
814916
-H "Content-Type: application/json" \
815-
-d '{"name":"db","description":"Database"}' \
917+
-d '{"name":"db","description":"Database","associatedTools": ["1","2","3"]}' \
816918
http://localhost:4444/servers
817919
818920
# Update server

docs/docs/using/agents/bee.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ To use MCP tools in the Bee Agent Framework, follow these steps:
3636

3737
```bash
3838
export MCP_GATEWAY_BASE_URL=http://localhost:4444
39-
export MCP_AUTH_USER=admin
40-
export MCP_AUTH_PASS=changeme
39+
export MCP_AUTH_TOKEN="your_bearer_token"
4140
```
4241

4342
---

docs/docs/using/clients/claude-desktop.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ Add this block to the `"mcpServers"` section of your config:
3333
"env": {
3434
"MCP_GATEWAY_BASE_URL": "http://localhost:4444",
3535
"MCP_SERVER_CATALOG_URLS": "http://localhost:4444/servers/2",
36-
"MCP_AUTH_USER": "admin",
37-
"MCP_AUTH_PASS": "changeme"
36+
"MCP_AUTH_TOKEN": "your_bearer_token"
3837
}
3938
}
4039
}

docs/docs/using/clients/continue.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ Replace `"mcpgateway-wrapper"` with the appropriate command or path to your MCP
5555

5656
* `MCP_GATEWAY_BASE_URL`: Base URL of your MCP Gateway (e.g., `http://localhost:4444`).
5757
* `MCP_SERVER_CATALOG_URLS`: URL(s) to the server catalog(s) (e.g., `http://localhost:4444/servers/2`).
58-
* `MCP_AUTH_USER`: Username for authentication (e.g., `admin`).
59-
* `MCP_AUTH_PASS`: Password for authentication (e.g., `changeme`).
58+
* `MCP_AUTH_TOKEN`: JWT token used for authentication (as generated by `python3 -m mcpgateway.utils.create_jwt_token`).
6059

6160
You can set these in your system environment or within the Continue configuration if supported.
6261

docs/docs/using/clients/copilot.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ Point Copilot to the local wrapper process:
9999
"env": {
100100
"MCP_GATEWAY_BASE_URL": "http://localhost:4444",
101101
"MCP_SERVER_CATALOG_URLS": "http://localhost:4444/servers/1",
102-
"MCP_AUTH_USER": "admin",
103-
"MCP_AUTH_PASS": "changeme"
102+
"MCP_AUTH_TOKEN": "your_bearer_token"
104103
}
105104
}
106105
}

docs/docs/using/clients/mcp-inspector.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ npx @modelcontextprotocol/inspector \
3838

3939
## 🔐 Auth & Config
4040

41-
Ensure you provide the necessary `MCP_AUTH_USER` and `MCP_AUTH_PASS` as environment variables if your gateway requires authentication:
41+
Ensure you provide the necessary `MCP_AUTH_TOKEN` as environment variable if your gateway requires authentication:
4242

4343
```bash
4444
export MCP_GATEWAY_BASE_URL=http://localhost:4444
4545
export MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/2
46-
export MCP_AUTH_USER=admin
47-
export MCP_AUTH_PASS=changeme
46+
export MCP_AUTH_TOKEN="your_bearer_token"
4847
```
4948

5049
Then run the Inspector again.

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)