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,12 +1,32 @@
|
|
1
|
-
|
2
|
-
"""
|
3
|
-
Main entry point for MCP Proxy Adapter.
|
1
|
+
"""Main entry point for MCP Proxy Adapter CLI.
|
4
2
|
|
5
|
-
This module
|
6
|
-
|
3
|
+
This module provides a command-line interface for running
|
4
|
+
MCP Proxy Adapter applications.
|
7
5
|
"""
|
8
6
|
|
9
|
-
|
7
|
+
import sys
|
8
|
+
from pathlib import Path
|
9
|
+
|
10
|
+
# Add the current directory to Python path for imports
|
11
|
+
current_dir = Path(__file__).parent
|
12
|
+
sys.path.insert(0, str(current_dir))
|
13
|
+
|
14
|
+
from mcp_proxy_adapter.api.app import create_app
|
15
|
+
|
16
|
+
|
17
|
+
def main():
|
18
|
+
"""Main CLI entry point."""
|
19
|
+
print("MCP Proxy Adapter v6.2.0")
|
20
|
+
print("========================")
|
21
|
+
print()
|
22
|
+
print("Usage:")
|
23
|
+
print(" python -m mcp_proxy_adapter")
|
24
|
+
print(" # or")
|
25
|
+
print(" mcp-proxy-adapter")
|
26
|
+
print()
|
27
|
+
print("For more information, see:")
|
28
|
+
print(" https://github.com/maverikod/mcp-proxy-adapter#readme")
|
29
|
+
|
10
30
|
|
11
31
|
if __name__ == "__main__":
|
12
|
-
main()
|
32
|
+
main()
|
mcp_proxy_adapter/api/app.py
CHANGED
@@ -170,16 +170,27 @@ def create_app(title: Optional[str] = None, description: Optional[str] = None, v
|
|
170
170
|
SystemExit: If authentication is enabled but required files are missing (security issue)
|
171
171
|
"""
|
172
172
|
# Use provided configuration or fallback to global config
|
173
|
-
|
173
|
+
if app_config is not None:
|
174
|
+
if hasattr(app_config, 'get_all'):
|
175
|
+
current_config = app_config.get_all()
|
176
|
+
elif hasattr(app_config, 'keys'):
|
177
|
+
current_config = app_config
|
178
|
+
else:
|
179
|
+
current_config = config.get_all()
|
180
|
+
else:
|
181
|
+
current_config = config.get_all()
|
174
182
|
|
175
183
|
# Debug: Check what config is passed to create_app
|
176
184
|
if app_config:
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
185
|
+
if hasattr(app_config, 'keys'):
|
186
|
+
print(f"🔍 Debug: create_app received app_config keys: {list(app_config.keys())}")
|
187
|
+
if "security" in app_config:
|
188
|
+
ssl_config = app_config["security"].get("ssl", {})
|
189
|
+
print(f"🔍 Debug: create_app SSL config: enabled={ssl_config.get('enabled', False)}")
|
190
|
+
print(f"🔍 Debug: create_app SSL config: cert_file={ssl_config.get('cert_file')}")
|
191
|
+
print(f"🔍 Debug: create_app SSL config: key_file={ssl_config.get('key_file')}")
|
192
|
+
else:
|
193
|
+
print(f"🔍 Debug: create_app received app_config type: {type(app_config)}")
|
183
194
|
else:
|
184
195
|
print("🔍 Debug: create_app received no app_config, using global config")
|
185
196
|
|
@@ -43,8 +43,8 @@ def setup_middleware(app: FastAPI, app_config: Optional[Dict[str, Any]] = None)
|
|
43
43
|
else:
|
44
44
|
logger.warning(f"Middleware {middleware.__class__.__name__} doesn't have dispatch method")
|
45
45
|
|
46
|
-
# Add protocol middleware
|
47
|
-
setup_protocol_middleware(app)
|
46
|
+
# Add protocol middleware with current configuration
|
47
|
+
setup_protocol_middleware(app, current_config)
|
48
48
|
|
49
49
|
# Log middleware information
|
50
50
|
middleware_info = factory.get_middleware_info()
|
@@ -4,12 +4,12 @@ Protocol middleware module.
|
|
4
4
|
This module provides middleware for validating protocol access based on configuration.
|
5
5
|
"""
|
6
6
|
|
7
|
-
from typing import Callable
|
7
|
+
from typing import Callable, Dict, Any, Optional
|
8
8
|
from fastapi import Request, Response
|
9
9
|
from starlette.middleware.base import BaseHTTPMiddleware
|
10
10
|
from starlette.responses import JSONResponse
|
11
11
|
|
12
|
-
from mcp_proxy_adapter.core.protocol_manager import
|
12
|
+
from mcp_proxy_adapter.core.protocol_manager import get_protocol_manager
|
13
13
|
from mcp_proxy_adapter.core.logging import logger
|
14
14
|
|
15
15
|
|
@@ -21,16 +21,29 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
|
|
21
21
|
based on the protocol configuration.
|
22
22
|
"""
|
23
23
|
|
24
|
-
def __init__(self, app,
|
24
|
+
def __init__(self, app, app_config: Optional[Dict[str, Any]] = None):
|
25
25
|
"""
|
26
26
|
Initialize protocol middleware.
|
27
27
|
|
28
28
|
Args:
|
29
29
|
app: FastAPI application
|
30
|
-
|
30
|
+
app_config: Application configuration dictionary (optional)
|
31
31
|
"""
|
32
32
|
super().__init__(app)
|
33
|
-
self.
|
33
|
+
self.app_config = app_config
|
34
|
+
# Get protocol manager with current configuration
|
35
|
+
self.protocol_manager = get_protocol_manager(app_config)
|
36
|
+
|
37
|
+
def update_config(self, new_config: Dict[str, Any]):
|
38
|
+
"""
|
39
|
+
Update configuration and reload protocol manager.
|
40
|
+
|
41
|
+
Args:
|
42
|
+
new_config: New configuration dictionary
|
43
|
+
"""
|
44
|
+
self.app_config = new_config
|
45
|
+
self.protocol_manager = get_protocol_manager(new_config)
|
46
|
+
logger.info("Protocol middleware configuration updated")
|
34
47
|
|
35
48
|
async def dispatch(self, request: Request, call_next: Callable) -> Response:
|
36
49
|
"""
|
@@ -116,20 +129,26 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
|
|
116
129
|
return "http"
|
117
130
|
|
118
131
|
|
119
|
-
def setup_protocol_middleware(app,
|
132
|
+
def setup_protocol_middleware(app, app_config: Optional[Dict[str, Any]] = None):
|
120
133
|
"""
|
121
134
|
Setup protocol middleware for FastAPI application.
|
122
135
|
|
123
136
|
Args:
|
124
137
|
app: FastAPI application
|
125
|
-
|
138
|
+
app_config: Application configuration dictionary (optional)
|
126
139
|
"""
|
127
|
-
if
|
128
|
-
|
140
|
+
# Check if protocol management is enabled
|
141
|
+
if app_config is None:
|
142
|
+
from mcp_proxy_adapter.config import config
|
143
|
+
app_config = config.get_all()
|
144
|
+
|
145
|
+
protocols_config = app_config.get("protocols", {})
|
146
|
+
enabled = protocols_config.get("enabled", True)
|
129
147
|
|
130
|
-
|
131
|
-
|
132
|
-
app
|
148
|
+
if enabled:
|
149
|
+
# Create protocol middleware with current configuration
|
150
|
+
middleware = ProtocolMiddleware(app, app_config)
|
151
|
+
app.add_middleware(ProtocolMiddleware, app_config=app_config)
|
133
152
|
logger.info("Protocol middleware added to application")
|
134
153
|
else:
|
135
|
-
logger.
|
154
|
+
logger.info("Protocol management is disabled, skipping protocol middleware")
|
@@ -66,9 +66,12 @@ class UnifiedSecurityMiddleware(BaseHTTPMiddleware):
|
|
66
66
|
logger.info("Using mcp_security_framework FastAPI middleware")
|
67
67
|
except Exception as e:
|
68
68
|
logger.error(f"Security framework integration failed: {e}")
|
69
|
-
|
69
|
+
# Instead of raising error, log warning and continue without security
|
70
|
+
logger.warning("Continuing without security framework - some security features will be disabled")
|
71
|
+
self.security_integration = None
|
72
|
+
self.framework_middleware = None
|
70
73
|
|
71
|
-
logger.info("Unified security middleware initialized
|
74
|
+
logger.info("Unified security middleware initialized")
|
72
75
|
|
73
76
|
async def dispatch(self, request: Request, call_next: Callable[[Request], Awaitable[Response]]) -> Response:
|
74
77
|
"""
|
@@ -82,8 +85,13 @@ class UnifiedSecurityMiddleware(BaseHTTPMiddleware):
|
|
82
85
|
Response object
|
83
86
|
"""
|
84
87
|
try:
|
85
|
-
# Use framework middleware
|
86
|
-
|
88
|
+
# Use framework middleware if available
|
89
|
+
if self.framework_middleware is not None:
|
90
|
+
return await self.framework_middleware.dispatch(request, call_next)
|
91
|
+
else:
|
92
|
+
# Fallback: continue without security middleware
|
93
|
+
logger.debug("Security framework not available, continuing without security checks")
|
94
|
+
return await call_next(request)
|
87
95
|
|
88
96
|
except SecurityValidationError as e:
|
89
97
|
# Handle security validation errors
|