Skip to content

Commit 077fa2a

Browse files
committed
Cleanup README
Signed-off-by: Mihai Criveti <[email protected]>
1 parent 8b9f2e6 commit 077fa2a

File tree

1 file changed

+88
-60
lines changed

1 file changed

+88
-60
lines changed

README.md

Lines changed: 88 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -99,92 +99,120 @@ For a list of upcoming features, check out the [ContextForge MCP Gateway Roadmap
9999

100100
---
101101

102-
## Quick Start: PyPi
102+
## Quick Start — PyPI
103103

104-
MCP Gateway is [published on PyPi](https://pypi.org/project/mcp-contextforge-gateway) as `mcp-contextforge-gateway`. You can install and start a server with:
104+
MCP Gateway is published on [PyPI](https://pypi.org/project/mcp-contextforge-gateway/) as `mcp-contextforge-gateway`.
105+
106+
---
107+
108+
<details>
109+
<summary><strong>📋 Prerequisites</strong></summary>
110+
111+
* **Python ≥ 3.10** (3.11 recommended)
112+
* **curl + jq** – only for the last smoke‑test step
113+
114+
</details>
115+
116+
### 1 · Install & run (copy‑paste friendly)
105117

106118
```bash
107-
# Create a virtual environment and activate it
108-
mkdir mcpgateway && cd mcpgateway # directory to store Python venv and mcp.db
109-
python3 -m venv .venv
110-
. ./.venv/bin/activate
119+
# 1️⃣ Isolated env + install from pypi
120+
mkdir mcpgateway && cd mcpgateway
121+
python3 -m venv .venv && source .venv/bin/activate
122+
pip install --upgrade pip
123+
pip install mcp-contextforge-gateway
111124

112-
# Install mcp-contextforge-gateway
113-
pip install mcp-contextforge-gateway # from pypi
114-
#pip install . # or install from latest github code after cloning repo
125+
# 2️⃣ Launch on all interfaces with custom creds & secret key
126+
BASIC_AUTH_PASSWORD=pass JWT_SECRET_KEY=my-test-key \
127+
mcpgateway --host 0.0.0.0 --port 4444 & # admin/pass
115128

116-
# Run mcpgateway with default options (binds to 127.0.0.1:4444) with admin:changeme
117-
mcpgateway # login to http://127.0.0.1:4444
129+
# 3️⃣ Generate a bearer token & smoke‑test the API
130+
export MCPGATEWAY_BEARER_TOKEN=$(python3 -m mcpgateway.utils.create_jwt_token \
131+
--username admin --exp 10080 --secret my-test-key)
118132

119-
# Optional: run in background with configured password/key and listen to all IPs
120-
BASIC_AUTH_PASSWORD=password JWT_SECRET_KEY=my-test-key mcpgateway --host 0.0.0.0 --port 4444 & bg
133+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
134+
http://127.0.0.1:4444/version | jq
135+
```
121136

122-
# List version / help
123-
mcpgateway --help; mcpgateway --version
137+
<details>
138+
<summary><strong>More configuration</strong></summary>
124139

125-
# Generate your JWT token from the key and list it
126-
export MCPGATEWAY_BEARER_TOKEN=$(python3 -m mcpgateway.utils.create_jwt_token --username admin --exp 10080 --secret my-test-key)
127-
echo $MCPGATEWAY_BEARER_TOKEN
140+
Copy [.env.example](.env.example) to `.env` and tweak any of the settings (or use them as env variables).
141+
142+
</details>
143+
144+
<details>
145+
<summary><strong>🚀 End‑to‑end demo (register a local MCP server)</strong></summary>
128146

129-
# Run a local MCP Server (github) listening on SSE http://localhost:8000/sse in another terminal:
147+
```bash
148+
# 1️⃣ Spin up a sample MCP server (Node supergateway)
130149
pip install uvenv
131-
npx -y supergateway --stdio "uvenv run mcp-server-git" # requires node.js and npx
132-
# or time: npx -y supergateway --stdio "uvenv run mcp_server_time -- --local-timezone=Europe/Dublin" --port 8002
133-
# or: python3 -m mcpgateway.translate --stdio "uvenv run mcp-server-git" --port 8000
134-
135-
#--------------------------------------------
136-
# Register the MCP Server with the gateway and test it
137-
# The curl steps can also from the admin ui: http://localhost:4444/admin
138-
# For more info on the API see /docs and /redoc *after* login to /admin
139-
#---------------------------------------------
140-
# Test the API (assume you have curl and jq installed)
141-
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/version | jq
142-
143-
# Register the MCP server as a new gateway provider
150+
npx -y supergateway --stdio "uvenv run mcp_server_time -- --local-timezone=Europe/Dublin" --port 8002 &
151+
152+
# 2️⃣ Register it with the gateway
144153
curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
145154
-H "Content-Type: application/json" \
146-
-d '{"name":"github_mcp_server","url":"http://localhost:8000/sse"}' \
155+
-d '{"name":"local_time","url":"http://localhost:8002/sse"}' \
147156
http://localhost:4444/gateways
148157

149-
# List gateways - you should see [{"id":1,"name":"github_mcp_server","url":"http://localhost:8000/sse" ...
150-
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways | jq
151-
152-
# Get gateway by ID
153-
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/gateways/1 | jq
154-
155-
# List the global tools
158+
# 3️⃣ Verify tool catalog
156159
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/tools | jq
157160

158-
# Create a virtual server with tool 1,2,3 form global tools catalog
159-
# You can configure virtual servers with multiple tools/resources/prompts from registered MCP server (gateways)
160-
curl -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
161+
# 4️⃣ Create a *virtual server* bundling those tools
162+
curl -s -X POST -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" \
161163
-H "Content-Type: application/json" \
162-
-d '{"name":"devtools_mcp_server","description":"My developer tools","associatedTools": ["1","2","3"]}' \
164+
-d '{"name":"demo_server","description":"Time tools","associatedTools":["1","2"]}' \
163165
http://localhost:4444/servers | jq
164166

165-
# List servers
166-
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers | jq
167+
# 5️⃣ List servers (should now include ID 1)
168+
curl -s -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers | jq
167169

168-
# Get an individual server
169-
curl -H "Authorization: Bearer $MCPGATEWAY_BEARER_TOKEN" http://localhost:4444/servers/1 | jq
170+
# 6️⃣ Client SSE endpoint. Inspect it interactively with the MCP Inspector CLI (or use any MCP client)
171+
npx -y @modelcontextprotocol/inspector
172+
# Transport Type: SSE, URL: http://localhost:4444/servers/1/sse, Header Name: "Authorization", Bearer Token
173+
```
170174

171-
# You can now use http://localhost:4444/servers/1 as an SSE server with the configured JWT token in any MCP client
175+
</details>
172176

173-
# To stop the running process, you can either:
174-
fg # Return the process to foreground, you can not Ctrl + C, or:
175-
pkill mcpgateway
177+
<details>
178+
<summary><strong>🖧 Using the stdio wrapper (optional)</strong></summary>
176179

177-
# Optionally, test the stdio wrapper to mirror tools from the gateway:
178-
# This lets you connect to the gateway with tools that don't support SSE:
179-
export MCP_AUTH_TOKEN=${MCPGATEWAY_BEARER_TOKEN}
180+
```bash
181+
export MCP_AUTH_TOKEN=$MCPGATEWAY_BEARER_TOKEN
180182
export MCP_SERVER_CATALOG_URLS=http://localhost:4444/servers/1
181-
python3 -m mcpgateway.wrapper # ^C to exit
182-
# Expected: INFO mcpgateway.wrapper: Starting MCP wrapper 0.1.1: base_url=http://localhost:4444, timeout=90
183-
# Alternatively with uv
184-
uv run --directory . -m mcpgateway.wrapper
183+
python3 -m mcpgateway.wrapper # Ctrl‑C to exit
184+
```
185+
186+
You can also run it with `uv` or inside Docker/Podman – see the *Containers* section above.
187+
188+
In MCP Inspector, define `MCP_AUTH_TOKEN` and `MCP_SERVER_CATALOG_URLS` env variables, and select `python3` as the Command, and `-m mcpgateway.wrapper` as Arguments.
189+
190+
```bash
191+
echo $PWD/.venv/bin/python3 # Using the Python3 full path ensures you have a working venv
192+
export MCP_SERVER_CATALOG_URLS='http://localhost:4444/servers/1'
193+
export MCP_AUTH_TOKEN=${MCPGATEWAY_BEARER_TOKEN}
194+
npx -y @modelcontextprotocol/inspector
185195
```
186196

187-
See [.env.example](.env.example) for full list of ENV variables you can use to override the configuration.
197+
When using a MCP Client such as Claude with stdio:
198+
199+
```json
200+
{
201+
"mcpServers": {
202+
"mcpgateway-wrapper": {
203+
"command": "python",
204+
"args": ["-m", "mcpgateway.wrapper"],
205+
"env": {
206+
"MCP_AUTH_TOKEN": "your-token-here",
207+
"MCP_SERVER_CATALOG_URLS": "http://localhost:4444/servers/1",
208+
"MCP_TOOL_CALL_TIMEOUT": "120"
209+
}
210+
}
211+
}
212+
}
213+
```
214+
215+
</details>
188216

189217
---
190218

0 commit comments

Comments
 (0)