mcp-proxy-adapter 6.3.4__py3-none-any.whl → 6.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_proxy_adapter/__init__.py +9 -5
- mcp_proxy_adapter/__main__.py +1 -1
- mcp_proxy_adapter/api/app.py +227 -176
- mcp_proxy_adapter/api/handlers.py +68 -60
- mcp_proxy_adapter/api/middleware/__init__.py +7 -5
- mcp_proxy_adapter/api/middleware/base.py +19 -16
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +44 -34
- mcp_proxy_adapter/api/middleware/error_handling.py +57 -67
- mcp_proxy_adapter/api/middleware/factory.py +50 -52
- mcp_proxy_adapter/api/middleware/logging.py +46 -30
- mcp_proxy_adapter/api/middleware/performance.py +19 -16
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +80 -50
- mcp_proxy_adapter/api/middleware/transport_middleware.py +26 -24
- mcp_proxy_adapter/api/middleware/unified_security.py +70 -51
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +43 -34
- mcp_proxy_adapter/api/schemas.py +69 -43
- mcp_proxy_adapter/api/tool_integration.py +83 -63
- mcp_proxy_adapter/api/tools.py +60 -50
- mcp_proxy_adapter/commands/__init__.py +15 -6
- mcp_proxy_adapter/commands/auth_validation_command.py +107 -110
- mcp_proxy_adapter/commands/base.py +108 -112
- mcp_proxy_adapter/commands/builtin_commands.py +28 -18
- mcp_proxy_adapter/commands/catalog_manager.py +394 -265
- mcp_proxy_adapter/commands/cert_monitor_command.py +222 -204
- mcp_proxy_adapter/commands/certificate_management_command.py +210 -213
- mcp_proxy_adapter/commands/command_registry.py +275 -226
- mcp_proxy_adapter/commands/config_command.py +48 -33
- mcp_proxy_adapter/commands/dependency_container.py +22 -23
- mcp_proxy_adapter/commands/dependency_manager.py +65 -56
- mcp_proxy_adapter/commands/echo_command.py +15 -15
- mcp_proxy_adapter/commands/health_command.py +31 -29
- mcp_proxy_adapter/commands/help_command.py +97 -61
- mcp_proxy_adapter/commands/hooks.py +65 -49
- mcp_proxy_adapter/commands/key_management_command.py +148 -147
- mcp_proxy_adapter/commands/load_command.py +58 -40
- mcp_proxy_adapter/commands/plugins_command.py +80 -54
- mcp_proxy_adapter/commands/protocol_management_command.py +60 -48
- mcp_proxy_adapter/commands/proxy_registration_command.py +107 -115
- mcp_proxy_adapter/commands/reload_command.py +43 -37
- mcp_proxy_adapter/commands/result.py +26 -33
- mcp_proxy_adapter/commands/role_test_command.py +26 -26
- mcp_proxy_adapter/commands/roles_management_command.py +176 -173
- mcp_proxy_adapter/commands/security_command.py +134 -122
- mcp_proxy_adapter/commands/settings_command.py +47 -56
- mcp_proxy_adapter/commands/ssl_setup_command.py +109 -129
- mcp_proxy_adapter/commands/token_management_command.py +129 -158
- mcp_proxy_adapter/commands/transport_management_command.py +41 -36
- mcp_proxy_adapter/commands/unload_command.py +42 -37
- mcp_proxy_adapter/config.py +36 -35
- mcp_proxy_adapter/core/__init__.py +19 -21
- mcp_proxy_adapter/core/app_factory.py +30 -9
- mcp_proxy_adapter/core/app_runner.py +81 -64
- mcp_proxy_adapter/core/auth_validator.py +176 -182
- mcp_proxy_adapter/core/certificate_utils.py +469 -426
- mcp_proxy_adapter/core/client.py +155 -126
- mcp_proxy_adapter/core/client_manager.py +60 -54
- mcp_proxy_adapter/core/client_security.py +108 -88
- mcp_proxy_adapter/core/config_converter.py +176 -143
- mcp_proxy_adapter/core/config_validator.py +12 -4
- mcp_proxy_adapter/core/crl_utils.py +21 -7
- mcp_proxy_adapter/core/errors.py +64 -20
- mcp_proxy_adapter/core/logging.py +34 -29
- mcp_proxy_adapter/core/mtls_asgi.py +29 -25
- mcp_proxy_adapter/core/mtls_asgi_app.py +66 -54
- mcp_proxy_adapter/core/protocol_manager.py +154 -104
- mcp_proxy_adapter/core/proxy_client.py +202 -144
- mcp_proxy_adapter/core/proxy_registration.py +7 -3
- mcp_proxy_adapter/core/role_utils.py +139 -125
- mcp_proxy_adapter/core/security_adapter.py +88 -77
- mcp_proxy_adapter/core/security_factory.py +50 -44
- mcp_proxy_adapter/core/security_integration.py +72 -24
- mcp_proxy_adapter/core/server_adapter.py +68 -64
- mcp_proxy_adapter/core/server_engine.py +71 -53
- mcp_proxy_adapter/core/settings.py +68 -58
- mcp_proxy_adapter/core/ssl_utils.py +69 -56
- mcp_proxy_adapter/core/transport_manager.py +72 -60
- mcp_proxy_adapter/core/unified_config_adapter.py +201 -150
- mcp_proxy_adapter/core/utils.py +4 -2
- mcp_proxy_adapter/custom_openapi.py +107 -99
- mcp_proxy_adapter/examples/basic_framework/main.py +9 -2
- mcp_proxy_adapter/examples/commands/__init__.py +1 -1
- mcp_proxy_adapter/examples/create_certificates_simple.py +182 -71
- mcp_proxy_adapter/examples/debug_request_state.py +38 -19
- mcp_proxy_adapter/examples/debug_role_chain.py +53 -20
- mcp_proxy_adapter/examples/demo_client.py +48 -36
- mcp_proxy_adapter/examples/examples/basic_framework/main.py +9 -2
- mcp_proxy_adapter/examples/examples/full_application/__init__.py +1 -0
- mcp_proxy_adapter/examples/examples/full_application/commands/custom_echo_command.py +22 -10
- mcp_proxy_adapter/examples/examples/full_application/commands/dynamic_calculator_command.py +24 -17
- mcp_proxy_adapter/examples/examples/full_application/hooks/application_hooks.py +16 -3
- mcp_proxy_adapter/examples/examples/full_application/hooks/builtin_command_hooks.py +13 -3
- mcp_proxy_adapter/examples/examples/full_application/main.py +27 -2
- mcp_proxy_adapter/examples/examples/full_application/proxy_endpoints.py +48 -14
- mcp_proxy_adapter/examples/full_application/__init__.py +1 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +22 -10
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +24 -17
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +16 -3
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +13 -3
- mcp_proxy_adapter/examples/full_application/main.py +27 -2
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +48 -14
- mcp_proxy_adapter/examples/generate_all_certificates.py +198 -73
- mcp_proxy_adapter/examples/generate_certificates.py +31 -16
- mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +220 -74
- mcp_proxy_adapter/examples/generate_test_configs.py +68 -91
- mcp_proxy_adapter/examples/proxy_registration_example.py +76 -75
- mcp_proxy_adapter/examples/run_example.py +23 -5
- mcp_proxy_adapter/examples/run_full_test_suite.py +109 -71
- mcp_proxy_adapter/examples/run_proxy_server.py +22 -9
- mcp_proxy_adapter/examples/run_security_tests.py +103 -41
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +72 -36
- mcp_proxy_adapter/examples/scripts/config_generator.py +288 -187
- mcp_proxy_adapter/examples/scripts/create_certificates_simple.py +185 -72
- mcp_proxy_adapter/examples/scripts/generate_certificates_and_tokens.py +220 -74
- mcp_proxy_adapter/examples/security_test_client.py +196 -127
- mcp_proxy_adapter/examples/setup_test_environment.py +17 -29
- mcp_proxy_adapter/examples/test_config.py +19 -4
- mcp_proxy_adapter/examples/test_config_generator.py +23 -7
- mcp_proxy_adapter/examples/test_examples.py +84 -56
- mcp_proxy_adapter/examples/universal_client.py +119 -62
- mcp_proxy_adapter/openapi.py +108 -115
- mcp_proxy_adapter/utils/config_generator.py +429 -274
- mcp_proxy_adapter/version.py +1 -2
- {mcp_proxy_adapter-6.3.4.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/METADATA +1 -1
- mcp_proxy_adapter-6.3.5.dist-info/RECORD +143 -0
- mcp_proxy_adapter-6.3.4.dist-info/RECORD +0 -143
- {mcp_proxy_adapter-6.3.4.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.3.4.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.3.4.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.3.4.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/top_level.txt +0 -0
@@ -21,15 +21,15 @@ logger = logging.getLogger(__name__)
|
|
21
21
|
class ConfigGenerator:
|
22
22
|
"""
|
23
23
|
Configuration generator for unified mcp_proxy_adapter and mcp_security_framework configs.
|
24
|
-
|
24
|
+
|
25
25
|
Generates comprehensive configuration files with detailed comments and examples
|
26
26
|
for both the proxy adapter and security framework components.
|
27
27
|
"""
|
28
|
-
|
28
|
+
|
29
29
|
def __init__(self):
|
30
30
|
"""Initialize configuration generator."""
|
31
31
|
self.template_config = self._get_template_config()
|
32
|
-
|
32
|
+
|
33
33
|
def _get_template_config(self) -> Dict[str, Any]:
|
34
34
|
"""Get template configuration with all available options."""
|
35
35
|
return {
|
@@ -40,7 +40,7 @@ class ConfigGenerator:
|
|
40
40
|
"debug": False,
|
41
41
|
"log_level": "INFO",
|
42
42
|
"workers": 1,
|
43
|
-
"reload": False
|
43
|
+
"reload": False,
|
44
44
|
},
|
45
45
|
"ssl": {
|
46
46
|
"enabled": False,
|
@@ -49,9 +49,12 @@ class ConfigGenerator:
|
|
49
49
|
"ca_cert": None,
|
50
50
|
"verify_client": False,
|
51
51
|
"client_cert_required": False,
|
52
|
-
"cipher_suites": [
|
52
|
+
"cipher_suites": [
|
53
|
+
"TLS_AES_256_GCM_SHA384",
|
54
|
+
"TLS_CHACHA20_POLY1305_SHA256",
|
55
|
+
],
|
53
56
|
"min_tls_version": "TLSv1.2",
|
54
|
-
"max_tls_version": "1.3"
|
57
|
+
"max_tls_version": "1.3",
|
55
58
|
},
|
56
59
|
"security": {
|
57
60
|
"framework": "mcp_security_framework",
|
@@ -59,7 +62,6 @@ class ConfigGenerator:
|
|
59
62
|
"debug": False,
|
60
63
|
"environment": "dev",
|
61
64
|
"version": "1.0.0",
|
62
|
-
|
63
65
|
"ssl": {
|
64
66
|
"enabled": False,
|
65
67
|
"cert_file": None,
|
@@ -73,9 +75,8 @@ class ConfigGenerator:
|
|
73
75
|
"cipher_suite": None,
|
74
76
|
"check_hostname": True,
|
75
77
|
"check_expiry": True,
|
76
|
-
"expiry_warning_days": 30
|
78
|
+
"expiry_warning_days": 30,
|
77
79
|
},
|
78
|
-
|
79
80
|
"auth": {
|
80
81
|
"enabled": False,
|
81
82
|
"methods": [],
|
@@ -94,10 +95,9 @@ class ConfigGenerator:
|
|
94
95
|
"X-Content-Type-Options": "nosniff",
|
95
96
|
"X-Frame-Options": "DENY",
|
96
97
|
"X-XSS-Protection": "1; mode=block",
|
97
|
-
"Strict-Transport-Security": "max-age=31536000; includeSubDomains"
|
98
|
-
}
|
98
|
+
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
99
|
+
},
|
99
100
|
},
|
100
|
-
|
101
101
|
"certificates": {
|
102
102
|
"enabled": False,
|
103
103
|
"ca_cert_path": None,
|
@@ -112,9 +112,8 @@ class ConfigGenerator:
|
|
112
112
|
"crl_url": None,
|
113
113
|
"crl_validity_days": 30,
|
114
114
|
"auto_renewal": False,
|
115
|
-
"renewal_threshold_days": 30
|
115
|
+
"renewal_threshold_days": 30,
|
116
116
|
},
|
117
|
-
|
118
117
|
"permissions": {
|
119
118
|
"enabled": False,
|
120
119
|
"roles_file": None,
|
@@ -125,9 +124,8 @@ class ConfigGenerator:
|
|
125
124
|
"permission_cache_ttl": 300,
|
126
125
|
"wildcard_permissions": False,
|
127
126
|
"strict_mode": False,
|
128
|
-
"roles": {}
|
127
|
+
"roles": {},
|
129
128
|
},
|
130
|
-
|
131
129
|
"rate_limit": {
|
132
130
|
"enabled": False,
|
133
131
|
"default_requests_per_minute": 60,
|
@@ -138,9 +136,8 @@ class ConfigGenerator:
|
|
138
136
|
"redis_config": None,
|
139
137
|
"cleanup_interval": 300,
|
140
138
|
"exempt_paths": ["/health", "/docs", "/openapi.json"],
|
141
|
-
"exempt_roles": ["admin"]
|
139
|
+
"exempt_roles": ["admin"],
|
142
140
|
},
|
143
|
-
|
144
141
|
"logging": {
|
145
142
|
"enabled": True,
|
146
143
|
"level": "INFO",
|
@@ -153,10 +150,9 @@ class ConfigGenerator:
|
|
153
150
|
"json_format": False,
|
154
151
|
"include_timestamp": True,
|
155
152
|
"include_level": True,
|
156
|
-
"include_module": True
|
157
|
-
}
|
153
|
+
"include_module": True,
|
154
|
+
},
|
158
155
|
},
|
159
|
-
|
160
156
|
"registration": {
|
161
157
|
"enabled": False,
|
162
158
|
"server_url": "https://proxy-registry.example.com",
|
@@ -166,18 +162,18 @@ class ConfigGenerator:
|
|
166
162
|
"cert_file": "mcp_proxy_adapter/examples/certs/proxy_client.crt",
|
167
163
|
"key_file": "mcp_proxy_adapter/examples/keys/proxy_client.key",
|
168
164
|
"ca_cert_file": "mcp_proxy_adapter/examples/certs/ca.crt",
|
169
|
-
"verify_server": True
|
165
|
+
"verify_server": True,
|
170
166
|
},
|
171
167
|
"token": {
|
172
168
|
"enabled": False,
|
173
169
|
"token": "proxy_registration_token_123",
|
174
170
|
"token_type": "bearer",
|
175
|
-
"refresh_interval": 3600
|
171
|
+
"refresh_interval": 3600,
|
176
172
|
},
|
177
173
|
"api_key": {
|
178
174
|
"enabled": False,
|
179
175
|
"key": "proxy_api_key_456",
|
180
|
-
"key_header": "X-Proxy-API-Key"
|
176
|
+
"key_header": "X-Proxy-API-Key",
|
181
177
|
},
|
182
178
|
"proxy_info": {
|
183
179
|
"name": "mcp_proxy_adapter",
|
@@ -187,24 +183,23 @@ class ConfigGenerator:
|
|
187
183
|
"endpoints": {
|
188
184
|
"jsonrpc": "/api/jsonrpc",
|
189
185
|
"rest": "/cmd",
|
190
|
-
"health": "/health"
|
191
|
-
}
|
186
|
+
"health": "/health",
|
187
|
+
},
|
192
188
|
},
|
193
189
|
"heartbeat": {
|
194
190
|
"enabled": True,
|
195
191
|
"interval": 300,
|
196
192
|
"timeout": 30,
|
197
193
|
"retry_attempts": 3,
|
198
|
-
"retry_delay": 60
|
194
|
+
"retry_delay": 60,
|
199
195
|
},
|
200
196
|
"auto_discovery": {
|
201
197
|
"enabled": False,
|
202
198
|
"discovery_urls": [],
|
203
199
|
"discovery_interval": 3600,
|
204
|
-
"register_on_discovery": True
|
205
|
-
}
|
200
|
+
"register_on_discovery": True,
|
201
|
+
},
|
206
202
|
},
|
207
|
-
|
208
203
|
"logging": {
|
209
204
|
"level": "INFO",
|
210
205
|
"console_output": True,
|
@@ -212,17 +207,15 @@ class ConfigGenerator:
|
|
212
207
|
"file_path": None,
|
213
208
|
"max_file_size": 10,
|
214
209
|
"backup_count": 5,
|
215
|
-
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
210
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
216
211
|
},
|
217
|
-
|
218
212
|
"commands": {
|
219
213
|
"auto_discovery": True,
|
220
214
|
"commands_directory": "./commands",
|
221
215
|
"builtin_commands": ["echo", "health", "config"],
|
222
216
|
"custom_commands": [],
|
223
|
-
"command_timeout": 30
|
217
|
+
"command_timeout": 30,
|
224
218
|
},
|
225
|
-
|
226
219
|
"hooks": {
|
227
220
|
"enabled": True,
|
228
221
|
"application_hooks": {
|
@@ -230,7 +223,7 @@ class ConfigGenerator:
|
|
230
223
|
"on_shutdown": [],
|
231
224
|
"before_request": [],
|
232
225
|
"after_request": [],
|
233
|
-
"on_error": []
|
226
|
+
"on_error": [],
|
234
227
|
},
|
235
228
|
"command_hooks": {
|
236
229
|
"before_echo_command": [],
|
@@ -238,22 +231,21 @@ class ConfigGenerator:
|
|
238
231
|
"before_health_command": [],
|
239
232
|
"after_health_command": [],
|
240
233
|
"before_config_command": [],
|
241
|
-
"after_config_command": []
|
242
|
-
}
|
234
|
+
"after_config_command": [],
|
235
|
+
},
|
243
236
|
},
|
244
|
-
|
245
237
|
"protocols": {
|
246
238
|
"enabled": True,
|
247
239
|
"allowed_protocols": ["http", "https"],
|
248
240
|
"default_protocol": "http",
|
249
|
-
"strict_mode": False
|
250
|
-
}
|
241
|
+
"strict_mode": False,
|
242
|
+
},
|
251
243
|
}
|
252
|
-
|
244
|
+
|
253
245
|
def generate_config_with_comments(self, config_type: str = "full") -> str:
|
254
246
|
"""
|
255
247
|
Generate configuration with detailed comments.
|
256
|
-
|
248
|
+
|
257
249
|
Args:
|
258
250
|
config_type: Type of configuration to generate
|
259
251
|
- "full": Complete configuration with all options
|
@@ -274,19 +266,19 @@ class ConfigGenerator:
|
|
274
266
|
JSON configuration string with comments
|
275
267
|
"""
|
276
268
|
config = self._get_config_by_type(config_type)
|
277
|
-
|
269
|
+
|
278
270
|
# Convert to JSON with comments
|
279
271
|
json_str = json.dumps(config, indent=2, ensure_ascii=False)
|
280
|
-
|
272
|
+
|
281
273
|
# Add comments
|
282
274
|
commented_config = self._add_comments(json_str, config_type)
|
283
|
-
|
275
|
+
|
284
276
|
return commented_config
|
285
|
-
|
277
|
+
|
286
278
|
def _get_config_by_type(self, config_type: str) -> Dict[str, Any]:
|
287
279
|
"""Get configuration based on type."""
|
288
280
|
base_config = self.template_config.copy()
|
289
|
-
|
281
|
+
|
290
282
|
if config_type == "minimal":
|
291
283
|
return self._get_minimal_config(base_config)
|
292
284
|
elif config_type == "secure":
|
@@ -317,30 +309,30 @@ class ConfigGenerator:
|
|
317
309
|
return self._get_custom_config(base_config)
|
318
310
|
else: # full
|
319
311
|
return base_config
|
320
|
-
|
312
|
+
|
321
313
|
def _get_minimal_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
322
314
|
"""Get minimal working configuration."""
|
323
315
|
config = base_config.copy()
|
324
|
-
|
316
|
+
|
325
317
|
# Disable security for minimal config
|
326
318
|
config["security"]["enabled"] = False
|
327
319
|
config["security"]["auth"]["enabled"] = False
|
328
320
|
config["security"]["permissions"]["enabled"] = False
|
329
321
|
config["security"]["rate_limit"]["enabled"] = False
|
330
|
-
|
322
|
+
|
331
323
|
# Disable registration for minimal config
|
332
324
|
config["registration"]["enabled"] = False
|
333
|
-
|
325
|
+
|
334
326
|
# Keep only essential settings
|
335
327
|
config["server"]["port"] = 8000
|
336
328
|
config["server"]["debug"] = False
|
337
|
-
|
329
|
+
|
338
330
|
return config
|
339
|
-
|
331
|
+
|
340
332
|
def _get_basic_http_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
341
333
|
"""Get basic HTTP configuration."""
|
342
334
|
config = base_config.copy()
|
343
|
-
|
335
|
+
|
344
336
|
# Basic HTTP settings
|
345
337
|
config["server"]["port"] = 8000
|
346
338
|
config["ssl"]["enabled"] = False
|
@@ -360,17 +352,20 @@ class ConfigGenerator:
|
|
360
352
|
config["registration"]["server_url"] = "http://127.0.0.1:3004/proxy"
|
361
353
|
config["registration"]["proxy_info"]["name"] = "mcp_example_server"
|
362
354
|
config["registration"]["proxy_info"]["capabilities"] = [
|
363
|
-
"jsonrpc",
|
355
|
+
"jsonrpc",
|
356
|
+
"rest",
|
357
|
+
"security",
|
358
|
+
"proxy_registration",
|
364
359
|
]
|
365
360
|
config["registration"]["heartbeat"]["enabled"] = True
|
366
361
|
config["registration"]["heartbeat"]["interval"] = 30
|
367
|
-
|
362
|
+
|
368
363
|
return config
|
369
|
-
|
364
|
+
|
370
365
|
def _get_http_token_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
371
366
|
"""Get HTTP with token authentication configuration."""
|
372
367
|
config = base_config.copy()
|
373
|
-
|
368
|
+
|
374
369
|
# HTTP with token auth
|
375
370
|
config["server"]["port"] = 8001
|
376
371
|
config["ssl"]["enabled"] = False
|
@@ -381,89 +376,105 @@ class ConfigGenerator:
|
|
381
376
|
"test-token-123": {
|
382
377
|
"roles": ["admin"],
|
383
378
|
"permissions": ["*"],
|
384
|
-
"expires": None
|
379
|
+
"expires": None,
|
385
380
|
},
|
386
381
|
"user-token-456": {
|
387
382
|
"roles": ["user"],
|
388
383
|
"permissions": ["read", "execute"],
|
389
|
-
"expires": None
|
390
|
-
}
|
384
|
+
"expires": None,
|
385
|
+
},
|
391
386
|
}
|
392
387
|
config["security"]["permissions"]["enabled"] = True
|
393
|
-
config["security"]["permissions"][
|
388
|
+
config["security"]["permissions"][
|
389
|
+
"roles_file"
|
390
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
394
391
|
config["protocols"]["enabled"] = True
|
395
392
|
config["protocols"]["allowed_protocols"] = ["http"]
|
396
393
|
config["protocols"]["default_protocol"] = "http"
|
397
|
-
|
394
|
+
|
398
395
|
return config
|
399
|
-
|
396
|
+
|
400
397
|
def _get_https_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
401
398
|
"""Get HTTPS configuration."""
|
402
399
|
config = base_config.copy()
|
403
|
-
|
400
|
+
|
404
401
|
# HTTPS settings
|
405
402
|
config["server"]["port"] = 8443
|
406
403
|
config["ssl"]["enabled"] = True
|
407
404
|
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
408
405
|
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
409
406
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
410
|
-
|
407
|
+
|
411
408
|
config["security"]["ssl"]["enabled"] = True
|
412
|
-
config["security"]["ssl"][
|
413
|
-
|
414
|
-
|
415
|
-
|
409
|
+
config["security"]["ssl"][
|
410
|
+
"cert_file"
|
411
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
412
|
+
config["security"]["ssl"][
|
413
|
+
"key_file"
|
414
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
415
|
+
config["security"]["ssl"][
|
416
|
+
"ca_cert_file"
|
417
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
418
|
+
|
416
419
|
config["security"]["auth"]["enabled"] = False
|
417
420
|
config["security"]["permissions"]["enabled"] = False
|
418
421
|
config["security"]["permissions"]["roles_file"] = None
|
419
422
|
config["protocols"]["enabled"] = True
|
420
423
|
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
421
424
|
config["protocols"]["default_protocol"] = "https"
|
422
|
-
|
425
|
+
|
423
426
|
return config
|
424
|
-
|
427
|
+
|
425
428
|
def _get_https_token_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
426
429
|
"""Get HTTPS with token authentication configuration."""
|
427
430
|
config = base_config.copy()
|
428
|
-
|
431
|
+
|
429
432
|
# HTTPS with token auth
|
430
433
|
config["server"]["port"] = 8444
|
431
434
|
config["ssl"]["enabled"] = True
|
432
435
|
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
433
436
|
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
434
437
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
435
|
-
|
438
|
+
|
436
439
|
config["security"]["ssl"]["enabled"] = True
|
437
|
-
config["security"]["ssl"][
|
438
|
-
|
439
|
-
|
440
|
-
|
440
|
+
config["security"]["ssl"][
|
441
|
+
"cert_file"
|
442
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
443
|
+
config["security"]["ssl"][
|
444
|
+
"key_file"
|
445
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
446
|
+
config["security"]["ssl"][
|
447
|
+
"ca_cert_file"
|
448
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
449
|
+
|
441
450
|
config["security"]["auth"]["enabled"] = True
|
442
451
|
config["security"]["auth"]["methods"] = ["api_key"]
|
443
452
|
config["security"]["auth"]["api_keys"] = {
|
444
453
|
"test-token-123": {
|
445
454
|
"roles": ["admin"],
|
446
455
|
"permissions": ["*"],
|
447
|
-
"expires": None
|
456
|
+
"expires": None,
|
448
457
|
},
|
449
458
|
"user-token-456": {
|
450
459
|
"roles": ["user"],
|
451
460
|
"permissions": ["read", "execute"],
|
452
|
-
"expires": None
|
453
|
-
}
|
461
|
+
"expires": None,
|
462
|
+
},
|
454
463
|
}
|
455
464
|
config["security"]["permissions"]["enabled"] = True
|
456
|
-
config["security"]["permissions"][
|
465
|
+
config["security"]["permissions"][
|
466
|
+
"roles_file"
|
467
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
457
468
|
config["protocols"]["enabled"] = True
|
458
469
|
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
459
470
|
config["protocols"]["default_protocol"] = "https"
|
460
|
-
|
471
|
+
|
461
472
|
return config
|
462
|
-
|
473
|
+
|
463
474
|
def _get_mtls_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
464
475
|
"""Get mTLS configuration."""
|
465
476
|
config = base_config.copy()
|
466
|
-
|
477
|
+
|
467
478
|
# mTLS settings
|
468
479
|
config["server"]["port"] = 8445
|
469
480
|
config["ssl"]["enabled"] = True
|
@@ -472,66 +483,90 @@ class ConfigGenerator:
|
|
472
483
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
473
484
|
config["ssl"]["verify_client"] = True
|
474
485
|
config["ssl"]["client_cert_required"] = True
|
475
|
-
|
486
|
+
|
476
487
|
config["security"]["ssl"]["enabled"] = True
|
477
|
-
config["security"]["ssl"][
|
478
|
-
|
479
|
-
|
480
|
-
config["security"]["ssl"][
|
481
|
-
|
488
|
+
config["security"]["ssl"][
|
489
|
+
"cert_file"
|
490
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
491
|
+
config["security"]["ssl"][
|
492
|
+
"key_file"
|
493
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
494
|
+
config["security"]["ssl"][
|
495
|
+
"ca_cert_file"
|
496
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
497
|
+
config["security"]["ssl"][
|
498
|
+
"client_cert_file"
|
499
|
+
] = "mcp_proxy_adapter/examples/certs/client_cert.pem"
|
500
|
+
config["security"]["ssl"][
|
501
|
+
"client_key_file"
|
502
|
+
] = "mcp_proxy_adapter/examples/certs/client_key.pem"
|
482
503
|
config["security"]["ssl"]["verify_mode"] = "CERT_REQUIRED"
|
483
|
-
|
504
|
+
|
484
505
|
config["security"]["auth"]["enabled"] = True
|
485
506
|
config["security"]["auth"]["methods"] = ["certificate"]
|
486
507
|
config["security"]["auth"]["certificate_auth"] = True
|
487
508
|
config["security"]["permissions"]["enabled"] = True
|
488
|
-
config["security"]["permissions"][
|
509
|
+
config["security"]["permissions"][
|
510
|
+
"roles_file"
|
511
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
489
512
|
config["protocols"]["enabled"] = True
|
490
513
|
config["protocols"]["allowed_protocols"] = ["https", "mtls"]
|
491
514
|
config["protocols"]["default_protocol"] = "https"
|
492
|
-
|
515
|
+
|
493
516
|
return config
|
494
|
-
|
495
|
-
def _get_https_no_protocol_middleware_config(
|
517
|
+
|
518
|
+
def _get_https_no_protocol_middleware_config(
|
519
|
+
self, base_config: Dict[str, Any]
|
520
|
+
) -> Dict[str, Any]:
|
496
521
|
"""Get HTTPS configuration without ProtocolMiddleware."""
|
497
522
|
config = base_config.copy()
|
498
|
-
|
523
|
+
|
499
524
|
# HTTPS settings
|
500
525
|
config["server"]["port"] = 8445
|
501
526
|
config["ssl"]["enabled"] = True
|
502
527
|
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
503
528
|
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
504
529
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
505
|
-
|
530
|
+
|
506
531
|
config["security"]["ssl"]["enabled"] = True
|
507
|
-
config["security"]["ssl"][
|
508
|
-
|
509
|
-
|
510
|
-
|
532
|
+
config["security"]["ssl"][
|
533
|
+
"cert_file"
|
534
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
535
|
+
config["security"]["ssl"][
|
536
|
+
"key_file"
|
537
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
538
|
+
config["security"]["ssl"][
|
539
|
+
"ca_cert_file"
|
540
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
541
|
+
|
511
542
|
config["security"]["auth"]["enabled"] = True
|
512
543
|
config["security"]["auth"]["methods"] = ["api_key"]
|
513
544
|
config["security"]["auth"]["api_keys"] = {
|
514
545
|
"test-token-123": {
|
515
546
|
"roles": ["admin"],
|
516
547
|
"permissions": ["*"],
|
517
|
-
"expires": None
|
548
|
+
"expires": None,
|
518
549
|
},
|
519
550
|
"user-token-456": {
|
520
551
|
"roles": ["user"],
|
521
552
|
"permissions": ["read", "execute"],
|
522
|
-
"expires": None
|
523
|
-
}
|
553
|
+
"expires": None,
|
554
|
+
},
|
524
555
|
}
|
525
556
|
config["security"]["permissions"]["enabled"] = True
|
526
|
-
config["security"]["permissions"][
|
557
|
+
config["security"]["permissions"][
|
558
|
+
"roles_file"
|
559
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
527
560
|
config["protocols"]["enabled"] = False # Disable ProtocolMiddleware
|
528
|
-
|
561
|
+
|
529
562
|
return config
|
530
|
-
|
531
|
-
def _get_mtls_no_protocol_middleware_config(
|
563
|
+
|
564
|
+
def _get_mtls_no_protocol_middleware_config(
|
565
|
+
self, base_config: Dict[str, Any]
|
566
|
+
) -> Dict[str, Any]:
|
532
567
|
"""Get mTLS configuration without ProtocolMiddleware."""
|
533
568
|
config = base_config.copy()
|
534
|
-
|
569
|
+
|
535
570
|
# mTLS settings
|
536
571
|
config["server"]["port"] = 8447
|
537
572
|
config["ssl"]["enabled"] = True
|
@@ -540,311 +575,355 @@ class ConfigGenerator:
|
|
540
575
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
541
576
|
config["ssl"]["verify_client"] = True
|
542
577
|
config["ssl"]["client_cert_required"] = True
|
543
|
-
|
578
|
+
|
544
579
|
config["security"]["ssl"]["enabled"] = True
|
545
|
-
config["security"]["ssl"][
|
546
|
-
|
547
|
-
|
548
|
-
config["security"]["ssl"][
|
549
|
-
|
580
|
+
config["security"]["ssl"][
|
581
|
+
"cert_file"
|
582
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
583
|
+
config["security"]["ssl"][
|
584
|
+
"key_file"
|
585
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
586
|
+
config["security"]["ssl"][
|
587
|
+
"ca_cert_file"
|
588
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
589
|
+
config["security"]["ssl"][
|
590
|
+
"client_cert_file"
|
591
|
+
] = "mcp_proxy_adapter/examples/certs/client_cert.pem"
|
592
|
+
config["security"]["ssl"][
|
593
|
+
"client_key_file"
|
594
|
+
] = "mcp_proxy_adapter/examples/certs/client_key.pem"
|
550
595
|
config["security"]["ssl"]["verify_mode"] = "CERT_REQUIRED"
|
551
|
-
|
596
|
+
|
552
597
|
config["security"]["auth"]["enabled"] = True
|
553
598
|
config["security"]["auth"]["methods"] = ["certificate"]
|
554
599
|
config["security"]["auth"]["certificate_auth"] = True
|
555
600
|
config["security"]["permissions"]["enabled"] = True
|
556
|
-
config["security"]["permissions"][
|
601
|
+
config["security"]["permissions"][
|
602
|
+
"roles_file"
|
603
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
557
604
|
config["protocols"]["enabled"] = False # Disable ProtocolMiddleware
|
558
|
-
|
605
|
+
|
559
606
|
return config
|
560
|
-
|
607
|
+
|
561
608
|
def _get_optional_ssl_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
562
609
|
"""Get configuration with optional SSL support."""
|
563
610
|
config = base_config.copy()
|
564
|
-
|
611
|
+
|
565
612
|
# Server configuration
|
566
613
|
config["server"]["port"] = 8000
|
567
|
-
|
614
|
+
|
568
615
|
# SSL configuration - can be enabled/disabled via environment or config
|
569
616
|
config["ssl"]["enabled"] = False # Default disabled, can be enabled
|
570
617
|
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
571
618
|
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
572
619
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
573
620
|
config["ssl"]["verify_client"] = False # Can be enabled for mTLS
|
574
|
-
|
621
|
+
|
575
622
|
# Security framework SSL - mirrors main SSL config
|
576
623
|
config["security"]["ssl"]["enabled"] = False # Default disabled
|
577
|
-
config["security"]["ssl"][
|
578
|
-
|
579
|
-
|
580
|
-
config["security"]["ssl"][
|
581
|
-
|
582
|
-
|
624
|
+
config["security"]["ssl"][
|
625
|
+
"cert_file"
|
626
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
627
|
+
config["security"]["ssl"][
|
628
|
+
"key_file"
|
629
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
630
|
+
config["security"]["ssl"][
|
631
|
+
"ca_cert_file"
|
632
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
633
|
+
config["security"]["ssl"][
|
634
|
+
"client_cert_file"
|
635
|
+
] = "mcp_proxy_adapter/examples/certs/client_cert.pem"
|
636
|
+
config["security"]["ssl"][
|
637
|
+
"client_key_file"
|
638
|
+
] = "mcp_proxy_adapter/examples/certs/client_key.key"
|
639
|
+
|
583
640
|
# Protocols support both HTTP and HTTPS
|
584
641
|
config["protocols"]["enabled"] = True
|
585
642
|
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
586
643
|
config["protocols"]["default_protocol"] = "http"
|
587
|
-
|
644
|
+
|
588
645
|
# Enable proxy registration with token auth
|
589
646
|
config["registration"]["enabled"] = True
|
590
647
|
config["registration"]["auth_method"] = "token"
|
591
648
|
config["registration"]["token"]["enabled"] = True
|
592
649
|
config["registration"]["token"]["token"] = "proxy_registration_token_123"
|
593
650
|
config["registration"]["server_url"] = "http://127.0.0.1:3004/proxy"
|
594
|
-
|
651
|
+
|
595
652
|
return config
|
596
|
-
|
653
|
+
|
597
654
|
def _get_optional_auth_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
598
655
|
"""Get configuration with optional authentication support."""
|
599
656
|
config = base_config.copy()
|
600
|
-
|
657
|
+
|
601
658
|
# Server configuration
|
602
659
|
config["server"]["port"] = 8001
|
603
|
-
|
660
|
+
|
604
661
|
# SSL disabled by default
|
605
662
|
config["ssl"]["enabled"] = False
|
606
663
|
config["security"]["ssl"]["enabled"] = False
|
607
|
-
|
664
|
+
|
608
665
|
# Authentication configuration - can be enabled/disabled
|
609
666
|
config["security"]["auth"]["enabled"] = False # Default disabled
|
610
667
|
config["security"]["auth"]["methods"] = ["api_key", "jwt"] # Available methods
|
611
|
-
|
668
|
+
|
612
669
|
# API keys configuration
|
613
670
|
config["security"]["auth"]["api_keys"] = {
|
614
|
-
"admin-token": {
|
615
|
-
"roles": ["admin"],
|
616
|
-
"permissions": ["*"],
|
617
|
-
"expires": None
|
618
|
-
},
|
671
|
+
"admin-token": {"roles": ["admin"], "permissions": ["*"], "expires": None},
|
619
672
|
"user-token": {
|
620
673
|
"roles": ["user"],
|
621
674
|
"permissions": ["read", "execute"],
|
622
|
-
"expires": None
|
675
|
+
"expires": None,
|
623
676
|
},
|
624
677
|
"guest-token": {
|
625
678
|
"roles": ["guest"],
|
626
679
|
"permissions": ["read"],
|
627
|
-
"expires": None
|
628
|
-
}
|
680
|
+
"expires": None,
|
681
|
+
},
|
629
682
|
}
|
630
|
-
|
683
|
+
|
631
684
|
# JWT configuration
|
632
685
|
config["security"]["auth"]["jwt_secret"] = "your_jwt_secret_here"
|
633
686
|
config["security"]["auth"]["jwt_algorithm"] = "HS256"
|
634
687
|
config["security"]["auth"]["jwt_expiry_hours"] = 24
|
635
|
-
|
688
|
+
|
636
689
|
# User roles mapping
|
637
690
|
config["security"]["auth"]["user_roles"] = {
|
638
691
|
"admin": ["admin"],
|
639
692
|
"user": ["user"],
|
640
|
-
"guest": ["guest"]
|
693
|
+
"guest": ["guest"],
|
641
694
|
}
|
642
|
-
|
695
|
+
|
643
696
|
# Permissions configuration - can be enabled/disabled
|
644
697
|
config["security"]["permissions"]["enabled"] = False # Default disabled
|
645
|
-
config["security"]["permissions"][
|
698
|
+
config["security"]["permissions"][
|
699
|
+
"roles_file"
|
700
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
646
701
|
config["security"]["permissions"]["default_role"] = "guest"
|
647
702
|
config["security"]["permissions"]["admin_role"] = "admin"
|
648
|
-
|
703
|
+
|
649
704
|
# Protocols
|
650
705
|
config["protocols"]["enabled"] = True
|
651
706
|
config["protocols"]["allowed_protocols"] = ["http"]
|
652
707
|
config["protocols"]["default_protocol"] = "http"
|
653
|
-
|
708
|
+
|
654
709
|
# Enable proxy registration
|
655
710
|
config["registration"]["enabled"] = True
|
656
711
|
config["registration"]["auth_method"] = "token"
|
657
712
|
config["registration"]["token"]["enabled"] = True
|
658
713
|
config["registration"]["token"]["token"] = "proxy_registration_token_123"
|
659
|
-
|
714
|
+
|
660
715
|
return config
|
661
|
-
|
662
|
-
def _get_optional_proxy_reg_config(
|
716
|
+
|
717
|
+
def _get_optional_proxy_reg_config(
|
718
|
+
self, base_config: Dict[str, Any]
|
719
|
+
) -> Dict[str, Any]:
|
663
720
|
"""Get configuration with optional proxy registration support."""
|
664
721
|
config = base_config.copy()
|
665
|
-
|
722
|
+
|
666
723
|
# Server configuration
|
667
724
|
config["server"]["port"] = 8002
|
668
|
-
|
725
|
+
|
669
726
|
# SSL disabled by default
|
670
727
|
config["ssl"]["enabled"] = False
|
671
728
|
config["security"]["ssl"]["enabled"] = False
|
672
|
-
|
729
|
+
|
673
730
|
# Authentication disabled by default
|
674
731
|
config["security"]["auth"]["enabled"] = False
|
675
732
|
config["security"]["permissions"]["enabled"] = False
|
676
|
-
|
733
|
+
|
677
734
|
# Proxy registration configuration - can be enabled/disabled
|
678
735
|
config["registration"]["enabled"] = False # Default disabled
|
679
736
|
config["registration"]["server_url"] = "http://127.0.0.1:3004/proxy"
|
680
737
|
config["registration"]["server_id"] = "mcp_proxy_adapter"
|
681
738
|
config["registration"]["server_name"] = "MCP Proxy Adapter"
|
682
|
-
config["registration"][
|
683
|
-
|
739
|
+
config["registration"][
|
740
|
+
"description"
|
741
|
+
] = "JSON-RPC API for interacting with MCP Proxy"
|
742
|
+
|
684
743
|
# Multiple authentication methods for proxy registration
|
685
744
|
config["registration"]["auth_method"] = "token" # Default method
|
686
|
-
|
745
|
+
|
687
746
|
# Token authentication
|
688
747
|
config["registration"]["token"]["enabled"] = True
|
689
748
|
config["registration"]["token"]["token"] = "proxy_registration_token_123"
|
690
749
|
config["registration"]["token"]["token_type"] = "bearer"
|
691
750
|
config["registration"]["token"]["refresh_interval"] = 3600
|
692
|
-
|
751
|
+
|
693
752
|
# Certificate authentication
|
694
753
|
config["registration"]["certificate"]["enabled"] = False
|
695
|
-
config["registration"]["certificate"][
|
696
|
-
|
697
|
-
|
754
|
+
config["registration"]["certificate"][
|
755
|
+
"cert_file"
|
756
|
+
] = "mcp_proxy_adapter/examples/certs/proxy_client.crt"
|
757
|
+
config["registration"]["certificate"][
|
758
|
+
"key_file"
|
759
|
+
] = "mcp_proxy_adapter/examples/keys/proxy_client.key"
|
760
|
+
config["registration"]["certificate"][
|
761
|
+
"ca_cert_file"
|
762
|
+
] = "mcp_proxy_adapter/examples/certs/ca.crt"
|
698
763
|
config["registration"]["certificate"]["verify_server"] = True
|
699
|
-
|
764
|
+
|
700
765
|
# API key authentication
|
701
766
|
config["registration"]["api_key"]["enabled"] = False
|
702
767
|
config["registration"]["api_key"]["key"] = "proxy_api_key_456"
|
703
768
|
config["registration"]["api_key"]["key_header"] = "X-Proxy-API-Key"
|
704
|
-
|
769
|
+
|
705
770
|
# Proxy information
|
706
771
|
config["registration"]["proxy_info"]["name"] = "mcp_proxy_adapter"
|
707
772
|
config["registration"]["proxy_info"]["version"] = "1.0.0"
|
708
|
-
config["registration"]["proxy_info"][
|
709
|
-
|
773
|
+
config["registration"]["proxy_info"][
|
774
|
+
"description"
|
775
|
+
] = "MCP Proxy Adapter with optional features"
|
776
|
+
config["registration"]["proxy_info"]["capabilities"] = [
|
777
|
+
"jsonrpc",
|
778
|
+
"rest",
|
779
|
+
"optional_features",
|
780
|
+
]
|
710
781
|
config["registration"]["proxy_info"]["endpoints"] = {
|
711
782
|
"jsonrpc": "/api/jsonrpc",
|
712
783
|
"rest": "/cmd",
|
713
|
-
"health": "/health"
|
784
|
+
"health": "/health",
|
714
785
|
}
|
715
|
-
|
786
|
+
|
716
787
|
# Heartbeat configuration
|
717
788
|
config["registration"]["heartbeat"]["enabled"] = True
|
718
789
|
config["registration"]["heartbeat"]["interval"] = 300
|
719
790
|
config["registration"]["heartbeat"]["timeout"] = 30
|
720
791
|
config["registration"]["heartbeat"]["retry_attempts"] = 3
|
721
792
|
config["registration"]["heartbeat"]["retry_delay"] = 60
|
722
|
-
|
793
|
+
|
723
794
|
# Auto-discovery
|
724
795
|
config["registration"]["auto_discovery"]["enabled"] = False
|
725
796
|
config["registration"]["auto_discovery"]["discovery_urls"] = []
|
726
797
|
config["registration"]["auto_discovery"]["discovery_interval"] = 3600
|
727
798
|
config["registration"]["auto_discovery"]["register_on_discovery"] = True
|
728
|
-
|
799
|
+
|
729
800
|
# Protocols
|
730
801
|
config["protocols"]["enabled"] = True
|
731
802
|
config["protocols"]["allowed_protocols"] = ["http"]
|
732
803
|
config["protocols"]["default_protocol"] = "http"
|
733
|
-
|
804
|
+
|
734
805
|
return config
|
735
|
-
|
806
|
+
|
736
807
|
def _get_custom_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
737
808
|
"""Get custom configuration with configurable features."""
|
738
809
|
config = base_config.copy()
|
739
|
-
|
810
|
+
|
740
811
|
# Server configuration
|
741
812
|
config["server"]["port"] = 8003
|
742
|
-
|
813
|
+
|
743
814
|
# SSL configuration - configurable
|
744
815
|
config["ssl"]["enabled"] = False # Can be enabled via config
|
745
816
|
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
746
817
|
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
747
818
|
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
748
819
|
config["ssl"]["verify_client"] = False # Can be enabled for mTLS
|
749
|
-
|
820
|
+
|
750
821
|
# Security framework - configurable
|
751
822
|
config["security"]["enabled"] = False # Can be enabled via config
|
752
823
|
config["security"]["ssl"]["enabled"] = False # Mirrors main SSL
|
753
|
-
config["security"]["ssl"][
|
754
|
-
|
755
|
-
|
756
|
-
|
824
|
+
config["security"]["ssl"][
|
825
|
+
"cert_file"
|
826
|
+
] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
827
|
+
config["security"]["ssl"][
|
828
|
+
"key_file"
|
829
|
+
] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
830
|
+
config["security"]["ssl"][
|
831
|
+
"ca_cert_file"
|
832
|
+
] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
833
|
+
|
757
834
|
# Authentication - configurable
|
758
835
|
config["security"]["auth"]["enabled"] = False # Can be enabled via config
|
759
836
|
config["security"]["auth"]["methods"] = ["api_key", "jwt", "certificate"]
|
760
837
|
config["security"]["auth"]["api_keys"] = {
|
761
|
-
"custom-admin": {
|
762
|
-
"roles": ["admin"],
|
763
|
-
"permissions": ["*"],
|
764
|
-
"expires": None
|
765
|
-
},
|
838
|
+
"custom-admin": {"roles": ["admin"], "permissions": ["*"], "expires": None},
|
766
839
|
"custom-user": {
|
767
840
|
"roles": ["user"],
|
768
841
|
"permissions": ["read", "execute"],
|
769
|
-
"expires": None
|
770
|
-
}
|
842
|
+
"expires": None,
|
843
|
+
},
|
771
844
|
}
|
772
|
-
|
845
|
+
|
773
846
|
# Permissions - configurable
|
774
|
-
config["security"]["permissions"][
|
775
|
-
|
776
|
-
|
847
|
+
config["security"]["permissions"][
|
848
|
+
"enabled"
|
849
|
+
] = False # Can be enabled via config
|
850
|
+
config["security"]["permissions"][
|
851
|
+
"roles_file"
|
852
|
+
] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
853
|
+
|
777
854
|
# Rate limiting - configurable
|
778
855
|
config["security"]["rate_limit"]["enabled"] = False # Can be enabled via config
|
779
856
|
config["security"]["rate_limit"]["default_requests_per_minute"] = 60
|
780
857
|
config["security"]["rate_limit"]["default_requests_per_hour"] = 1000
|
781
|
-
|
858
|
+
|
782
859
|
# Certificates - configurable
|
783
|
-
config["security"]["certificates"][
|
860
|
+
config["security"]["certificates"][
|
861
|
+
"enabled"
|
862
|
+
] = False # Can be enabled via config
|
784
863
|
config["security"]["certificates"]["cert_storage_path"] = "./certs"
|
785
864
|
config["security"]["certificates"]["key_storage_path"] = "./keys"
|
786
|
-
|
865
|
+
|
787
866
|
# Proxy registration - configurable
|
788
867
|
config["registration"]["enabled"] = False # Can be enabled via config
|
789
868
|
config["registration"]["auth_method"] = "token"
|
790
869
|
config["registration"]["token"]["enabled"] = True
|
791
870
|
config["registration"]["token"]["token"] = "custom_proxy_token"
|
792
|
-
|
871
|
+
|
793
872
|
# Protocols
|
794
873
|
config["protocols"]["enabled"] = True
|
795
874
|
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
796
875
|
config["protocols"]["default_protocol"] = "http"
|
797
|
-
|
876
|
+
|
798
877
|
return config
|
799
|
-
|
878
|
+
|
800
879
|
def _get_secure_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
801
880
|
"""Get secure configuration with all security features enabled."""
|
802
881
|
config = base_config.copy()
|
803
|
-
|
882
|
+
|
804
883
|
# Enable all security features
|
805
884
|
config["security"]["enabled"] = True
|
806
885
|
config["security"]["ssl"]["enabled"] = True
|
807
886
|
config["security"]["auth"]["enabled"] = True
|
808
887
|
config["security"]["permissions"]["enabled"] = True
|
809
888
|
config["security"]["rate_limit"]["enabled"] = True
|
810
|
-
|
889
|
+
|
811
890
|
# Enable registration with certificate auth
|
812
891
|
config["registration"]["enabled"] = True
|
813
892
|
config["registration"]["auth_method"] = "certificate"
|
814
893
|
config["registration"]["certificate"]["enabled"] = True
|
815
|
-
|
894
|
+
|
816
895
|
# Set secure defaults
|
817
896
|
config["security"]["ssl"]["min_tls_version"] = "TLSv1.2"
|
818
897
|
config["security"]["auth"]["methods"] = ["api_key", "jwt"]
|
819
898
|
config["security"]["permissions"]["strict_mode"] = True
|
820
899
|
config["security"]["rate_limit"]["burst_limit"] = 1
|
821
|
-
|
900
|
+
|
822
901
|
return config
|
823
|
-
|
902
|
+
|
824
903
|
def _get_development_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
825
904
|
"""Get development configuration with debug enabled."""
|
826
905
|
config = base_config.copy()
|
827
|
-
|
906
|
+
|
828
907
|
# Enable debug features
|
829
908
|
config["server"]["debug"] = True
|
830
909
|
config["security"]["debug"] = True
|
831
910
|
config["logging"]["level"] = "DEBUG"
|
832
|
-
|
911
|
+
|
833
912
|
# Enable registration with token auth for development
|
834
913
|
config["registration"]["enabled"] = True
|
835
914
|
config["registration"]["auth_method"] = "token"
|
836
915
|
config["registration"]["token"]["enabled"] = True
|
837
|
-
|
916
|
+
|
838
917
|
# Relax security for development
|
839
918
|
config["security"]["rate_limit"]["default_requests_per_minute"] = 1000
|
840
919
|
config["security"]["permissions"]["strict_mode"] = False
|
841
|
-
|
920
|
+
|
842
921
|
return config
|
843
|
-
|
922
|
+
|
844
923
|
def _add_comments(self, json_str: str, config_type: str) -> str:
|
845
924
|
"""Add comments to JSON configuration."""
|
846
925
|
comments = self._get_comments_for_type(config_type)
|
847
|
-
|
926
|
+
|
848
927
|
# Add header comment
|
849
928
|
commented_config = f"""/**
|
850
929
|
* MCP Proxy Adapter Configuration
|
@@ -860,7 +939,7 @@ class ConfigGenerator:
|
|
860
939
|
*/
|
861
940
|
|
862
941
|
"""
|
863
|
-
|
942
|
+
|
864
943
|
# Add section comments
|
865
944
|
for section, comment in comments.items():
|
866
945
|
if section in json_str:
|
@@ -868,15 +947,15 @@ class ConfigGenerator:
|
|
868
947
|
section_start = json_str.find(f'"{section}":')
|
869
948
|
if section_start != -1:
|
870
949
|
# Find the line start
|
871
|
-
line_start = json_str.rfind(
|
950
|
+
line_start = json_str.rfind("\n", 0, section_start) + 1
|
872
951
|
json_str = (
|
873
|
-
json_str[:line_start]
|
874
|
-
f" // {comment}\n"
|
875
|
-
json_str[line_start:]
|
952
|
+
json_str[:line_start]
|
953
|
+
+ f" // {comment}\n"
|
954
|
+
+ json_str[line_start:]
|
876
955
|
)
|
877
|
-
|
956
|
+
|
878
957
|
return commented_config + json_str
|
879
|
-
|
958
|
+
|
880
959
|
def _get_comments_for_type(self, config_type: str) -> Dict[str, str]:
|
881
960
|
"""Get comments for configuration sections."""
|
882
961
|
base_comments = {
|
@@ -888,50 +967,94 @@ class ConfigGenerator:
|
|
888
967
|
"logging": "Logging configuration for the application",
|
889
968
|
"commands": "Command management and discovery settings",
|
890
969
|
"hooks": "Application and command hooks configuration",
|
891
|
-
"protocols": "Protocol endpoints and settings"
|
970
|
+
"protocols": "Protocol endpoints and settings",
|
892
971
|
}
|
893
|
-
|
972
|
+
|
894
973
|
if config_type == "minimal":
|
895
|
-
base_comments["security"] =
|
896
|
-
|
974
|
+
base_comments["security"] = (
|
975
|
+
"Security framework configuration (disabled for minimal setup)"
|
976
|
+
)
|
977
|
+
base_comments["registration"] = (
|
978
|
+
"Proxy registration configuration (disabled for minimal setup)"
|
979
|
+
)
|
897
980
|
elif config_type == "secure":
|
898
|
-
base_comments["security"] =
|
899
|
-
|
981
|
+
base_comments["security"] = (
|
982
|
+
"Security framework configuration (all features enabled)"
|
983
|
+
)
|
984
|
+
base_comments["registration"] = (
|
985
|
+
"Proxy registration configuration (certificate authentication enabled)"
|
986
|
+
)
|
900
987
|
elif config_type == "development":
|
901
|
-
base_comments["security"] =
|
902
|
-
|
988
|
+
base_comments["security"] = (
|
989
|
+
"Security framework configuration (development mode with relaxed settings)"
|
990
|
+
)
|
991
|
+
base_comments["registration"] = (
|
992
|
+
"Proxy registration configuration (token authentication for development)"
|
993
|
+
)
|
903
994
|
elif config_type in ["basic_http", "http_token"]:
|
904
995
|
base_comments["ssl"] = "SSL/TLS configuration (disabled for HTTP)"
|
905
|
-
base_comments["security"] =
|
996
|
+
base_comments["security"] = (
|
997
|
+
f"Security framework configuration ({config_type} mode)"
|
998
|
+
)
|
906
999
|
elif config_type in ["https", "https_token"]:
|
907
1000
|
base_comments["ssl"] = "SSL/TLS configuration (enabled for HTTPS)"
|
908
|
-
base_comments["security"] =
|
1001
|
+
base_comments["security"] = (
|
1002
|
+
f"Security framework configuration ({config_type} mode)"
|
1003
|
+
)
|
909
1004
|
elif config_type == "mtls":
|
910
|
-
base_comments["ssl"] =
|
911
|
-
|
1005
|
+
base_comments["ssl"] = (
|
1006
|
+
"SSL/TLS configuration (enabled for mTLS with client certificate verification)"
|
1007
|
+
)
|
1008
|
+
base_comments["security"] = (
|
1009
|
+
"Security framework configuration (mTLS mode with certificate authentication)"
|
1010
|
+
)
|
912
1011
|
elif config_type == "https_no_protocol_middleware":
|
913
|
-
base_comments["ssl"] =
|
914
|
-
|
1012
|
+
base_comments["ssl"] = (
|
1013
|
+
"SSL/TLS configuration (enabled for HTTPS without ProtocolMiddleware)"
|
1014
|
+
)
|
1015
|
+
base_comments["security"] = (
|
1016
|
+
"Security framework configuration (HTTPS mode without ProtocolMiddleware)"
|
1017
|
+
)
|
915
1018
|
elif config_type == "mtls_no_protocol_middleware":
|
916
|
-
base_comments["ssl"] =
|
917
|
-
|
1019
|
+
base_comments["ssl"] = (
|
1020
|
+
"SSL/TLS configuration (enabled for mTLS without ProtocolMiddleware)"
|
1021
|
+
)
|
1022
|
+
base_comments["security"] = (
|
1023
|
+
"Security framework configuration (mTLS mode without ProtocolMiddleware)"
|
1024
|
+
)
|
918
1025
|
elif config_type == "optional_ssl":
|
919
|
-
base_comments["ssl"] =
|
920
|
-
|
1026
|
+
base_comments["ssl"] = (
|
1027
|
+
"SSL/TLS configuration (optional, can be enabled/disabled)"
|
1028
|
+
)
|
1029
|
+
base_comments["security"] = (
|
1030
|
+
"Security framework SSL configuration (mirrors main SSL)"
|
1031
|
+
)
|
921
1032
|
elif config_type == "optional_auth":
|
922
1033
|
base_comments["ssl"] = "SSL/TLS configuration (disabled for optional auth)"
|
923
|
-
base_comments["security"] =
|
1034
|
+
base_comments["security"] = (
|
1035
|
+
"Security framework authentication configuration (optional, can be enabled/disabled)"
|
1036
|
+
)
|
924
1037
|
elif config_type == "optional_proxy_reg":
|
925
|
-
base_comments["ssl"] =
|
926
|
-
|
1038
|
+
base_comments["ssl"] = (
|
1039
|
+
"SSL/TLS configuration (disabled for optional proxy reg)"
|
1040
|
+
)
|
1041
|
+
base_comments["security"] = (
|
1042
|
+
"Security framework proxy registration configuration (optional, can be enabled/disabled)"
|
1043
|
+
)
|
927
1044
|
elif config_type == "custom":
|
928
1045
|
base_comments["ssl"] = "SSL/TLS configuration (configurable)"
|
929
|
-
base_comments["security"] =
|
930
|
-
|
931
|
-
|
932
|
-
|
1046
|
+
base_comments["security"] = (
|
1047
|
+
"Security framework configuration (configurable)"
|
1048
|
+
)
|
1049
|
+
base_comments["registration"] = (
|
1050
|
+
"Proxy registration configuration (configurable)"
|
1051
|
+
)
|
1052
|
+
base_comments["protocols"] = (
|
1053
|
+
"Protocol endpoints and settings (configurable)"
|
1054
|
+
)
|
1055
|
+
|
933
1056
|
return base_comments
|
934
|
-
|
1057
|
+
|
935
1058
|
def generate_config_file(self, output_path: str, config_type: str = "full") -> None:
|
936
1059
|
"""
|
937
1060
|
Generate configuration file and save to disk.
|
@@ -943,65 +1066,97 @@ class ConfigGenerator:
|
|
943
1066
|
try:
|
944
1067
|
# Get configuration without comments for file generation
|
945
1068
|
config = self._get_config_by_type(config_type)
|
946
|
-
|
1069
|
+
|
947
1070
|
# Create directory if it doesn't exist
|
948
1071
|
output_file = Path(output_path)
|
949
1072
|
output_file.parent.mkdir(parents=True, exist_ok=True)
|
950
|
-
|
1073
|
+
|
951
1074
|
# Write configuration file as clean JSON
|
952
|
-
with open(output_file,
|
1075
|
+
with open(output_file, "w", encoding="utf-8") as f:
|
953
1076
|
json.dump(config, f, indent=2, ensure_ascii=False)
|
954
|
-
|
1077
|
+
|
955
1078
|
logger.info(f"Configuration file generated: {output_path}")
|
956
1079
|
logger.info(f"Configuration type: {config_type}")
|
957
|
-
|
1080
|
+
|
958
1081
|
except Exception as e:
|
959
1082
|
logger.error(f"Failed to generate configuration file: {e}")
|
960
1083
|
raise
|
961
|
-
|
1084
|
+
|
962
1085
|
def generate_all_configs(self, output_dir: str) -> None:
|
963
1086
|
"""
|
964
1087
|
Generate all configuration types.
|
965
|
-
|
1088
|
+
|
966
1089
|
Args:
|
967
1090
|
output_dir: Directory to save configuration files
|
968
1091
|
"""
|
969
1092
|
config_types = [
|
970
|
-
"minimal",
|
971
|
-
"
|
972
|
-
"
|
973
|
-
"
|
1093
|
+
"minimal",
|
1094
|
+
"development",
|
1095
|
+
"secure",
|
1096
|
+
"full",
|
1097
|
+
"basic_http",
|
1098
|
+
"http_token",
|
1099
|
+
"https",
|
1100
|
+
"https_token",
|
1101
|
+
"mtls",
|
1102
|
+
"https_no_protocol_middleware",
|
1103
|
+
"mtls_no_protocol_middleware",
|
1104
|
+
"optional_ssl",
|
1105
|
+
"optional_auth",
|
1106
|
+
"optional_proxy_reg",
|
1107
|
+
"custom",
|
974
1108
|
]
|
975
|
-
|
1109
|
+
|
976
1110
|
for config_type in config_types:
|
977
1111
|
output_path = Path(output_dir) / f"config_{config_type}.json"
|
978
1112
|
self.generate_config_file(str(output_path), config_type)
|
979
|
-
|
980
|
-
logger.info(
|
1113
|
+
|
1114
|
+
logger.info(
|
1115
|
+
f"Generated {len(config_types)} configuration files in {output_dir}"
|
1116
|
+
)
|
981
1117
|
|
982
1118
|
|
983
1119
|
def main():
|
984
1120
|
"""Main function for command-line usage."""
|
985
1121
|
import argparse
|
986
|
-
|
987
|
-
parser = argparse.ArgumentParser(
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1122
|
+
|
1123
|
+
parser = argparse.ArgumentParser(
|
1124
|
+
description="Generate MCP Proxy Adapter configuration files"
|
1125
|
+
)
|
1126
|
+
parser.add_argument(
|
1127
|
+
"--type",
|
1128
|
+
choices=[
|
1129
|
+
"minimal",
|
1130
|
+
"development",
|
1131
|
+
"secure",
|
1132
|
+
"full",
|
1133
|
+
"basic_http",
|
1134
|
+
"http_token",
|
1135
|
+
"https",
|
1136
|
+
"https_token",
|
1137
|
+
"mtls",
|
1138
|
+
"https_no_protocol_middleware",
|
1139
|
+
"mtls_no_protocol_middleware",
|
1140
|
+
"optional_ssl",
|
1141
|
+
"optional_auth",
|
1142
|
+
"optional_proxy_reg",
|
1143
|
+
"custom",
|
1144
|
+
],
|
1145
|
+
default="full",
|
1146
|
+
help="Configuration type to generate",
|
1147
|
+
)
|
1148
|
+
parser.add_argument("--output", default="./config.json", help="Output file path")
|
1149
|
+
parser.add_argument(
|
1150
|
+
"--all", action="store_true", help="Generate all configuration types"
|
1151
|
+
)
|
1152
|
+
parser.add_argument(
|
1153
|
+
"--output-dir", default="./configs", help="Output directory for all configs"
|
1154
|
+
)
|
1155
|
+
|
1001
1156
|
args = parser.parse_args()
|
1002
|
-
|
1157
|
+
|
1003
1158
|
generator = ConfigGenerator()
|
1004
|
-
|
1159
|
+
|
1005
1160
|
if args.all:
|
1006
1161
|
generator.generate_all_configs(args.output_dir)
|
1007
1162
|
else:
|