forked from IBM/mcp-context-forge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose-embedded.yml
More file actions
220 lines (195 loc) · 9.4 KB
/
docker-compose-embedded.yml
File metadata and controls
220 lines (195 loc) · 9.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
###############################################################################
# Docker Compose Override - Embedded Mode Embedded iframe Mode
#
# This is an OVERRIDE file. Use it with docker-compose.yml:
#
# docker compose -f docker-compose.yml -f docker-compose-embedded.yml --profile benchmark up -d
# docker compose -f docker-compose.yml -f docker-compose-embedded.yml --profile benchmark down
#
# Or simply:
# make embedded-up
# make embedded-down
#
# What this adds / overrides:
# - Gateway env overrides for embedded iframe mode (proxy auth, hidden sections,
# CORS, CSP, cookie settings, visibility controls)
# - Benchmark servers (10 servers x 50 tools = 500 tools for pagination testing)
# - Auto-registration of benchmark servers with gateway
# - iframe test harness at http://localhost:8889
#
# Access:
# iframe harness: http://localhost:8889 (loads gateway UI inside iframe)
# Gateway UI: http://localhost:8080/admin/ (via nginx, direct access)
# Gateway API: http://localhost:8080 (via nginx)
#
# Test checklist:
# - Team member role = developer (DEFAULT_USER_ROLE=developer)
# - Embedded UI hides: overview, logs, maintenance, mcp-registry, plugins,
# roots, llm-settings, teams, tokens, users
# - View Public checkbox visible in team scope
# - Public visibility selection disabled (ALLOW_PUBLIC_VISIBILITY=false)
# - Virtual server search with multi-select, edit in Add/Edit screens
# - Pagination with 500+ tools across 10 benchmark servers
###############################################################################
services:
# ──────────────────────────────────────────────────────────────────────
# Gateway overrides for embedded iframe mode
# ──────────────────────────────────────────────────────────────────────
# Override nginx to use iframe-friendly config (removes hardcoded X-Frame-Options: SAMEORIGIN,
# lets the gateway's own X_FRAME_OPTIONS=ALLOW-ALL header pass through for iframe embedding)
nginx:
volumes:
- nginx_cache:/var/cache/nginx
- ./infra/iframe-test/nginx-embedded.conf:/etc/nginx/nginx.conf:ro
gateway:
image: ${IMAGE_LOCAL:-mcpgateway/mcpgateway:latest}
ulimits:
nofile:
soft: 65535
hard: 65535
nproc:
soft: 5000
hard: 5000
environment:
# ── Embedded UI ──
- MCPGATEWAY_UI_EMBEDDED=true
- MCPGATEWAY_UI_HIDE_SECTIONS=overview,logs,maintenance,mcp-registry,plugins,roots,llm-settings,teams,tokens,users
# Admin users see all sections by default in embedded mode
- MCPGATEWAY_UI_HIDE_SECTIONS_ADMIN=
- MCPGATEWAY_UI_HIDE_HEADER_ITEMS_ADMIN=
# ── CORS & iframe embedding ──
- CORS_ENABLED=true
- "ALLOWED_ORIGINS=[\"*\"]"
- CORS_ALLOW_CREDENTIALS=true
# X_FRAME_OPTIONS controls both the header and CSP frame-ancestors directive:
# SAMEORIGIN -> frame-ancestors 'self' (same-origin only)
# ALLOW-ALL -> frame-ancestors * file: http: https: (any origin)
# empty/null -> no X-Frame-Options or frame-ancestors (fully open)
- X_FRAME_OPTIONS=ALLOW-ALL
- SECURITY_HEADERS_ENABLED=true
- SECURE_COOKIES=false
# SameSite=lax for HTTP; use 'none' only with HTTPS (SameSite=None requires Secure flag)
- COOKIE_SAMESITE=lax
# ── Proxy auth (Embedded Mode forwards identity via header) ──
- TRUST_PROXY_AUTH=true
- PROXY_USER_HEADER=X-Authenticated-User
# ── Auth & platform admin ──
- AUTH_REQUIRED=true
- EMAIL_AUTH_ENABLED=true
- MCP_CLIENT_AUTH_ENABLED=true
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-my-test-key-but-now-longer-than-32-bytes}
- PLATFORM_ADMIN_EMAIL=admin@example.com
- PLATFORM_ADMIN_PASSWORD=Changeme123!
- PLATFORM_ADMIN_FULL_NAME=Platform Administrator
- TOKEN_EXPIRY=1008000
# ── Password policy (relaxed for dev) ──
- PASSWORD_CHANGE_ENFORCEMENT_ENABLED=false
- PASSWORD_MIN_LENGTH=12
- PASSWORD_REQUIRE_LOWERCASE=true
- PASSWORD_REQUIRE_UPPERCASE=true
- PASSWORD_REQUIRE_NUMBERS=true
- PASSWORD_REQUIRE_SPECIAL=true
- ACCOUNT_LOCKOUT_DURATION_MINUTES=30
- MAX_FAILED_LOGIN_ATTEMPTS=5
# ── RBAC & visibility ──
- DEFAULT_USER_ROLE=developer
- ALLOW_PUBLIC_VISIBILITY=false
- PAGINATION_DEFAULT_PAGE_SIZE=350
# ── Header passthrough ──
- ENABLE_HEADER_PASSTHROUGH=true
- ENABLE_OVERWRITE_BASE_HEADERS=false
- "DEFAULT_PASSTHROUGH_HEADERS=[\"X-Tenant-Id\", \"X-Team-Id\", \"X-Trace-Id\", \"Authorization\"]"
# ── SSE / WebSocket ──
- SSE_KEEPALIVE_ENABLED=true
- SSE_KEEPALIVE_INTERVAL=30
- SSE_RETRY_TIMEOUT=5000
- WEBSOCKET_PING_INTERVAL=30
# ── SSRF (disabled for dev) ──
- SSRF_PROTECTION_ENABLED=false
# ── LLM Chat (disabled for embedded) ──
- LLMCHAT_ENABLED=false
# ── Federation (disabled) ──
- FEDERATION_ENABLED=false
- FEDERATION_DISCOVERY=false
# ── App root path (behind reverse proxy) ──
# Uncomment if Embedded Mode proxies at /api/proxy/mcp
# - APP_ROOT_PATH=/api/proxy/mcp
# ── Logging ──
- LOG_LEVEL=DEBUG
- LOG_FORMAT=json
- LOG_REQUESTS=false
# ──────────────────────────────────────────────────────────────────────
# iframe Test Harness - serves a simple page that embeds the gateway UI
# Access: http://localhost:8889
# ──────────────────────────────────────────────────────────────────────
iframe_harness:
image: nginx:stable-bookworm
restart: unless-stopped
networks: [mcpnet]
ports:
- "8889:80"
volumes:
- ./infra/iframe-test/index.html:/usr/share/nginx/html/index.html:ro
depends_on:
gateway:
condition: service_healthy
###############################################################################
# Benchmark Server - 10 MCP servers with 50 tools each = 500 tools
# For pagination testing with large numbers of items
###############################################################################
# Benchmark services: inherited from base compose (profiles: ["benchmark"])
# Activated via --profile benchmark in Makefile targets
register_benchmark:
image: ${IMAGE_LOCAL:-mcpgateway/mcpgateway:latest}
environment:
- JWT_SECRET_KEY=${JWT_SECRET_KEY:-my-test-key-but-now-longer-than-32-bytes}
- BENCHMARK_SERVER_COUNT=${BENCHMARK_SERVER_COUNT:-10}
- BENCHMARK_START_PORT=${BENCHMARK_START_PORT:-9000}
command:
- |
echo "Registering benchmark servers with gateway..."
# Wait for benchmark servers to start (no healthcheck available)
echo "Waiting for benchmark servers to start..."
sleep 5
# Generate JWT token (uses overridden jwt-secret-key)
export MCPGATEWAY_BEARER_TOKEN=$$(python3 -m mcpgateway.utils.create_jwt_token --username admin@example.com --exp 10080 --secret jwt-secret-key --algo HS256 2>/dev/null)
# Register benchmark servers
python3 -c "
import urllib.request
import json
import os
token = os.environ.get('MCPGATEWAY_BEARER_TOKEN', '')
server_count = int(os.environ.get('BENCHMARK_SERVER_COUNT', '10'))
start_port = int(os.environ.get('BENCHMARK_START_PORT', '9000'))
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
def api_request(method, path, data=None):
url = f'http://gateway:4444{path}'
body = json.dumps(data).encode() if data else None
req = urllib.request.Request(url, data=body, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read().decode())
print(f'Registering {server_count} benchmark servers (ports {start_port}-{start_port + server_count - 1})...')
registered = 0
for port in range(start_port, start_port + server_count):
name = f'benchmark-{port}'
try:
result = api_request('POST', '/gateways', {
'name': name,
'url': f'http://benchmark_server:{port}/mcp',
'transport': 'STREAMABLEHTTP'
})
print(f'Registered {name}: {result.get(\"id\", \"unknown\")}')
registered += 1
except urllib.error.HTTPError as e:
if e.code == 409:
print(f'{name} already registered')
registered += 1
else:
print(f'Failed to register {name}: HTTP {e.code}')
except Exception as e:
print(f'Failed to register {name}: {e}')
print(f'Registration complete: {registered}/{server_count} benchmark servers')
"