mcp-proxy-adapter 6.0.0__py3-none-any.whl → 6.0.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/__main__.py +27 -7
- mcp_proxy_adapter/api/app.py +209 -79
- mcp_proxy_adapter/api/handlers.py +16 -5
- mcp_proxy_adapter/api/middleware/__init__.py +14 -9
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +148 -0
- mcp_proxy_adapter/api/middleware/factory.py +36 -12
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +84 -18
- mcp_proxy_adapter/api/middleware/unified_security.py +197 -0
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +158 -0
- mcp_proxy_adapter/commands/__init__.py +7 -1
- mcp_proxy_adapter/commands/base.py +7 -4
- mcp_proxy_adapter/commands/builtin_commands.py +8 -2
- mcp_proxy_adapter/commands/command_registry.py +8 -0
- mcp_proxy_adapter/commands/echo_command.py +81 -0
- mcp_proxy_adapter/commands/health_command.py +1 -1
- mcp_proxy_adapter/commands/help_command.py +21 -14
- mcp_proxy_adapter/commands/proxy_registration_command.py +326 -185
- mcp_proxy_adapter/commands/role_test_command.py +141 -0
- mcp_proxy_adapter/commands/security_command.py +488 -0
- mcp_proxy_adapter/commands/ssl_setup_command.py +234 -351
- mcp_proxy_adapter/commands/token_management_command.py +1 -1
- mcp_proxy_adapter/config.py +323 -40
- mcp_proxy_adapter/core/app_factory.py +410 -0
- 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/client_security.py +384 -0
- mcp_proxy_adapter/core/logging.py +8 -3
- mcp_proxy_adapter/core/mtls_asgi.py +156 -0
- mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
- mcp_proxy_adapter/core/protocol_manager.py +169 -10
- mcp_proxy_adapter/core/proxy_client.py +602 -0
- mcp_proxy_adapter/core/proxy_registration.py +299 -47
- mcp_proxy_adapter/core/security_adapter.py +12 -15
- mcp_proxy_adapter/core/security_integration.py +286 -0
- mcp_proxy_adapter/core/server_adapter.py +282 -0
- mcp_proxy_adapter/core/server_engine.py +270 -0
- mcp_proxy_adapter/core/ssl_utils.py +13 -12
- mcp_proxy_adapter/core/transport_manager.py +5 -5
- mcp_proxy_adapter/core/unified_config_adapter.py +579 -0
- mcp_proxy_adapter/examples/__init__.py +13 -4
- mcp_proxy_adapter/examples/basic_framework/__init__.py +9 -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 +44 -0
- mcp_proxy_adapter/examples/commands/__init__.py +5 -0
- mcp_proxy_adapter/examples/create_certificates_simple.py +550 -0
- mcp_proxy_adapter/examples/debug_request_state.py +112 -0
- mcp_proxy_adapter/examples/debug_role_chain.py +158 -0
- mcp_proxy_adapter/examples/demo_client.py +275 -0
- mcp_proxy_adapter/examples/examples/basic_framework/__init__.py +9 -0
- mcp_proxy_adapter/examples/examples/basic_framework/commands/__init__.py +4 -0
- mcp_proxy_adapter/examples/examples/basic_framework/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/examples/basic_framework/main.py +44 -0
- mcp_proxy_adapter/examples/examples/full_application/__init__.py +12 -0
- mcp_proxy_adapter/examples/examples/full_application/commands/__init__.py +7 -0
- mcp_proxy_adapter/examples/examples/full_application/commands/custom_echo_command.py +80 -0
- mcp_proxy_adapter/examples/examples/full_application/commands/dynamic_calculator_command.py +90 -0
- mcp_proxy_adapter/examples/examples/full_application/hooks/__init__.py +7 -0
- mcp_proxy_adapter/examples/examples/full_application/hooks/application_hooks.py +75 -0
- mcp_proxy_adapter/examples/examples/full_application/hooks/builtin_command_hooks.py +71 -0
- mcp_proxy_adapter/examples/examples/full_application/main.py +173 -0
- mcp_proxy_adapter/examples/examples/full_application/proxy_endpoints.py +154 -0
- mcp_proxy_adapter/examples/full_application/__init__.py +12 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +80 -0
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +90 -0
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +75 -0
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +71 -0
- mcp_proxy_adapter/examples/full_application/main.py +173 -0
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +154 -0
- mcp_proxy_adapter/examples/generate_all_certificates.py +362 -0
- mcp_proxy_adapter/examples/generate_certificates.py +177 -0
- mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +369 -0
- mcp_proxy_adapter/examples/generate_test_configs.py +331 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +334 -0
- mcp_proxy_adapter/examples/run_example.py +59 -0
- mcp_proxy_adapter/examples/run_full_test_suite.py +318 -0
- mcp_proxy_adapter/examples/run_proxy_server.py +146 -0
- mcp_proxy_adapter/examples/run_security_tests.py +544 -0
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +247 -0
- mcp_proxy_adapter/examples/scripts/config_generator.py +740 -0
- mcp_proxy_adapter/examples/scripts/create_certificates_simple.py +560 -0
- mcp_proxy_adapter/examples/scripts/generate_certificates_and_tokens.py +369 -0
- mcp_proxy_adapter/examples/security_test_client.py +782 -0
- mcp_proxy_adapter/examples/setup_test_environment.py +328 -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 +281 -0
- mcp_proxy_adapter/examples/universal_client.py +620 -0
- mcp_proxy_adapter/main.py +66 -148
- mcp_proxy_adapter/utils/config_generator.py +1008 -0
- mcp_proxy_adapter/version.py +5 -2
- mcp_proxy_adapter-6.0.1.dist-info/METADATA +679 -0
- mcp_proxy_adapter-6.0.1.dist-info/RECORD +140 -0
- mcp_proxy_adapter-6.0.1.dist-info/entry_points.txt +2 -0
- {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/licenses/LICENSE +2 -2
- mcp_proxy_adapter/api/middleware/auth.py +0 -146
- mcp_proxy_adapter/api/middleware/auth_adapter.py +0 -235
- mcp_proxy_adapter/api/middleware/mtls_adapter.py +0 -305
- mcp_proxy_adapter/api/middleware/mtls_middleware.py +0 -296
- mcp_proxy_adapter/api/middleware/rate_limit.py +0 -152
- mcp_proxy_adapter/api/middleware/rate_limit_adapter.py +0 -241
- mcp_proxy_adapter/api/middleware/roles_adapter.py +0 -365
- mcp_proxy_adapter/api/middleware/roles_middleware.py +0 -381
- mcp_proxy_adapter/api/middleware/security.py +0 -376
- mcp_proxy_adapter/api/middleware/token_auth_middleware.py +0 -261
- mcp_proxy_adapter/examples/README.md +0 -124
- mcp_proxy_adapter/examples/basic_server/README.md +0 -60
- mcp_proxy_adapter/examples/basic_server/__init__.py +0 -7
- mcp_proxy_adapter/examples/basic_server/basic_custom_settings.json +0 -39
- mcp_proxy_adapter/examples/basic_server/config.json +0 -70
- mcp_proxy_adapter/examples/basic_server/config_all_protocols.json +0 -54
- mcp_proxy_adapter/examples/basic_server/config_http.json +0 -70
- mcp_proxy_adapter/examples/basic_server/config_http_only.json +0 -52
- mcp_proxy_adapter/examples/basic_server/config_https.json +0 -58
- mcp_proxy_adapter/examples/basic_server/config_mtls.json +0 -58
- mcp_proxy_adapter/examples/basic_server/config_ssl.json +0 -46
- mcp_proxy_adapter/examples/basic_server/custom_settings_example.py +0 -238
- mcp_proxy_adapter/examples/basic_server/server.py +0 -114
- mcp_proxy_adapter/examples/custom_commands/README.md +0 -127
- mcp_proxy_adapter/examples/custom_commands/__init__.py +0 -27
- mcp_proxy_adapter/examples/custom_commands/advanced_hooks.py +0 -566
- mcp_proxy_adapter/examples/custom_commands/auto_commands/__init__.py +0 -6
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_echo_command.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_info_command.py +0 -111
- mcp_proxy_adapter/examples/custom_commands/auto_commands/test_command.py +0 -105
- mcp_proxy_adapter/examples/custom_commands/catalog/commands/test_command.py +0 -129
- mcp_proxy_adapter/examples/custom_commands/config.json +0 -118
- mcp_proxy_adapter/examples/custom_commands/config_all_protocols.json +0 -46
- mcp_proxy_adapter/examples/custom_commands/config_https_only.json +0 -46
- mcp_proxy_adapter/examples/custom_commands/config_https_transport.json +0 -33
- mcp_proxy_adapter/examples/custom_commands/config_mtls_only.json +0 -46
- mcp_proxy_adapter/examples/custom_commands/config_mtls_transport.json +0 -33
- mcp_proxy_adapter/examples/custom_commands/config_single_transport.json +0 -33
- mcp_proxy_adapter/examples/custom_commands/custom_health_command.py +0 -169
- mcp_proxy_adapter/examples/custom_commands/custom_help_command.py +0 -215
- mcp_proxy_adapter/examples/custom_commands/custom_openapi_generator.py +0 -76
- mcp_proxy_adapter/examples/custom_commands/custom_settings.json +0 -96
- mcp_proxy_adapter/examples/custom_commands/custom_settings_manager.py +0 -241
- mcp_proxy_adapter/examples/custom_commands/data_transform_command.py +0 -135
- mcp_proxy_adapter/examples/custom_commands/echo_command.py +0 -122
- mcp_proxy_adapter/examples/custom_commands/full_help_response.json +0 -1
- mcp_proxy_adapter/examples/custom_commands/generated_openapi.json +0 -629
- mcp_proxy_adapter/examples/custom_commands/get_openapi.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/hooks.py +0 -230
- mcp_proxy_adapter/examples/custom_commands/intercept_command.py +0 -123
- mcp_proxy_adapter/examples/custom_commands/loadable_commands/test_ignored.py +0 -129
- mcp_proxy_adapter/examples/custom_commands/manual_echo_command.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/proxy_connection_manager.py +0 -278
- mcp_proxy_adapter/examples/custom_commands/server.py +0 -252
- mcp_proxy_adapter/examples/custom_commands/simple_openapi_server.py +0 -75
- mcp_proxy_adapter/examples/custom_commands/start_server_with_proxy_manager.py +0 -299
- mcp_proxy_adapter/examples/custom_commands/start_server_with_registration.py +0 -278
- mcp_proxy_adapter/examples/custom_commands/test_hooks.py +0 -176
- mcp_proxy_adapter/examples/custom_commands/test_openapi.py +0 -27
- mcp_proxy_adapter/examples/custom_commands/test_registry.py +0 -23
- mcp_proxy_adapter/examples/custom_commands/test_simple.py +0 -19
- mcp_proxy_adapter/examples/custom_project_example/README.md +0 -103
- mcp_proxy_adapter/examples/custom_project_example/README_EN.md +0 -103
- mcp_proxy_adapter/examples/deployment/README.md +0 -49
- mcp_proxy_adapter/examples/deployment/__init__.py +0 -7
- mcp_proxy_adapter/examples/deployment/config.development.json +0 -8
- mcp_proxy_adapter/examples/deployment/config.json +0 -29
- mcp_proxy_adapter/examples/deployment/config.production.json +0 -12
- mcp_proxy_adapter/examples/deployment/config.staging.json +0 -11
- mcp_proxy_adapter/examples/deployment/docker-compose.yml +0 -31
- mcp_proxy_adapter/examples/deployment/run.sh +0 -43
- mcp_proxy_adapter/examples/deployment/run_docker.sh +0 -84
- mcp_proxy_adapter/examples/simple_custom_commands/README.md +0 -149
- mcp_proxy_adapter/examples/simple_custom_commands/README_EN.md +0 -149
- mcp_proxy_adapter/schemas/base_schema.json +0 -114
- mcp_proxy_adapter/schemas/openapi_schema.json +0 -314
- mcp_proxy_adapter/schemas/roles_schema.json +0 -162
- mcp_proxy_adapter/tests/__init__.py +0 -0
- mcp_proxy_adapter/tests/api/__init__.py +0 -3
- mcp_proxy_adapter/tests/api/test_cmd_endpoint.py +0 -115
- mcp_proxy_adapter/tests/api/test_custom_openapi.py +0 -617
- mcp_proxy_adapter/tests/api/test_handlers.py +0 -522
- mcp_proxy_adapter/tests/api/test_middleware.py +0 -340
- mcp_proxy_adapter/tests/api/test_schemas.py +0 -546
- mcp_proxy_adapter/tests/api/test_tool_integration.py +0 -531
- mcp_proxy_adapter/tests/commands/__init__.py +0 -3
- mcp_proxy_adapter/tests/commands/test_config_command.py +0 -211
- mcp_proxy_adapter/tests/commands/test_echo_command.py +0 -127
- mcp_proxy_adapter/tests/commands/test_help_command.py +0 -136
- mcp_proxy_adapter/tests/conftest.py +0 -131
- mcp_proxy_adapter/tests/functional/__init__.py +0 -3
- mcp_proxy_adapter/tests/functional/test_api.py +0 -253
- mcp_proxy_adapter/tests/integration/__init__.py +0 -3
- mcp_proxy_adapter/tests/integration/test_cmd_integration.py +0 -129
- mcp_proxy_adapter/tests/integration/test_integration.py +0 -255
- mcp_proxy_adapter/tests/performance/__init__.py +0 -3
- mcp_proxy_adapter/tests/performance/test_performance.py +0 -189
- mcp_proxy_adapter/tests/stubs/__init__.py +0 -10
- mcp_proxy_adapter/tests/stubs/echo_command.py +0 -104
- mcp_proxy_adapter/tests/test_api_endpoints.py +0 -271
- mcp_proxy_adapter/tests/test_api_handlers.py +0 -289
- mcp_proxy_adapter/tests/test_base_command.py +0 -123
- mcp_proxy_adapter/tests/test_batch_requests.py +0 -117
- mcp_proxy_adapter/tests/test_command_registry.py +0 -281
- mcp_proxy_adapter/tests/test_config.py +0 -127
- mcp_proxy_adapter/tests/test_utils.py +0 -65
- mcp_proxy_adapter/tests/unit/__init__.py +0 -3
- mcp_proxy_adapter/tests/unit/test_base_command.py +0 -436
- mcp_proxy_adapter/tests/unit/test_config.py +0 -270
- mcp_proxy_adapter-6.0.0.dist-info/METADATA +0 -201
- mcp_proxy_adapter-6.0.0.dist-info/RECORD +0 -179
- {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/top_level.txt +0 -0
mcp_proxy_adapter/main.py
CHANGED
@@ -1,174 +1,92 @@
|
|
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 ssl
|
11
|
+
import hypercorn.asyncio
|
12
|
+
import hypercorn.config
|
13
|
+
import asyncio
|
14
|
+
import argparse
|
13
15
|
from pathlib import Path
|
14
16
|
|
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
|
17
|
+
# Add the project root to the path
|
18
|
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
25
19
|
|
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()
|
20
|
+
from mcp_proxy_adapter.api.app import create_app
|
21
|
+
from mcp_proxy_adapter.config import Config
|
61
22
|
|
62
23
|
|
63
24
|
def main():
|
64
|
-
"""
|
65
|
-
|
25
|
+
"""Main entry point for the MCP Proxy Adapter."""
|
26
|
+
# Parse command line arguments
|
27
|
+
parser = argparse.ArgumentParser(description="MCP Proxy Adapter Server")
|
28
|
+
parser.add_argument("--config", "-c", type=str, help="Path to configuration file")
|
29
|
+
args = parser.parse_args()
|
66
30
|
|
67
|
-
# Load configuration
|
31
|
+
# Load configuration
|
68
32
|
if args.config:
|
69
|
-
|
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)
|
33
|
+
config = Config(config_path=args.config)
|
77
34
|
else:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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", {})
|
90
|
-
|
91
|
-
# STRICT CONFIGURATION VALIDATION
|
92
|
-
from mcp_proxy_adapter.core.config_validator import ConfigValidator
|
93
|
-
|
94
|
-
# Get full config for validation
|
95
|
-
full_config = {
|
96
|
-
"server": server_settings,
|
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
|
-
}
|
104
|
-
|
105
|
-
# Validate configuration
|
106
|
-
validator = ConfigValidator(full_config)
|
107
|
-
if not validator.validate_all():
|
108
|
-
logger.critical("CRITICAL SECURITY ERROR: Configuration validation failed")
|
109
|
-
validator.print_validation_report()
|
110
|
-
logger.critical("Server startup blocked for security reasons.")
|
111
|
-
logger.critical("Please fix configuration errors or disable security features.")
|
112
|
-
sys.exit(1)
|
35
|
+
config = Config()
|
36
|
+
|
37
|
+
|
38
|
+
# Create application
|
39
|
+
app = create_app(app_config=config)
|
113
40
|
|
114
|
-
|
41
|
+
# Get server configuration
|
42
|
+
host = config.get("server.host", "0.0.0.0")
|
43
|
+
port = config.get("server.port", 8000)
|
115
44
|
|
116
|
-
#
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
server_settings['debug'] = True
|
123
|
-
if args.log_level:
|
124
|
-
logging_settings['level'] = args.log_level
|
125
|
-
server_settings['log_level'] = args.log_level
|
45
|
+
# Get SSL configuration
|
46
|
+
ssl_enabled = config.get("ssl.enabled", False)
|
47
|
+
ssl_cert_file = config.get("ssl.cert_file")
|
48
|
+
ssl_key_file = config.get("ssl.key_file")
|
49
|
+
ssl_ca_cert = config.get("ssl.ca_cert")
|
50
|
+
verify_client = config.get("ssl.verify_client", False)
|
126
51
|
|
127
|
-
|
128
|
-
print("
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
print(
|
137
|
-
print(f" • Security Enabled: {security_settings.get('enabled', False)}")
|
138
|
-
if ssl_settings.get('enabled', False):
|
139
|
-
print(f" • SSL Mode: {ssl_settings.get('mode', 'https_only')}")
|
140
|
-
if security_settings.get('enabled', False):
|
141
|
-
print(f" • Security Framework: {security_settings.get('framework', 'built-in')}")
|
142
|
-
print("=" * 80)
|
143
|
-
print()
|
52
|
+
print(f"🚀 Starting MCP Proxy Adapter")
|
53
|
+
print(f"🌐 Server: {host}:{port}")
|
54
|
+
if ssl_enabled:
|
55
|
+
print(f"🔐 SSL: Enabled")
|
56
|
+
print(f" Certificate: {ssl_cert_file}")
|
57
|
+
print(f" Key: {ssl_key_file}")
|
58
|
+
if ssl_ca_cert:
|
59
|
+
print(f" CA: {ssl_ca_cert}")
|
60
|
+
print(f" Client verification: {verify_client}")
|
61
|
+
print("=" * 50)
|
144
62
|
|
145
|
-
|
146
|
-
|
147
|
-
|
63
|
+
# Configure hypercorn
|
64
|
+
config_hypercorn = hypercorn.config.Config()
|
65
|
+
config_hypercorn.bind = [f"{host}:{port}"]
|
148
66
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
title="MCP Proxy Adapter Server",
|
153
|
-
description="Model Context Protocol Proxy Adapter with Security Framework",
|
154
|
-
version="1.0.0"
|
155
|
-
)
|
67
|
+
if ssl_enabled and ssl_cert_file and ssl_key_file:
|
68
|
+
config_hypercorn.certfile = ssl_cert_file
|
69
|
+
config_hypercorn.keyfile = ssl_key_file
|
156
70
|
|
157
|
-
|
158
|
-
|
71
|
+
if ssl_ca_cert:
|
72
|
+
config_hypercorn.ca_certs = ssl_ca_cert
|
159
73
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
74
|
+
if verify_client:
|
75
|
+
# For mTLS, require client certificates
|
76
|
+
config_hypercorn.set_cert_reqs(ssl.CERT_REQUIRED)
|
77
|
+
config_hypercorn.verify_mode = ssl.CERT_REQUIRED
|
78
|
+
print("🔐 mTLS: Client certificate verification enabled")
|
79
|
+
else:
|
80
|
+
# For regular HTTPS without client verification
|
81
|
+
config_hypercorn.set_cert_reqs(ssl.CERT_NONE)
|
82
|
+
config_hypercorn.verify_mode = ssl.CERT_NONE
|
168
83
|
|
169
|
-
|
170
|
-
|
171
|
-
|
84
|
+
print(f"🔐 Starting HTTPS server with hypercorn...")
|
85
|
+
else:
|
86
|
+
print(f"🌐 Starting HTTP server with hypercorn...")
|
87
|
+
|
88
|
+
# Run the server
|
89
|
+
asyncio.run(hypercorn.asyncio.serve(app, config_hypercorn))
|
172
90
|
|
173
91
|
|
174
92
|
if __name__ == "__main__":
|