mcp-proxy-adapter 6.1.0__py3-none-any.whl → 6.2.0__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/__main__.py +27 -7
- mcp_proxy_adapter/api/app.py +18 -7
- mcp_proxy_adapter/api/middleware/__init__.py +2 -2
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +32 -13
- mcp_proxy_adapter/api/middleware/unified_security.py +12 -4
- mcp_proxy_adapter/commands/ssl_setup_command.py +234 -351
- mcp_proxy_adapter/core/app_factory.py +87 -3
- mcp_proxy_adapter/core/app_runner.py +272 -0
- mcp_proxy_adapter/core/certificate_utils.py +291 -73
- mcp_proxy_adapter/core/client.py +574 -0
- mcp_proxy_adapter/core/client_manager.py +284 -0
- mcp_proxy_adapter/core/protocol_manager.py +132 -10
- mcp_proxy_adapter/core/security_integration.py +19 -11
- mcp_proxy_adapter/core/server_adapter.py +17 -80
- mcp_proxy_adapter/core/server_engine.py +5 -99
- mcp_proxy_adapter/core/ssl_utils.py +13 -12
- mcp_proxy_adapter/core/transport_manager.py +5 -5
- mcp_proxy_adapter/examples/__init__.py +16 -0
- mcp_proxy_adapter/examples/basic_framework/__init__.py +7 -0
- mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +21 -40
- mcp_proxy_adapter/examples/commands/__init__.py +5 -1
- mcp_proxy_adapter/examples/create_certificates_simple.py +260 -75
- mcp_proxy_adapter/examples/debug_request_state.py +4 -36
- mcp_proxy_adapter/examples/debug_role_chain.py +2 -49
- mcp_proxy_adapter/examples/demo_client.py +0 -66
- mcp_proxy_adapter/examples/full_application/__init__.py +11 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +0 -19
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +0 -16
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +0 -22
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +0 -24
- mcp_proxy_adapter/examples/full_application/main.py +65 -44
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +154 -0
- mcp_proxy_adapter/examples/generate_all_certificates.py +0 -67
- mcp_proxy_adapter/examples/generate_certificates.py +0 -15
- mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +369 -0
- mcp_proxy_adapter/examples/generate_test_configs.py +204 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +3 -70
- mcp_proxy_adapter/examples/run_example.py +1 -23
- mcp_proxy_adapter/examples/run_security_tests.py +2 -60
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +0 -53
- mcp_proxy_adapter/examples/security_test_client.py +18 -123
- mcp_proxy_adapter/examples/setup_test_environment.py +179 -0
- mcp_proxy_adapter/examples/test_config.py +148 -0
- mcp_proxy_adapter/examples/test_config_generator.py +86 -0
- mcp_proxy_adapter/examples/test_examples.py +4 -67
- mcp_proxy_adapter/examples/universal_client.py +154 -162
- mcp_proxy_adapter/main.py +51 -161
- mcp_proxy_adapter/utils/config_generator.py +90 -2
- mcp_proxy_adapter/version.py +4 -2
- mcp_proxy_adapter-6.2.0.dist-info/METADATA +687 -0
- mcp_proxy_adapter-6.2.0.dist-info/RECORD +122 -0
- mcp_proxy_adapter/examples/README.md +0 -257
- mcp_proxy_adapter/examples/README_EN.md +0 -258
- mcp_proxy_adapter/examples/SECURITY_TESTING.md +0 -455
- mcp_proxy_adapter/examples/__pycache__/security_configurations.cpython-312.pyc +0 -0
- mcp_proxy_adapter/examples/__pycache__/security_test_client.cpython-312.pyc +0 -0
- mcp_proxy_adapter/examples/basic_framework/configs/http_auth.json +0 -37
- mcp_proxy_adapter/examples/basic_framework/configs/http_simple.json +0 -23
- mcp_proxy_adapter/examples/basic_framework/configs/https_auth.json +0 -39
- mcp_proxy_adapter/examples/basic_framework/configs/https_simple.json +0 -25
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_roles.json +0 -39
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_with_roles.json +0 -45
- mcp_proxy_adapter/examples/basic_framework/roles.json +0 -21
- mcp_proxy_adapter/examples/cert_config.json +0 -9
- mcp_proxy_adapter/examples/certs/admin.crt +0 -32
- mcp_proxy_adapter/examples/certs/admin.key +0 -52
- mcp_proxy_adapter/examples/certs/admin_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/admin_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/ca_cert.pem +0 -23
- mcp_proxy_adapter/examples/certs/ca_cert.srl +0 -1
- mcp_proxy_adapter/examples/certs/ca_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/cert_config.json +0 -9
- mcp_proxy_adapter/examples/certs/client.crt +0 -32
- mcp_proxy_adapter/examples/certs/client.key +0 -52
- mcp_proxy_adapter/examples/certs/client_admin.crt +0 -32
- mcp_proxy_adapter/examples/certs/client_admin.key +0 -52
- mcp_proxy_adapter/examples/certs/client_user.crt +0 -32
- mcp_proxy_adapter/examples/certs/client_user.key +0 -52
- mcp_proxy_adapter/examples/certs/guest_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/guest_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/mcp_proxy_adapter_ca_ca.crt +0 -23
- mcp_proxy_adapter/examples/certs/proxy_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/proxy_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/readonly.crt +0 -32
- mcp_proxy_adapter/examples/certs/readonly.key +0 -52
- mcp_proxy_adapter/examples/certs/readonly_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/readonly_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/server.crt +0 -32
- mcp_proxy_adapter/examples/certs/server.key +0 -52
- mcp_proxy_adapter/examples/certs/server_cert.pem +0 -32
- mcp_proxy_adapter/examples/certs/server_key.pem +0 -52
- mcp_proxy_adapter/examples/certs/test_ca_ca.crt +0 -20
- mcp_proxy_adapter/examples/certs/user.crt +0 -32
- mcp_proxy_adapter/examples/certs/user.key +0 -52
- mcp_proxy_adapter/examples/certs/user_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/user_key.pem +0 -28
- mcp_proxy_adapter/examples/client_configs/api_key_client.json +0 -13
- mcp_proxy_adapter/examples/client_configs/basic_auth_client.json +0 -13
- mcp_proxy_adapter/examples/client_configs/certificate_client.json +0 -22
- mcp_proxy_adapter/examples/client_configs/jwt_client.json +0 -15
- mcp_proxy_adapter/examples/client_configs/no_auth_client.json +0 -9
- mcp_proxy_adapter/examples/full_application/configs/http_auth.json +0 -37
- mcp_proxy_adapter/examples/full_application/configs/http_simple.json +0 -23
- mcp_proxy_adapter/examples/full_application/configs/https_auth.json +0 -39
- mcp_proxy_adapter/examples/full_application/configs/https_simple.json +0 -25
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles.json +0 -39
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles.json +0 -45
- mcp_proxy_adapter/examples/full_application/roles.json +0 -21
- mcp_proxy_adapter/examples/keys/ca_key.pem +0 -28
- mcp_proxy_adapter/examples/keys/mcp_proxy_adapter_ca_ca.key +0 -28
- mcp_proxy_adapter/examples/keys/test_ca_ca.key +0 -28
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log +0 -220
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.5 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log +0 -220
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.5 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log +0 -2
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.5 +0 -1
- mcp_proxy_adapter/examples/roles.json +0 -38
- mcp_proxy_adapter/examples/server_configs/config_basic_http.json +0 -204
- mcp_proxy_adapter/examples/server_configs/config_http_token.json +0 -238
- mcp_proxy_adapter/examples/server_configs/config_https.json +0 -215
- mcp_proxy_adapter/examples/server_configs/config_https_token.json +0 -231
- mcp_proxy_adapter/examples/server_configs/config_mtls.json +0 -215
- mcp_proxy_adapter/examples/server_configs/config_proxy_registration.json +0 -250
- mcp_proxy_adapter/examples/server_configs/config_simple.json +0 -46
- mcp_proxy_adapter/examples/server_configs/roles.json +0 -38
- mcp_proxy_adapter-6.1.0.dist-info/METADATA +0 -205
- mcp_proxy_adapter-6.1.0.dist-info/RECORD +0 -193
- {mcp_proxy_adapter-6.1.0.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.1.0.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.1.0.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.1.0.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/top_level.txt +0 -0
mcp_proxy_adapter/main.py
CHANGED
@@ -1,185 +1,75 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
"""
|
3
|
-
|
3
|
+
MCP Proxy Adapter - Main Entry Point
|
4
4
|
|
5
|
-
|
5
|
+
Author: Vasiliy Zdanovskiy
|
6
|
+
email: vasilyvz@gmail.com
|
6
7
|
"""
|
7
8
|
|
8
|
-
import argparse
|
9
|
-
import asyncio
|
10
|
-
import uvicorn
|
11
9
|
import sys
|
12
|
-
import
|
10
|
+
import hypercorn.asyncio
|
11
|
+
import hypercorn.config
|
12
|
+
import asyncio
|
13
13
|
from pathlib import Path
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
from mcp_proxy_adapter.core.settings import (
|
18
|
-
Settings,
|
19
|
-
get_server_host,
|
20
|
-
get_server_port,
|
21
|
-
get_server_debug,
|
22
|
-
get_setting
|
23
|
-
)
|
24
|
-
from mcp_proxy_adapter.core.ssl_utils import SSLUtils
|
15
|
+
# Add the project root to the path
|
16
|
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
25
17
|
|
26
|
-
|
27
|
-
|
28
|
-
"""Parse command line arguments."""
|
29
|
-
parser = argparse.ArgumentParser(description="MCP Proxy Adapter Server")
|
30
|
-
parser.add_argument(
|
31
|
-
"--config",
|
32
|
-
type=str,
|
33
|
-
default=None,
|
34
|
-
help="Path to configuration file"
|
35
|
-
)
|
36
|
-
parser.add_argument(
|
37
|
-
"--host",
|
38
|
-
type=str,
|
39
|
-
default=None,
|
40
|
-
help="Host to bind to (overrides config)"
|
41
|
-
)
|
42
|
-
parser.add_argument(
|
43
|
-
"--port",
|
44
|
-
type=int,
|
45
|
-
default=None,
|
46
|
-
help="Port to bind to (overrides config)"
|
47
|
-
)
|
48
|
-
parser.add_argument(
|
49
|
-
"--debug",
|
50
|
-
action="store_true",
|
51
|
-
help="Enable debug mode (overrides config)"
|
52
|
-
)
|
53
|
-
parser.add_argument(
|
54
|
-
"--log-level",
|
55
|
-
type=str,
|
56
|
-
default=None,
|
57
|
-
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
58
|
-
help="Log level (overrides config)"
|
59
|
-
)
|
60
|
-
return parser.parse_args()
|
18
|
+
from mcp_proxy_adapter.api.app import create_app
|
19
|
+
from mcp_proxy_adapter.config import Config
|
61
20
|
|
62
21
|
|
63
22
|
def main():
|
64
|
-
"""
|
65
|
-
|
66
|
-
|
67
|
-
# Load configuration if specified
|
68
|
-
if args.config:
|
69
|
-
config_path = Path(args.config)
|
70
|
-
if config_path.exists():
|
71
|
-
from mcp_proxy_adapter.config import config
|
72
|
-
config.load_from_file(str(config_path))
|
73
|
-
print(f"✅ Loaded configuration from: {config_path}")
|
74
|
-
else:
|
75
|
-
print(f"❌ Configuration file not found: {config_path}")
|
76
|
-
sys.exit(1)
|
77
|
-
else:
|
78
|
-
print("⚠️ No configuration file specified, using defaults")
|
79
|
-
|
80
|
-
# Setup logging with configuration
|
81
|
-
setup_logging()
|
82
|
-
logger = get_logger("mcp_proxy_adapter")
|
83
|
-
|
84
|
-
# Get settings from configuration
|
85
|
-
server_settings = Settings.get_server_settings()
|
86
|
-
logging_settings = Settings.get_logging_settings()
|
87
|
-
commands_settings = Settings.get_commands_settings()
|
88
|
-
ssl_settings = Settings.get_custom_setting("ssl", {})
|
89
|
-
security_settings = Settings.get_custom_setting("security", {})
|
23
|
+
"""Main entry point for the MCP Proxy Adapter."""
|
24
|
+
# Load configuration
|
25
|
+
config = Config()
|
90
26
|
|
91
|
-
#
|
92
|
-
|
27
|
+
# Create application
|
28
|
+
app = create_app(app_config=config)
|
93
29
|
|
94
|
-
# Get
|
95
|
-
|
96
|
-
|
97
|
-
"logging": logging_settings,
|
98
|
-
"commands": commands_settings,
|
99
|
-
"ssl": ssl_settings,
|
100
|
-
"security": security_settings,
|
101
|
-
"auth_enabled": Settings.get_custom_setting("auth_enabled", False),
|
102
|
-
"roles": Settings.get_custom_setting("roles", {})
|
103
|
-
}
|
30
|
+
# Get server configuration
|
31
|
+
host = config.get("server.host", "0.0.0.0")
|
32
|
+
port = config.get("server.port", 8000)
|
104
33
|
|
105
|
-
#
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
logger.critical("Please fix configuration errors or disable security features.")
|
112
|
-
sys.exit(1)
|
34
|
+
# Get SSL configuration
|
35
|
+
ssl_enabled = config.get("ssl.enabled", False)
|
36
|
+
ssl_cert_file = config.get("ssl.cert_file")
|
37
|
+
ssl_key_file = config.get("ssl.key_file")
|
38
|
+
ssl_ca_cert = config.get("ssl.ca_cert")
|
39
|
+
verify_client = config.get("ssl.verify_client", False)
|
113
40
|
|
114
|
-
|
41
|
+
print(f"🚀 Starting MCP Proxy Adapter")
|
42
|
+
print(f"🌐 Server: {host}:{port}")
|
43
|
+
if ssl_enabled:
|
44
|
+
print(f"🔐 SSL: Enabled")
|
45
|
+
print(f" Certificate: {ssl_cert_file}")
|
46
|
+
print(f" Key: {ssl_key_file}")
|
47
|
+
if ssl_ca_cert:
|
48
|
+
print(f" CA: {ssl_ca_cert}")
|
49
|
+
print(f" Client verification: {verify_client}")
|
50
|
+
print("=" * 50)
|
115
51
|
|
116
|
-
#
|
117
|
-
|
118
|
-
|
52
|
+
# Configure hypercorn
|
53
|
+
config_hypercorn = hypercorn.config.Config()
|
54
|
+
config_hypercorn.bind = [f"{host}:{port}"]
|
119
55
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
# Override settings with command line arguments
|
125
|
-
if args.host:
|
126
|
-
server_settings['host'] = args.host
|
127
|
-
if args.port:
|
128
|
-
server_settings['port'] = args.port
|
129
|
-
if args.debug:
|
130
|
-
server_settings['debug'] = True
|
131
|
-
if args.log_level:
|
132
|
-
logging_settings['level'] = args.log_level
|
133
|
-
server_settings['log_level'] = args.log_level
|
134
|
-
|
135
|
-
# Print server header and description
|
136
|
-
print("=" * 80)
|
137
|
-
print("🚀 MCP PROXY ADAPTER SERVER")
|
138
|
-
print("=" * 80)
|
139
|
-
print("📋 Configuration:")
|
140
|
-
print(f" • Server: {server_settings['host']}:{server_settings['port']}")
|
141
|
-
print(f" • Debug: {server_settings['debug']}")
|
142
|
-
print(f" • Log Level: {logging_settings['level']}")
|
143
|
-
print(f" • Auto Discovery: {commands_settings['auto_discovery']}")
|
144
|
-
print(f" • SSL Enabled: {ssl_settings.get('enabled', False)}")
|
145
|
-
print(f" • Security Enabled: {security_settings.get('enabled', False)}")
|
146
|
-
if ssl_settings.get('enabled', False):
|
147
|
-
print(f" • SSL Mode: {ssl_settings.get('mode', 'https_only')}")
|
148
|
-
if security_settings.get('enabled', False):
|
149
|
-
print(f" • Security Framework: {security_settings.get('framework', 'built-in')}")
|
150
|
-
print("=" * 80)
|
151
|
-
print()
|
152
|
-
|
153
|
-
logger.info("Starting MCP Proxy Adapter Server...")
|
154
|
-
logger.info(f"Server configuration: {server_settings}")
|
155
|
-
logger.info(f"Security configuration: {security_settings}")
|
156
|
-
|
157
|
-
try:
|
158
|
-
# Create application
|
159
|
-
app = create_app(
|
160
|
-
title="MCP Proxy Adapter Server",
|
161
|
-
description="Model Context Protocol Proxy Adapter with Security Framework",
|
162
|
-
version="1.0.0"
|
163
|
-
)
|
56
|
+
if ssl_enabled and ssl_cert_file and ssl_key_file:
|
57
|
+
config_hypercorn.certfile = ssl_cert_file
|
58
|
+
config_hypercorn.keyfile = ssl_key_file
|
164
59
|
|
165
|
-
|
166
|
-
|
167
|
-
"host": server_settings['host'],
|
168
|
-
"port": server_settings['port'],
|
169
|
-
"log_level": server_settings.get('log_level', 'info'),
|
170
|
-
"ssl": ssl_settings
|
171
|
-
}
|
60
|
+
if ssl_ca_cert:
|
61
|
+
config_hypercorn.ca_certs = ssl_ca_cert
|
172
62
|
|
173
|
-
|
174
|
-
|
175
|
-
|
63
|
+
if verify_client:
|
64
|
+
import ssl
|
65
|
+
config_hypercorn.verify_mode = ssl.CERT_REQUIRED
|
176
66
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
67
|
+
print(f"🔐 Starting HTTPS server with hypercorn...")
|
68
|
+
else:
|
69
|
+
print(f"🌐 Starting HTTP server with hypercorn...")
|
70
|
+
|
71
|
+
# Run the server
|
72
|
+
asyncio.run(hypercorn.asyncio.serve(app, config_hypercorn))
|
183
73
|
|
184
74
|
|
185
75
|
if __name__ == "__main__":
|
@@ -294,8 +294,12 @@ class ConfigGenerator:
|
|
294
294
|
return self._get_https_config(base_config)
|
295
295
|
elif config_type == "https_token":
|
296
296
|
return self._get_https_token_config(base_config)
|
297
|
+
elif config_type == "https_no_protocol_middleware":
|
298
|
+
return self._get_https_no_protocol_middleware_config(base_config)
|
297
299
|
elif config_type == "mtls":
|
298
300
|
return self._get_mtls_config(base_config)
|
301
|
+
elif config_type == "mtls_no_protocol_middleware":
|
302
|
+
return self._get_mtls_no_protocol_middleware_config(base_config)
|
299
303
|
else: # full
|
300
304
|
return base_config
|
301
305
|
|
@@ -329,6 +333,8 @@ class ConfigGenerator:
|
|
329
333
|
config["security"]["auth"]["enabled"] = False
|
330
334
|
config["security"]["permissions"]["enabled"] = False
|
331
335
|
config["security"]["permissions"]["roles_file"] = None
|
336
|
+
config["protocols"]["enabled"] = True
|
337
|
+
config["protocols"]["allowed_protocols"] = ["http"]
|
332
338
|
config["protocols"]["default_protocol"] = "http"
|
333
339
|
|
334
340
|
return config
|
@@ -357,6 +363,8 @@ class ConfigGenerator:
|
|
357
363
|
}
|
358
364
|
config["security"]["permissions"]["enabled"] = True
|
359
365
|
config["security"]["permissions"]["roles_file"] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
366
|
+
config["protocols"]["enabled"] = True
|
367
|
+
config["protocols"]["allowed_protocols"] = ["http"]
|
360
368
|
config["protocols"]["default_protocol"] = "http"
|
361
369
|
|
362
370
|
return config
|
@@ -380,6 +388,8 @@ class ConfigGenerator:
|
|
380
388
|
config["security"]["auth"]["enabled"] = False
|
381
389
|
config["security"]["permissions"]["enabled"] = False
|
382
390
|
config["security"]["permissions"]["roles_file"] = None
|
391
|
+
config["protocols"]["enabled"] = True
|
392
|
+
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
383
393
|
config["protocols"]["default_protocol"] = "https"
|
384
394
|
|
385
395
|
return config
|
@@ -416,6 +426,8 @@ class ConfigGenerator:
|
|
416
426
|
}
|
417
427
|
config["security"]["permissions"]["enabled"] = True
|
418
428
|
config["security"]["permissions"]["roles_file"] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
429
|
+
config["protocols"]["enabled"] = True
|
430
|
+
config["protocols"]["allowed_protocols"] = ["http", "https"]
|
419
431
|
config["protocols"]["default_protocol"] = "https"
|
420
432
|
|
421
433
|
return config
|
@@ -446,10 +458,78 @@ class ConfigGenerator:
|
|
446
458
|
config["security"]["auth"]["certificate_auth"] = True
|
447
459
|
config["security"]["permissions"]["enabled"] = True
|
448
460
|
config["security"]["permissions"]["roles_file"] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
461
|
+
config["protocols"]["enabled"] = True
|
462
|
+
config["protocols"]["allowed_protocols"] = ["https", "mtls"]
|
449
463
|
config["protocols"]["default_protocol"] = "https"
|
450
464
|
|
451
465
|
return config
|
452
466
|
|
467
|
+
def _get_https_no_protocol_middleware_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
468
|
+
"""Get HTTPS configuration without ProtocolMiddleware."""
|
469
|
+
config = base_config.copy()
|
470
|
+
|
471
|
+
# HTTPS settings
|
472
|
+
config["server"]["port"] = 8445
|
473
|
+
config["ssl"]["enabled"] = True
|
474
|
+
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
475
|
+
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
476
|
+
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
477
|
+
|
478
|
+
config["security"]["ssl"]["enabled"] = True
|
479
|
+
config["security"]["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
480
|
+
config["security"]["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
481
|
+
config["security"]["ssl"]["ca_cert_file"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
482
|
+
|
483
|
+
config["security"]["auth"]["enabled"] = True
|
484
|
+
config["security"]["auth"]["methods"] = ["api_key"]
|
485
|
+
config["security"]["auth"]["api_keys"] = {
|
486
|
+
"test-token-123": {
|
487
|
+
"roles": ["admin"],
|
488
|
+
"permissions": ["*"],
|
489
|
+
"expires": None
|
490
|
+
},
|
491
|
+
"user-token-456": {
|
492
|
+
"roles": ["user"],
|
493
|
+
"permissions": ["read", "execute"],
|
494
|
+
"expires": None
|
495
|
+
}
|
496
|
+
}
|
497
|
+
config["security"]["permissions"]["enabled"] = True
|
498
|
+
config["security"]["permissions"]["roles_file"] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
499
|
+
config["protocols"]["enabled"] = False # Disable ProtocolMiddleware
|
500
|
+
|
501
|
+
return config
|
502
|
+
|
503
|
+
def _get_mtls_no_protocol_middleware_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
504
|
+
"""Get mTLS configuration without ProtocolMiddleware."""
|
505
|
+
config = base_config.copy()
|
506
|
+
|
507
|
+
# mTLS settings
|
508
|
+
config["server"]["port"] = 8447
|
509
|
+
config["ssl"]["enabled"] = True
|
510
|
+
config["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
511
|
+
config["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
512
|
+
config["ssl"]["ca_cert"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
513
|
+
config["ssl"]["verify_client"] = True
|
514
|
+
config["ssl"]["client_cert_required"] = True
|
515
|
+
|
516
|
+
config["security"]["ssl"]["enabled"] = True
|
517
|
+
config["security"]["ssl"]["cert_file"] = "mcp_proxy_adapter/examples/certs/server_cert.pem"
|
518
|
+
config["security"]["ssl"]["key_file"] = "mcp_proxy_adapter/examples/certs/server_key.pem"
|
519
|
+
config["security"]["ssl"]["ca_cert_file"] = "mcp_proxy_adapter/examples/certs/ca_cert.pem"
|
520
|
+
config["security"]["ssl"]["client_cert_file"] = "mcp_proxy_adapter/examples/certs/client_cert.pem"
|
521
|
+
config["security"]["ssl"]["client_key_file"] = "mcp_proxy_adapter/examples/certs/client_key.pem"
|
522
|
+
config["security"]["ssl"]["verify_mode"] = "CERT_REQUIRED"
|
523
|
+
|
524
|
+
config["security"]["auth"]["enabled"] = True
|
525
|
+
config["security"]["auth"]["methods"] = ["certificate"]
|
526
|
+
config["security"]["auth"]["certificate_auth"] = True
|
527
|
+
config["security"]["permissions"]["enabled"] = True
|
528
|
+
config["security"]["permissions"]["roles_file"] = "mcp_proxy_adapter/examples/server_configs/roles.json"
|
529
|
+
config["protocols"]["enabled"] = False # Disable ProtocolMiddleware
|
530
|
+
|
531
|
+
return config
|
532
|
+
|
453
533
|
def _get_secure_config(self, base_config: Dict[str, Any]) -> Dict[str, Any]:
|
454
534
|
"""Get secure configuration with all security features enabled."""
|
455
535
|
config = base_config.copy()
|
@@ -561,6 +641,12 @@ class ConfigGenerator:
|
|
561
641
|
elif config_type == "mtls":
|
562
642
|
base_comments["ssl"] = "SSL/TLS configuration (enabled for mTLS with client certificate verification)"
|
563
643
|
base_comments["security"] = "Security framework configuration (mTLS mode with certificate authentication)"
|
644
|
+
elif config_type == "https_no_protocol_middleware":
|
645
|
+
base_comments["ssl"] = "SSL/TLS configuration (enabled for HTTPS without ProtocolMiddleware)"
|
646
|
+
base_comments["security"] = "Security framework configuration (HTTPS mode without ProtocolMiddleware)"
|
647
|
+
elif config_type == "mtls_no_protocol_middleware":
|
648
|
+
base_comments["ssl"] = "SSL/TLS configuration (enabled for mTLS without ProtocolMiddleware)"
|
649
|
+
base_comments["security"] = "Security framework configuration (mTLS mode without ProtocolMiddleware)"
|
564
650
|
|
565
651
|
return base_comments
|
566
652
|
|
@@ -599,7 +685,8 @@ class ConfigGenerator:
|
|
599
685
|
"""
|
600
686
|
config_types = [
|
601
687
|
"minimal", "development", "secure", "full",
|
602
|
-
"basic_http", "http_token", "https", "https_token", "mtls"
|
688
|
+
"basic_http", "http_token", "https", "https_token", "mtls",
|
689
|
+
"https_no_protocol_middleware", "mtls_no_protocol_middleware"
|
603
690
|
]
|
604
691
|
|
605
692
|
for config_type in config_types:
|
@@ -616,7 +703,8 @@ def main():
|
|
616
703
|
parser = argparse.ArgumentParser(description="Generate MCP Proxy Adapter configuration files")
|
617
704
|
parser.add_argument("--type",
|
618
705
|
choices=["minimal", "development", "secure", "full",
|
619
|
-
"basic_http", "http_token", "https", "https_token", "mtls"
|
706
|
+
"basic_http", "http_token", "https", "https_token", "mtls",
|
707
|
+
"https_no_protocol_middleware", "mtls_no_protocol_middleware"],
|
620
708
|
default="full", help="Configuration type to generate")
|
621
709
|
parser.add_argument("--output", default="./config.json",
|
622
710
|
help="Output file path")
|
mcp_proxy_adapter/version.py
CHANGED