mcp-proxy-adapter 6.6.9__py3-none-any.whl → 6.7.1__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/api/app.py +60 -15
- mcp_proxy_adapter/commands/__init__.py +4 -0
- mcp_proxy_adapter/commands/registration_status_command.py +119 -0
- mcp_proxy_adapter/core/app_runner.py +29 -2
- mcp_proxy_adapter/core/async_proxy_registration.py +285 -0
- mcp_proxy_adapter/core/mtls_proxy.py +181 -0
- mcp_proxy_adapter/core/signal_handler.py +170 -0
- mcp_proxy_adapter/examples/config_builder.py +405 -61
- mcp_proxy_adapter/examples/generate_config.py +21 -16
- mcp_proxy_adapter/main.py +86 -5
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.6.9.dist-info → mcp_proxy_adapter-6.7.1.dist-info}/METADATA +1 -1
- {mcp_proxy_adapter-6.6.9.dist-info → mcp_proxy_adapter-6.7.1.dist-info}/RECORD +16 -12
- {mcp_proxy_adapter-6.6.9.dist-info → mcp_proxy_adapter-6.7.1.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.6.9.dist-info → mcp_proxy_adapter-6.7.1.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.6.9.dist-info → mcp_proxy_adapter-6.7.1.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
"""
|
3
|
-
|
3
|
+
Enhanced Configuration Builder for MCP Proxy Adapter
|
4
|
+
Supports all configuration options and versions.
|
4
5
|
|
5
6
|
Author: Vasiliy Zdanovskiy
|
6
7
|
email: vasilyvz@gmail.com
|
@@ -24,17 +25,21 @@ class AuthMethod(Enum):
|
|
24
25
|
NONE = "none"
|
25
26
|
TOKEN = "token"
|
26
27
|
TOKEN_ROLES = "token_roles"
|
28
|
+
CERTIFICATE = "certificate"
|
29
|
+
BASIC = "basic"
|
30
|
+
OAUTH2 = "oauth2"
|
31
|
+
JWT = "jwt"
|
27
32
|
|
28
33
|
|
29
34
|
class ConfigBuilder:
|
30
|
-
"""
|
35
|
+
"""Enhanced configuration builder with full feature support."""
|
31
36
|
|
32
37
|
def __init__(self):
|
33
38
|
"""Initialize the configuration builder."""
|
34
39
|
self._reset_to_defaults()
|
35
40
|
|
36
41
|
def _reset_to_defaults(self):
|
37
|
-
"""Reset configuration to default values."""
|
42
|
+
"""Reset configuration to default values with all sections."""
|
38
43
|
self.config = {
|
39
44
|
"uuid": str(uuid.uuid4()),
|
40
45
|
"server": {
|
@@ -49,53 +54,258 @@ class ConfigBuilder:
|
|
49
54
|
"file": None,
|
50
55
|
"log_dir": "./logs",
|
51
56
|
"log_file": "mcp_proxy_adapter.log",
|
52
|
-
"
|
57
|
+
"error_log_file": "mcp_proxy_adapter_error.log",
|
58
|
+
"access_log_file": "mcp_proxy_adapter_access.log",
|
59
|
+
"max_file_size": "10MB",
|
53
60
|
"backup_count": 5,
|
61
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
62
|
+
"date_format": "%Y-%m-%d %H:%M:%S",
|
54
63
|
"console_output": True,
|
64
|
+
"file_output": True,
|
55
65
|
"json_format": False
|
56
66
|
},
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
"
|
65
|
-
|
66
|
-
"user": ["read", "write"],
|
67
|
-
"readonly": ["read"]
|
68
|
-
},
|
69
|
-
"roles_file": None
|
67
|
+
"commands": {
|
68
|
+
"auto_discovery": True,
|
69
|
+
"commands_directory": "./commands",
|
70
|
+
"catalog_directory": "./catalog",
|
71
|
+
"plugin_servers": [],
|
72
|
+
"auto_install_dependencies": True,
|
73
|
+
"enabled_commands": ["health", "echo", "list", "help"],
|
74
|
+
"disabled_commands": [],
|
75
|
+
"custom_commands_path": "./commands"
|
70
76
|
},
|
71
|
-
"
|
77
|
+
"ssl": {
|
72
78
|
"enabled": False,
|
73
|
-
"
|
74
|
-
"
|
75
|
-
"
|
79
|
+
"mode": "https_only",
|
80
|
+
"cert_file": None,
|
81
|
+
"key_file": None,
|
82
|
+
"ca_cert": None,
|
83
|
+
"verify_client": False,
|
84
|
+
"client_cert_required": False,
|
85
|
+
"chk_hostname": False,
|
86
|
+
"cipher_suites": [
|
87
|
+
"TLS_AES_256_GCM_SHA384",
|
88
|
+
"TLS_CHACHA20_POLY1305_SHA256"
|
89
|
+
],
|
90
|
+
"min_tls_version": "TLSv1.2",
|
91
|
+
"max_tls_version": None,
|
92
|
+
"token_auth": {
|
93
|
+
"enabled": False,
|
94
|
+
"header_name": "Authorization",
|
95
|
+
"token_prefix": "Bearer",
|
96
|
+
"tokens_file": "tokens.json",
|
97
|
+
"token_expiry": 3600,
|
98
|
+
"jwt_secret": "",
|
99
|
+
"jwt_algorithm": "HS256"
|
100
|
+
}
|
76
101
|
},
|
77
102
|
"transport": {
|
78
103
|
"type": "http",
|
79
104
|
"port": None,
|
80
|
-
"
|
81
|
-
|
105
|
+
"ssl": {
|
106
|
+
"enabled": False,
|
107
|
+
"cert_file": None,
|
108
|
+
"key_file": None,
|
109
|
+
"ca_cert": None,
|
110
|
+
"verify_client": False,
|
111
|
+
"client_cert_required": False
|
112
|
+
}
|
82
113
|
},
|
83
|
-
"
|
114
|
+
"proxy_registration": {
|
84
115
|
"enabled": False,
|
85
116
|
"proxy_url": "http://localhost:3004",
|
86
|
-
"public_host": None, # Auto-determined from hostname or server.host
|
87
|
-
"public_port": None, # Auto-determined from server.port
|
88
|
-
"protocol": None, # Auto-determined from server.protocol
|
89
117
|
"server_id": "mcp_proxy_adapter",
|
90
118
|
"server_name": "MCP Proxy Adapter",
|
91
119
|
"description": "JSON-RPC API for interacting with MCP Proxy",
|
92
120
|
"version": "6.6.9",
|
121
|
+
"registration_timeout": 30,
|
122
|
+
"retry_attempts": 3,
|
123
|
+
"retry_delay": 5,
|
124
|
+
"auto_register_on_startup": True,
|
125
|
+
"auto_unregister_on_shutdown": True,
|
126
|
+
"auth_method": "none",
|
127
|
+
"server_url": None,
|
128
|
+
"fallback_proxy_url": None,
|
129
|
+
"public_host": None,
|
130
|
+
"public_port": None,
|
131
|
+
"protocol": None,
|
132
|
+
"certificate": {
|
133
|
+
"cert_file": None,
|
134
|
+
"key_file": None
|
135
|
+
},
|
136
|
+
"token": {
|
137
|
+
"token": None
|
138
|
+
},
|
139
|
+
"api_key": {
|
140
|
+
"key": None
|
141
|
+
},
|
142
|
+
"ssl": {
|
143
|
+
"ca_cert": None,
|
144
|
+
"verify_mode": "CERT_REQUIRED"
|
145
|
+
},
|
93
146
|
"heartbeat": {
|
94
147
|
"enabled": True,
|
95
148
|
"interval": 30,
|
96
149
|
"timeout": 10,
|
97
150
|
"retry_attempts": 3,
|
98
151
|
"retry_delay": 5
|
152
|
+
},
|
153
|
+
"proxy_info": {
|
154
|
+
"name": "mcp_proxy_adapter",
|
155
|
+
"description": "MCP Proxy Adapter",
|
156
|
+
"version": "6.6.9",
|
157
|
+
"capabilities": ["jsonrpc", "rest", "security"],
|
158
|
+
"endpoints": {
|
159
|
+
"jsonrpc": "/api/jsonrpc",
|
160
|
+
"rest": "/cmd",
|
161
|
+
"health": "/health"
|
162
|
+
}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
"debug": {
|
166
|
+
"enabled": False,
|
167
|
+
"level": "WARNING",
|
168
|
+
"log_level": "DEBUG",
|
169
|
+
"trace_requests": False,
|
170
|
+
"trace_responses": False
|
171
|
+
},
|
172
|
+
"security": {
|
173
|
+
"framework": "mcp_security_framework",
|
174
|
+
"enabled": False,
|
175
|
+
"debug": False,
|
176
|
+
"environment": "dev",
|
177
|
+
"version": "1.0.0",
|
178
|
+
"tokens": {
|
179
|
+
"admin": "admin-secret-key",
|
180
|
+
"user": "user-secret-key",
|
181
|
+
"readonly": "readonly-secret-key"
|
182
|
+
},
|
183
|
+
"roles": {
|
184
|
+
"admin": ["read", "write", "delete", "admin"],
|
185
|
+
"user": ["read", "write"],
|
186
|
+
"readonly": ["read"]
|
187
|
+
},
|
188
|
+
"roles_file": None,
|
189
|
+
"auth": {
|
190
|
+
"enabled": False,
|
191
|
+
"methods": ["api_key"],
|
192
|
+
"api_keys": {},
|
193
|
+
"user_roles": {},
|
194
|
+
"jwt_secret": "",
|
195
|
+
"jwt_algorithm": "HS256",
|
196
|
+
"jwt_expiry_hours": 24,
|
197
|
+
"certificate_auth": False,
|
198
|
+
"certificate_roles_oid": "1.3.6.1.4.1.99999.1.1",
|
199
|
+
"certificate_permissions_oid": "1.3.6.1.4.1.99999.1.2",
|
200
|
+
"basic_auth": False,
|
201
|
+
"oauth2_config": None,
|
202
|
+
"public_paths": ["/health", "/docs", "/openapi.json"],
|
203
|
+
"security_headers": None
|
204
|
+
},
|
205
|
+
"ssl": {
|
206
|
+
"enabled": False,
|
207
|
+
"cert_file": None,
|
208
|
+
"key_file": None,
|
209
|
+
"ca_cert_file": None,
|
210
|
+
"client_cert_file": None,
|
211
|
+
"client_key_file": None,
|
212
|
+
"verify_mode": "CERT_NONE",
|
213
|
+
"min_tls_version": "TLSv1.2",
|
214
|
+
"max_tls_version": None,
|
215
|
+
"cipher_suite": None,
|
216
|
+
"check_hostname": True,
|
217
|
+
"check_expiry": True,
|
218
|
+
"expiry_warning_days": 30
|
219
|
+
},
|
220
|
+
"certificates": {
|
221
|
+
"enabled": False,
|
222
|
+
"ca_cert_path": None,
|
223
|
+
"ca_key_path": None,
|
224
|
+
"cert_storage_path": "./certs",
|
225
|
+
"key_storage_path": "./keys",
|
226
|
+
"default_validity_days": 365,
|
227
|
+
"key_size": 2048,
|
228
|
+
"hash_algorithm": "sha256",
|
229
|
+
"crl_enabled": False,
|
230
|
+
"crl_path": None,
|
231
|
+
"crl_url": None,
|
232
|
+
"crl_validity_days": 30,
|
233
|
+
"auto_renewal": False,
|
234
|
+
"renewal_threshold_days": 30
|
235
|
+
},
|
236
|
+
"permissions": {
|
237
|
+
"enabled": False,
|
238
|
+
"roles_file": None,
|
239
|
+
"default_role": "guest",
|
240
|
+
"admin_role": "admin",
|
241
|
+
"role_hierarchy": {},
|
242
|
+
"permission_cache_enabled": False,
|
243
|
+
"permission_cache_ttl": 300,
|
244
|
+
"wildcard_permissions": False,
|
245
|
+
"strict_mode": False,
|
246
|
+
"roles": None
|
247
|
+
},
|
248
|
+
"rate_limit": {
|
249
|
+
"enabled": False,
|
250
|
+
"default_requests_per_minute": 60,
|
251
|
+
"default_requests_per_hour": 1000,
|
252
|
+
"burst_limit": 2,
|
253
|
+
"window_size_seconds": 60,
|
254
|
+
"storage_backend": "memory",
|
255
|
+
"redis_config": None,
|
256
|
+
"cleanup_interval": 300,
|
257
|
+
"exempt_paths": ["/health", "/docs", "/openapi.json"],
|
258
|
+
"exempt_roles": ["admin"]
|
259
|
+
},
|
260
|
+
"logging": {
|
261
|
+
"enabled": True,
|
262
|
+
"level": "INFO",
|
263
|
+
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
264
|
+
"date_format": "%Y-%m-%d %H:%M:%S",
|
265
|
+
"file_path": None,
|
266
|
+
"max_file_size": 10,
|
267
|
+
"backup_count": 5,
|
268
|
+
"console_output": True,
|
269
|
+
"json_format": False,
|
270
|
+
"include_timestamp": True,
|
271
|
+
"include_level": True,
|
272
|
+
"include_module": True
|
273
|
+
}
|
274
|
+
},
|
275
|
+
"roles": {
|
276
|
+
"enabled": False,
|
277
|
+
"config_file": None,
|
278
|
+
"default_policy": {
|
279
|
+
"deny_by_default": False,
|
280
|
+
"require_role_match": False,
|
281
|
+
"case_sensitive": False,
|
282
|
+
"allow_wildcard": False
|
283
|
+
},
|
284
|
+
"auto_load": False,
|
285
|
+
"validation_enabled": False
|
286
|
+
},
|
287
|
+
"protocols": {
|
288
|
+
"enabled": True,
|
289
|
+
"allowed_protocols": ["http", "jsonrpc"],
|
290
|
+
"default_protocol": "http",
|
291
|
+
"auto_discovery": True,
|
292
|
+
"protocol_handlers": {
|
293
|
+
"http": {
|
294
|
+
"enabled": True,
|
295
|
+
"port": None,
|
296
|
+
"ssl": False
|
297
|
+
},
|
298
|
+
"https": {
|
299
|
+
"enabled": False,
|
300
|
+
"port": None,
|
301
|
+
"ssl": True
|
302
|
+
},
|
303
|
+
"mtls": {
|
304
|
+
"enabled": False,
|
305
|
+
"port": None,
|
306
|
+
"ssl": True,
|
307
|
+
"client_cert_required": True
|
308
|
+
}
|
99
309
|
}
|
100
310
|
}
|
101
311
|
}
|
@@ -105,22 +315,47 @@ class ConfigBuilder:
|
|
105
315
|
self.config["server"]["protocol"] = protocol.value
|
106
316
|
|
107
317
|
# Set registration protocol to match server protocol
|
108
|
-
self.config["
|
318
|
+
self.config["proxy_registration"]["protocol"] = protocol.value
|
319
|
+
|
320
|
+
# Update protocol handlers
|
321
|
+
for handler_name in self.config["protocols"]["protocol_handlers"]:
|
322
|
+
self.config["protocols"]["protocol_handlers"][handler_name]["enabled"] = False
|
109
323
|
|
110
324
|
if protocol == Protocol.HTTP:
|
111
325
|
# HTTP - no SSL, no client verification
|
112
|
-
self.config["transport"]["verify_client"] = False
|
113
|
-
self.config["transport"]["
|
326
|
+
self.config["transport"]["ssl"]["verify_client"] = False
|
327
|
+
self.config["transport"]["ssl"]["enabled"] = False
|
328
|
+
self.config["ssl"]["enabled"] = False
|
329
|
+
self.config["ssl"]["verify_client"] = False
|
330
|
+
self.config["ssl"]["chk_hostname"] = False
|
331
|
+
self.config["protocols"]["protocol_handlers"]["http"]["enabled"] = True
|
332
|
+
self.config["protocols"]["allowed_protocols"] = ["http"]
|
333
|
+
self.config["protocols"]["default_protocol"] = "http"
|
114
334
|
|
115
335
|
elif protocol == Protocol.HTTPS:
|
116
336
|
# HTTPS - SSL enabled, no client verification
|
117
|
-
self.config["transport"]["verify_client"] = False
|
118
|
-
self.config["transport"]["
|
337
|
+
self.config["transport"]["ssl"]["verify_client"] = False
|
338
|
+
self.config["transport"]["ssl"]["enabled"] = True
|
339
|
+
self.config["ssl"]["enabled"] = True
|
340
|
+
self.config["ssl"]["verify_client"] = False
|
341
|
+
self.config["ssl"]["chk_hostname"] = True
|
342
|
+
self.config["ssl"]["mode"] = "https_only"
|
343
|
+
self.config["protocols"]["protocol_handlers"]["https"]["enabled"] = True
|
344
|
+
self.config["protocols"]["allowed_protocols"] = ["https"]
|
345
|
+
self.config["protocols"]["default_protocol"] = "https"
|
119
346
|
|
120
347
|
elif protocol == Protocol.MTLS:
|
121
348
|
# mTLS - SSL enabled, client verification required
|
122
|
-
self.config["transport"]["verify_client"] = True
|
123
|
-
self.config["transport"]["
|
349
|
+
self.config["transport"]["ssl"]["verify_client"] = True
|
350
|
+
self.config["transport"]["ssl"]["enabled"] = True
|
351
|
+
self.config["ssl"]["enabled"] = True
|
352
|
+
self.config["ssl"]["verify_client"] = True
|
353
|
+
self.config["ssl"]["chk_hostname"] = True
|
354
|
+
self.config["ssl"]["mode"] = "mtls"
|
355
|
+
self.config["ssl"]["client_cert_required"] = True
|
356
|
+
self.config["protocols"]["protocol_handlers"]["mtls"]["enabled"] = True
|
357
|
+
self.config["protocols"]["allowed_protocols"] = ["mtls"]
|
358
|
+
self.config["protocols"]["default_protocol"] = "mtls"
|
124
359
|
|
125
360
|
return self
|
126
361
|
|
@@ -128,12 +363,16 @@ class ConfigBuilder:
|
|
128
363
|
"""Set authentication configuration."""
|
129
364
|
if auth_method == AuthMethod.NONE:
|
130
365
|
self.config["security"]["enabled"] = False
|
366
|
+
self.config["security"]["auth"]["enabled"] = False
|
367
|
+
self.config["security"]["auth"]["methods"] = []
|
131
368
|
self.config["security"]["tokens"] = {}
|
132
369
|
self.config["security"]["roles"] = {}
|
133
370
|
self.config["security"]["roles_file"] = None
|
134
371
|
|
135
372
|
elif auth_method == AuthMethod.TOKEN:
|
136
373
|
self.config["security"]["enabled"] = True
|
374
|
+
self.config["security"]["auth"]["enabled"] = True
|
375
|
+
self.config["security"]["auth"]["methods"] = ["api_key"]
|
137
376
|
self.config["security"]["tokens"] = api_keys or {
|
138
377
|
"admin": "admin-secret-key",
|
139
378
|
"user": "user-secret-key"
|
@@ -146,6 +385,8 @@ class ConfigBuilder:
|
|
146
385
|
|
147
386
|
elif auth_method == AuthMethod.TOKEN_ROLES:
|
148
387
|
self.config["security"]["enabled"] = True
|
388
|
+
self.config["security"]["auth"]["enabled"] = True
|
389
|
+
self.config["security"]["auth"]["methods"] = ["api_key"]
|
149
390
|
self.config["security"]["tokens"] = api_keys or {
|
150
391
|
"admin": "admin-secret-key",
|
151
392
|
"user": "user-secret-key",
|
@@ -157,43 +398,100 @@ class ConfigBuilder:
|
|
157
398
|
"readonly": ["read"]
|
158
399
|
}
|
159
400
|
self.config["security"]["roles_file"] = "configs/roles.json"
|
401
|
+
self.config["roles"]["enabled"] = True
|
402
|
+
self.config["roles"]["config_file"] = "configs/roles.json"
|
403
|
+
|
404
|
+
elif auth_method == AuthMethod.CERTIFICATE:
|
405
|
+
self.config["security"]["enabled"] = True
|
406
|
+
self.config["security"]["auth"]["enabled"] = True
|
407
|
+
self.config["security"]["auth"]["methods"] = ["certificate"]
|
408
|
+
self.config["security"]["auth"]["certificate_auth"] = True
|
409
|
+
self.config["security"]["ssl"]["enabled"] = True
|
410
|
+
self.config["security"]["ssl"]["verify_mode"] = "CERT_REQUIRED"
|
411
|
+
|
412
|
+
elif auth_method == AuthMethod.BASIC:
|
413
|
+
self.config["security"]["enabled"] = True
|
414
|
+
self.config["security"]["auth"]["enabled"] = True
|
415
|
+
self.config["security"]["auth"]["methods"] = ["basic"]
|
416
|
+
self.config["security"]["auth"]["basic_auth"] = True
|
417
|
+
|
418
|
+
elif auth_method == AuthMethod.OAUTH2:
|
419
|
+
self.config["security"]["enabled"] = True
|
420
|
+
self.config["security"]["auth"]["enabled"] = True
|
421
|
+
self.config["security"]["auth"]["methods"] = ["oauth2"]
|
422
|
+
self.config["security"]["auth"]["oauth2_config"] = {}
|
423
|
+
|
424
|
+
elif auth_method == AuthMethod.JWT:
|
425
|
+
self.config["security"]["enabled"] = True
|
426
|
+
self.config["security"]["auth"]["enabled"] = True
|
427
|
+
self.config["security"]["auth"]["methods"] = ["jwt"]
|
428
|
+
self.config["security"]["auth"]["jwt_secret"] = "your-jwt-secret"
|
429
|
+
self.config["security"]["auth"]["jwt_algorithm"] = "HS256"
|
160
430
|
|
161
431
|
return self
|
162
432
|
|
163
|
-
def set_server(self, host: str = "0.0.0.0", port: int = 8000):
|
433
|
+
def set_server(self, host: str = "0.0.0.0", port: int = 8000, debug: bool = False, log_level: str = "INFO"):
|
164
434
|
"""Set server configuration."""
|
165
435
|
self.config["server"]["host"] = host
|
166
436
|
self.config["server"]["port"] = port
|
437
|
+
self.config["server"]["debug"] = debug
|
438
|
+
self.config["server"]["log_level"] = log_level
|
439
|
+
return self
|
440
|
+
|
441
|
+
def set_logging(self, log_dir: str = "./logs", level: str = "INFO", console_output: bool = True, file_output: bool = True):
|
442
|
+
"""Set logging configuration."""
|
443
|
+
self.config["logging"]["log_dir"] = log_dir
|
444
|
+
self.config["logging"]["level"] = level
|
445
|
+
self.config["logging"]["console_output"] = console_output
|
446
|
+
self.config["logging"]["file_output"] = file_output
|
447
|
+
return self
|
448
|
+
|
449
|
+
def set_commands(self, enabled_commands: Optional[List[str]] = None, disabled_commands: Optional[List[str]] = None):
|
450
|
+
"""Set commands configuration."""
|
451
|
+
if enabled_commands:
|
452
|
+
self.config["commands"]["enabled_commands"] = enabled_commands
|
453
|
+
if disabled_commands:
|
454
|
+
self.config["commands"]["disabled_commands"] = disabled_commands
|
167
455
|
return self
|
168
456
|
|
169
457
|
def set_roles_file(self, roles_file: str):
|
170
458
|
"""Set roles file path."""
|
171
459
|
self.config["security"]["roles_file"] = roles_file
|
460
|
+
self.config["roles"]["config_file"] = roles_file
|
461
|
+
self.config["roles"]["enabled"] = True
|
172
462
|
return self
|
173
463
|
|
174
464
|
def set_proxy_registration(self, enabled: bool = True, proxy_url: str = "http://localhost:3004",
|
175
465
|
public_host: Optional[str] = None, public_port: Optional[int] = None,
|
176
466
|
server_id: str = "mcp_proxy_adapter", server_name: str = "MCP Proxy Adapter",
|
177
|
-
description: str = "JSON-RPC API for interacting with MCP Proxy"
|
467
|
+
description: str = "JSON-RPC API for interacting with MCP Proxy",
|
468
|
+
auth_method: str = "none", cert_file: Optional[str] = None, key_file: Optional[str] = None):
|
178
469
|
"""Set proxy registration configuration."""
|
179
|
-
self.config["
|
180
|
-
self.config["
|
181
|
-
self.config["
|
182
|
-
self.config["
|
183
|
-
self.config["
|
184
|
-
self.config["
|
185
|
-
self.config["
|
470
|
+
self.config["proxy_registration"]["enabled"] = enabled
|
471
|
+
self.config["proxy_registration"]["proxy_url"] = proxy_url
|
472
|
+
self.config["proxy_registration"]["public_host"] = public_host
|
473
|
+
self.config["proxy_registration"]["public_port"] = public_port
|
474
|
+
self.config["proxy_registration"]["server_id"] = server_id
|
475
|
+
self.config["proxy_registration"]["server_name"] = server_name
|
476
|
+
self.config["proxy_registration"]["description"] = description
|
477
|
+
self.config["proxy_registration"]["auth_method"] = auth_method
|
478
|
+
|
479
|
+
if cert_file:
|
480
|
+
self.config["proxy_registration"]["certificate"]["cert_file"] = cert_file
|
481
|
+
if key_file:
|
482
|
+
self.config["proxy_registration"]["certificate"]["key_file"] = key_file
|
186
483
|
|
187
484
|
# Set protocol to match server protocol if not explicitly set
|
188
|
-
if self.config["
|
189
|
-
self.config["
|
485
|
+
if self.config["proxy_registration"]["protocol"] is None:
|
486
|
+
self.config["proxy_registration"]["protocol"] = self.config["server"]["protocol"]
|
190
487
|
|
191
488
|
return self
|
192
489
|
|
193
490
|
def enable_auto_registration(self, proxy_url: str = "http://localhost:3004",
|
194
491
|
server_id: str = "mcp_proxy_adapter",
|
195
492
|
server_name: str = "MCP Proxy Adapter",
|
196
|
-
description: str = "JSON-RPC API for interacting with MCP Proxy"
|
493
|
+
description: str = "JSON-RPC API for interacting with MCP Proxy",
|
494
|
+
auth_method: str = "none"):
|
197
495
|
"""
|
198
496
|
Enable automatic proxy registration with auto-determined parameters.
|
199
497
|
|
@@ -207,18 +505,34 @@ class ConfigBuilder:
|
|
207
505
|
server_id: Unique identifier for this server
|
208
506
|
server_name: Human-readable name for this server
|
209
507
|
description: Description of this server
|
508
|
+
auth_method: Authentication method for proxy registration
|
210
509
|
"""
|
211
|
-
self.config["
|
212
|
-
self.config["
|
213
|
-
self.config["
|
214
|
-
self.config["
|
215
|
-
self.config["
|
216
|
-
self.config["
|
217
|
-
self.config["
|
218
|
-
self.config["
|
510
|
+
self.config["proxy_registration"]["enabled"] = True
|
511
|
+
self.config["proxy_registration"]["proxy_url"] = proxy_url
|
512
|
+
self.config["proxy_registration"]["public_host"] = None # Auto-determined
|
513
|
+
self.config["proxy_registration"]["public_port"] = None # Auto-determined
|
514
|
+
self.config["proxy_registration"]["protocol"] = None # Auto-determined
|
515
|
+
self.config["proxy_registration"]["server_id"] = server_id
|
516
|
+
self.config["proxy_registration"]["server_name"] = server_name
|
517
|
+
self.config["proxy_registration"]["description"] = description
|
518
|
+
self.config["proxy_registration"]["auth_method"] = auth_method
|
219
519
|
|
220
520
|
return self
|
221
521
|
|
522
|
+
def set_ssl_certificates(self, cert_file: str, key_file: str, ca_cert: Optional[str] = None):
|
523
|
+
"""Set SSL certificate paths."""
|
524
|
+
self.config["ssl"]["cert_file"] = cert_file
|
525
|
+
self.config["ssl"]["key_file"] = key_file
|
526
|
+
if ca_cert:
|
527
|
+
self.config["ssl"]["ca_cert"] = ca_cert
|
528
|
+
return self
|
529
|
+
|
530
|
+
def set_debug(self, enabled: bool = True, log_level: str = "DEBUG"):
|
531
|
+
"""Set debug configuration."""
|
532
|
+
self.config["debug"]["enabled"] = enabled
|
533
|
+
self.config["debug"]["log_level"] = log_level
|
534
|
+
return self
|
535
|
+
|
222
536
|
def build(self) -> Dict[str, Any]:
|
223
537
|
"""Build and return the configuration."""
|
224
538
|
return self.config.copy()
|
@@ -311,7 +625,16 @@ class ConfigFactory:
|
|
311
625
|
.build())
|
312
626
|
|
313
627
|
@staticmethod
|
314
|
-
def
|
628
|
+
def create_mtls_certificate_config(port: int = 8009) -> Dict[str, Any]:
|
629
|
+
"""Create mTLS with certificate authentication configuration."""
|
630
|
+
return (ConfigBuilder()
|
631
|
+
.set_protocol(Protocol.MTLS)
|
632
|
+
.set_auth(AuthMethod.CERTIFICATE)
|
633
|
+
.set_server(port=port)
|
634
|
+
.build())
|
635
|
+
|
636
|
+
@staticmethod
|
637
|
+
def create_http_with_proxy_config(port: int = 8010, proxy_url: str = "http://localhost:3004") -> Dict[str, Any]:
|
315
638
|
"""Create HTTP configuration with proxy registration."""
|
316
639
|
return (ConfigBuilder()
|
317
640
|
.set_protocol(Protocol.HTTP)
|
@@ -320,7 +643,7 @@ class ConfigFactory:
|
|
320
643
|
.build())
|
321
644
|
|
322
645
|
@staticmethod
|
323
|
-
def create_https_with_proxy_config(port: int =
|
646
|
+
def create_https_with_proxy_config(port: int = 8011, proxy_url: str = "https://localhost:3004") -> Dict[str, Any]:
|
324
647
|
"""Create HTTPS configuration with proxy registration."""
|
325
648
|
return (ConfigBuilder()
|
326
649
|
.set_protocol(Protocol.HTTPS)
|
@@ -329,7 +652,7 @@ class ConfigFactory:
|
|
329
652
|
.build())
|
330
653
|
|
331
654
|
@staticmethod
|
332
|
-
def create_mtls_with_proxy_config(port: int =
|
655
|
+
def create_mtls_with_proxy_config(port: int = 8012, proxy_url: str = "https://localhost:3004") -> Dict[str, Any]:
|
333
656
|
"""Create mTLS configuration with proxy registration."""
|
334
657
|
return (ConfigBuilder()
|
335
658
|
.set_protocol(Protocol.MTLS)
|
@@ -338,7 +661,7 @@ class ConfigFactory:
|
|
338
661
|
.build())
|
339
662
|
|
340
663
|
@staticmethod
|
341
|
-
def create_http_with_auto_registration(port: int =
|
664
|
+
def create_http_with_auto_registration(port: int = 8013, proxy_url: str = "http://localhost:3004",
|
342
665
|
server_id: str = "mcp_proxy_adapter") -> Dict[str, Any]:
|
343
666
|
"""Create HTTP configuration with automatic proxy registration."""
|
344
667
|
return (ConfigBuilder()
|
@@ -348,7 +671,7 @@ class ConfigFactory:
|
|
348
671
|
.build())
|
349
672
|
|
350
673
|
@staticmethod
|
351
|
-
def create_https_with_auto_registration(port: int =
|
674
|
+
def create_https_with_auto_registration(port: int = 8014, proxy_url: str = "https://localhost:3004",
|
352
675
|
server_id: str = "mcp_proxy_adapter") -> Dict[str, Any]:
|
353
676
|
"""Create HTTPS configuration with automatic proxy registration."""
|
354
677
|
return (ConfigBuilder()
|
@@ -358,7 +681,7 @@ class ConfigFactory:
|
|
358
681
|
.build())
|
359
682
|
|
360
683
|
@staticmethod
|
361
|
-
def create_mtls_with_auto_registration(port: int =
|
684
|
+
def create_mtls_with_auto_registration(port: int = 8015, proxy_url: str = "https://localhost:3004",
|
362
685
|
server_id: str = "mcp_proxy_adapter") -> Dict[str, Any]:
|
363
686
|
"""Create mTLS configuration with automatic proxy registration."""
|
364
687
|
return (ConfigBuilder()
|
@@ -366,6 +689,27 @@ class ConfigFactory:
|
|
366
689
|
.set_server(port=port)
|
367
690
|
.enable_auto_registration(proxy_url=proxy_url, server_id=server_id)
|
368
691
|
.build())
|
692
|
+
|
693
|
+
@staticmethod
|
694
|
+
def create_full_featured_config(port: int = 8020) -> Dict[str, Any]:
|
695
|
+
"""Create full-featured configuration with all options enabled."""
|
696
|
+
return (ConfigBuilder()
|
697
|
+
.set_protocol(Protocol.MTLS)
|
698
|
+
.set_auth(AuthMethod.TOKEN_ROLES)
|
699
|
+
.set_server(port=port)
|
700
|
+
.enable_auto_registration(
|
701
|
+
proxy_url="https://mcp-proxy:3004",
|
702
|
+
server_id="full-featured-server",
|
703
|
+
server_name="Full Featured Server",
|
704
|
+
description="Server with all features enabled"
|
705
|
+
)
|
706
|
+
.set_ssl_certificates(
|
707
|
+
cert_file="./certs/server.crt",
|
708
|
+
key_file="./keys/server.key",
|
709
|
+
ca_cert="./certs/ca.crt"
|
710
|
+
)
|
711
|
+
.set_debug(enabled=True)
|
712
|
+
.build())
|
369
713
|
|
370
714
|
|
371
715
|
def create_config_from_flags(protocol: str, token: bool = False, roles: bool = False, port: int = 8000,
|
@@ -419,4 +763,4 @@ def create_config_from_flags(protocol: str, token: bool = False, roles: bool = F
|
|
419
763
|
if __name__ == "__main__":
|
420
764
|
# Example usage
|
421
765
|
config = create_config_from_flags("http", token=True, port=8001)
|
422
|
-
print(json.dumps(config, indent=2))
|
766
|
+
print(json.dumps(config, indent=2))
|