mcp-proxy-adapter 6.1.1__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/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/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 +1 -25
- 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/version.py +1 -1
- 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/docs/EN/TROUBLESHOOTING.md +0 -285
- mcp_proxy_adapter/docs/RU/TROUBLESHOOTING.md +0 -285
- 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/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 -43
- mcp_proxy_adapter/examples/basic_framework/configs/https_no_protocol_middleware.json +0 -36
- mcp_proxy_adapter/examples/basic_framework/configs/https_simple.json +0 -29
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_protocol_middleware.json +0 -34
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_roles.json +0 -39
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_simple.json +0 -35
- 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.1.dist-info/METADATA +0 -205
- mcp_proxy_adapter-6.1.1.dist-info/RECORD +0 -197
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.1.1.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__":
|
mcp_proxy_adapter/version.py
CHANGED