mcp-proxy-adapter 6.9.27__py3-none-any.whl → 6.9.29__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.
Potentially problematic release.
This version of mcp-proxy-adapter might be problematic. Click here for more details.
- mcp_proxy_adapter/__init__.py +10 -0
- mcp_proxy_adapter/__main__.py +8 -21
- mcp_proxy_adapter/api/app.py +10 -913
- mcp_proxy_adapter/api/core/__init__.py +18 -0
- mcp_proxy_adapter/api/core/app_factory.py +243 -0
- mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
- mcp_proxy_adapter/api/core/registration_manager.py +166 -0
- mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
- mcp_proxy_adapter/api/handlers.py +78 -199
- mcp_proxy_adapter/api/middleware/__init__.py +1 -44
- mcp_proxy_adapter/api/middleware/base.py +0 -42
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +0 -85
- mcp_proxy_adapter/api/middleware/error_handling.py +1 -127
- mcp_proxy_adapter/api/middleware/factory.py +0 -94
- mcp_proxy_adapter/api/middleware/logging.py +0 -112
- mcp_proxy_adapter/api/middleware/performance.py +0 -35
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +2 -98
- mcp_proxy_adapter/api/middleware/transport_middleware.py +0 -37
- mcp_proxy_adapter/api/middleware/unified_security.py +10 -10
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +0 -118
- mcp_proxy_adapter/api/openapi/__init__.py +21 -0
- mcp_proxy_adapter/api/openapi/command_integration.py +105 -0
- mcp_proxy_adapter/api/openapi/openapi_generator.py +40 -0
- mcp_proxy_adapter/api/openapi/openapi_registry.py +62 -0
- mcp_proxy_adapter/api/openapi/schema_loader.py +116 -0
- mcp_proxy_adapter/api/schemas.py +0 -61
- mcp_proxy_adapter/api/tool_integration.py +0 -117
- mcp_proxy_adapter/api/tools.py +0 -46
- mcp_proxy_adapter/cli/__init__.py +12 -0
- mcp_proxy_adapter/cli/commands/__init__.py +15 -0
- mcp_proxy_adapter/cli/commands/client.py +100 -0
- mcp_proxy_adapter/cli/commands/config_generate.py +21 -0
- mcp_proxy_adapter/cli/commands/config_validate.py +36 -0
- mcp_proxy_adapter/cli/commands/generate.py +259 -0
- mcp_proxy_adapter/cli/commands/server.py +174 -0
- mcp_proxy_adapter/cli/commands/sets.py +128 -0
- mcp_proxy_adapter/cli/commands/testconfig.py +177 -0
- mcp_proxy_adapter/cli/examples/__init__.py +8 -0
- mcp_proxy_adapter/cli/examples/http_basic.py +82 -0
- mcp_proxy_adapter/cli/examples/https_token.py +96 -0
- mcp_proxy_adapter/cli/examples/mtls_roles.py +103 -0
- mcp_proxy_adapter/cli/main.py +63 -0
- mcp_proxy_adapter/cli/parser.py +324 -0
- mcp_proxy_adapter/cli/validators.py +231 -0
- mcp_proxy_adapter/client/jsonrpc_client.py +406 -0
- mcp_proxy_adapter/client/proxy.py +45 -0
- mcp_proxy_adapter/commands/__init__.py +44 -28
- mcp_proxy_adapter/commands/auth_validation_command.py +7 -344
- mcp_proxy_adapter/commands/base.py +19 -43
- mcp_proxy_adapter/commands/builtin_commands.py +0 -75
- mcp_proxy_adapter/commands/catalog/__init__.py +20 -0
- mcp_proxy_adapter/commands/catalog/catalog_loader.py +34 -0
- mcp_proxy_adapter/commands/catalog/catalog_manager.py +122 -0
- mcp_proxy_adapter/commands/catalog/catalog_syncer.py +149 -0
- mcp_proxy_adapter/commands/catalog/command_catalog.py +43 -0
- mcp_proxy_adapter/commands/catalog/dependency_manager.py +37 -0
- mcp_proxy_adapter/commands/catalog_manager.py +58 -928
- mcp_proxy_adapter/commands/cert_monitor_command.py +0 -88
- mcp_proxy_adapter/commands/certificate_management_command.py +0 -45
- mcp_proxy_adapter/commands/command_registry.py +172 -904
- mcp_proxy_adapter/commands/config_command.py +0 -28
- mcp_proxy_adapter/commands/dependency_container.py +1 -70
- mcp_proxy_adapter/commands/dependency_manager.py +0 -128
- mcp_proxy_adapter/commands/echo_command.py +0 -34
- mcp_proxy_adapter/commands/health_command.py +0 -3
- mcp_proxy_adapter/commands/help_command.py +0 -159
- mcp_proxy_adapter/commands/hooks.py +0 -137
- mcp_proxy_adapter/commands/key_management_command.py +0 -25
- mcp_proxy_adapter/commands/load_command.py +7 -78
- mcp_proxy_adapter/commands/plugins_command.py +0 -16
- mcp_proxy_adapter/commands/protocol_management_command.py +0 -28
- mcp_proxy_adapter/commands/proxy_registration_command.py +0 -88
- mcp_proxy_adapter/commands/queue_commands.py +750 -0
- mcp_proxy_adapter/commands/registration_status_command.py +0 -43
- mcp_proxy_adapter/commands/registry/__init__.py +18 -0
- mcp_proxy_adapter/commands/registry/command_info.py +103 -0
- mcp_proxy_adapter/commands/registry/command_loader.py +207 -0
- mcp_proxy_adapter/commands/registry/command_manager.py +119 -0
- mcp_proxy_adapter/commands/registry/command_registry.py +217 -0
- mcp_proxy_adapter/commands/reload_command.py +0 -80
- mcp_proxy_adapter/commands/result.py +25 -77
- mcp_proxy_adapter/commands/role_test_command.py +0 -44
- mcp_proxy_adapter/commands/roles_management_command.py +0 -199
- mcp_proxy_adapter/commands/security_command.py +0 -30
- mcp_proxy_adapter/commands/settings_command.py +0 -68
- mcp_proxy_adapter/commands/ssl_setup_command.py +0 -42
- mcp_proxy_adapter/commands/token_management_command.py +0 -1
- mcp_proxy_adapter/commands/transport_management_command.py +0 -20
- mcp_proxy_adapter/commands/unload_command.py +0 -71
- mcp_proxy_adapter/config.py +15 -626
- mcp_proxy_adapter/core/__init__.py +5 -39
- mcp_proxy_adapter/core/app_factory.py +14 -36
- mcp_proxy_adapter/core/app_runner.py +0 -27
- mcp_proxy_adapter/core/auth_validator.py +1 -93
- mcp_proxy_adapter/core/certificate/__init__.py +20 -0
- mcp_proxy_adapter/core/certificate/certificate_creator.py +371 -0
- mcp_proxy_adapter/core/certificate/certificate_extractor.py +183 -0
- mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/certificate/certificate_validator.py +110 -0
- mcp_proxy_adapter/core/certificate/ssl_context_manager.py +70 -0
- mcp_proxy_adapter/core/certificate_utils.py +64 -903
- mcp_proxy_adapter/core/client.py +0 -6
- mcp_proxy_adapter/core/client_manager.py +0 -19
- mcp_proxy_adapter/core/client_security.py +0 -2
- mcp_proxy_adapter/core/config/__init__.py +18 -0
- mcp_proxy_adapter/core/config/config.py +195 -0
- mcp_proxy_adapter/core/config/config_factory.py +22 -0
- mcp_proxy_adapter/core/config/config_loader.py +66 -0
- mcp_proxy_adapter/core/config/feature_manager.py +31 -0
- mcp_proxy_adapter/core/config/simple_config.py +112 -0
- mcp_proxy_adapter/core/config/simple_config_generator.py +50 -0
- mcp_proxy_adapter/core/config/simple_config_validator.py +96 -0
- mcp_proxy_adapter/core/config_converter.py +0 -186
- mcp_proxy_adapter/core/config_validator.py +96 -1238
- mcp_proxy_adapter/core/errors.py +7 -42
- mcp_proxy_adapter/core/job_manager.py +54 -0
- mcp_proxy_adapter/core/logging.py +2 -22
- mcp_proxy_adapter/core/mtls_asgi.py +0 -20
- mcp_proxy_adapter/core/mtls_asgi_app.py +0 -12
- mcp_proxy_adapter/core/mtls_proxy.py +0 -80
- mcp_proxy_adapter/core/mtls_server.py +3 -173
- mcp_proxy_adapter/core/protocol_manager.py +1 -191
- mcp_proxy_adapter/core/proxy/__init__.py +22 -0
- mcp_proxy_adapter/core/proxy/auth_manager.py +27 -0
- mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +137 -0
- mcp_proxy_adapter/core/proxy/registration_client.py +60 -0
- mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
- mcp_proxy_adapter/core/proxy_client.py +0 -1
- mcp_proxy_adapter/core/proxy_registration.py +36 -912
- mcp_proxy_adapter/core/role_utils.py +0 -308
- mcp_proxy_adapter/core/security_adapter.py +1 -36
- mcp_proxy_adapter/core/security_factory.py +1 -150
- mcp_proxy_adapter/core/security_integration.py +0 -33
- mcp_proxy_adapter/core/server_adapter.py +1 -40
- mcp_proxy_adapter/core/server_engine.py +2 -173
- mcp_proxy_adapter/core/settings.py +0 -127
- mcp_proxy_adapter/core/signal_handler.py +0 -65
- mcp_proxy_adapter/core/ssl_utils.py +19 -137
- mcp_proxy_adapter/core/transport_manager.py +0 -151
- mcp_proxy_adapter/core/unified_config_adapter.py +1 -193
- mcp_proxy_adapter/core/utils.py +1 -182
- mcp_proxy_adapter/core/validation/__init__.py +21 -0
- mcp_proxy_adapter/core/validation/config_validator.py +211 -0
- mcp_proxy_adapter/core/validation/file_validator.py +73 -0
- mcp_proxy_adapter/core/validation/protocol_validator.py +191 -0
- mcp_proxy_adapter/core/validation/security_validator.py +58 -0
- mcp_proxy_adapter/core/validation/validation_result.py +27 -0
- mcp_proxy_adapter/custom_openapi.py +33 -652
- mcp_proxy_adapter/examples/bugfix_certificate_config.py +0 -23
- mcp_proxy_adapter/examples/check_config.py +0 -2
- mcp_proxy_adapter/examples/client_usage_example.py +164 -0
- mcp_proxy_adapter/examples/config_builder.py +13 -2
- mcp_proxy_adapter/examples/config_cli.py +0 -1
- mcp_proxy_adapter/examples/create_test_configs.py +0 -46
- mcp_proxy_adapter/examples/debug_request_state.py +0 -1
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +0 -47
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +0 -45
- mcp_proxy_adapter/examples/full_application/commands/echo_command.py +0 -12
- mcp_proxy_adapter/examples/full_application/commands/help_command.py +0 -12
- mcp_proxy_adapter/examples/full_application/commands/list_command.py +0 -7
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +0 -2
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +0 -59
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +0 -54
- mcp_proxy_adapter/examples/full_application/main.py +186 -150
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +0 -107
- mcp_proxy_adapter/examples/full_application/test_minimal_server.py +0 -24
- mcp_proxy_adapter/examples/full_application/test_server.py +0 -58
- mcp_proxy_adapter/examples/generate_config.py +65 -11
- mcp_proxy_adapter/examples/queue_demo_simple.py +632 -0
- mcp_proxy_adapter/examples/queue_integration_example.py +578 -0
- mcp_proxy_adapter/examples/queue_server_demo.py +82 -0
- mcp_proxy_adapter/examples/queue_server_example.py +85 -0
- mcp_proxy_adapter/examples/queue_server_simple.py +173 -0
- mcp_proxy_adapter/examples/required_certificates.py +0 -2
- mcp_proxy_adapter/examples/run_full_test_suite.py +0 -29
- mcp_proxy_adapter/examples/run_proxy_server.py +31 -71
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +0 -27
- mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
- mcp_proxy_adapter/examples/security_test/auth_manager.py +14 -0
- mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +28 -0
- mcp_proxy_adapter/examples/security_test/test_client.py +159 -0
- mcp_proxy_adapter/examples/security_test/test_result.py +22 -0
- mcp_proxy_adapter/examples/security_test_client.py +24 -1075
- mcp_proxy_adapter/examples/setup/__init__.py +24 -0
- mcp_proxy_adapter/examples/setup/certificate_manager.py +215 -0
- mcp_proxy_adapter/examples/setup/config_generator.py +12 -0
- mcp_proxy_adapter/examples/setup/config_validator.py +118 -0
- mcp_proxy_adapter/examples/setup/environment_setup.py +62 -0
- mcp_proxy_adapter/examples/setup/test_files_generator.py +10 -0
- mcp_proxy_adapter/examples/setup/test_runner.py +89 -0
- mcp_proxy_adapter/examples/setup_test_environment.py +133 -1425
- mcp_proxy_adapter/examples/test_config.py +0 -3
- mcp_proxy_adapter/examples/test_config_builder.py +25 -405
- mcp_proxy_adapter/examples/test_examples.py +0 -1
- mcp_proxy_adapter/examples/test_framework_complete.py +0 -2
- mcp_proxy_adapter/examples/test_mcp_server.py +0 -1
- mcp_proxy_adapter/examples/test_protocol_examples.py +0 -1
- mcp_proxy_adapter/examples/universal_client.py +0 -6
- mcp_proxy_adapter/examples/update_config_certificates.py +0 -1
- mcp_proxy_adapter/examples/validate_generator_compatibility.py +0 -1
- mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +0 -187
- mcp_proxy_adapter/integrations/__init__.py +25 -0
- mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
- mcp_proxy_adapter/main.py +70 -62
- mcp_proxy_adapter/openapi.py +0 -22
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.9.27.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/METADATA +2 -1
- mcp_proxy_adapter-6.9.29.dist-info/RECORD +235 -0
- {mcp_proxy_adapter-6.9.27.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/entry_points.txt +1 -1
- mcp_proxy_adapter-6.9.27.dist-info/RECORD +0 -149
- {mcp_proxy_adapter-6.9.27.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.9.27.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Main security test client for comprehensive testing.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import time
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from aiohttp import ClientSession, ClientTimeout, TCPConnector
|
|
12
|
+
|
|
13
|
+
from .test_result import TestResult
|
|
14
|
+
from .ssl_context_manager import SSLContextManager
|
|
15
|
+
from .auth_manager import AuthManager
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SecurityTestClient:
|
|
19
|
+
"""Security test client for comprehensive testing."""
|
|
20
|
+
|
|
21
|
+
def __init__(self, base_url: str = "http://localhost:8000"):
|
|
22
|
+
"""
|
|
23
|
+
Initialize security test client.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
base_url: Base URL for the server
|
|
27
|
+
"""
|
|
28
|
+
self.base_url = base_url
|
|
29
|
+
self.session: Optional[ClientSession] = None
|
|
30
|
+
self.test_results: List[TestResult] = []
|
|
31
|
+
|
|
32
|
+
# Initialize managers
|
|
33
|
+
project_root = Path(__file__).parent.parent.parent.parent
|
|
34
|
+
self.ssl_manager = SSLContextManager(project_root)
|
|
35
|
+
self.auth_manager = AuthManager()
|
|
36
|
+
|
|
37
|
+
async def __aenter__(self):
|
|
38
|
+
"""Async context manager entry."""
|
|
39
|
+
timeout = ClientTimeout(total=30)
|
|
40
|
+
# Create SSL context only for HTTPS URLs
|
|
41
|
+
if self.base_url.startswith('https://'):
|
|
42
|
+
# Check if this is mTLS (ports 20006, 20007, 20008 are mTLS test ports)
|
|
43
|
+
if any(port in self.base_url for port in ['20006', '20007', '20008']):
|
|
44
|
+
# Use mTLS context with client certificates
|
|
45
|
+
ssl_context = self.ssl_manager.create_ssl_context_for_mtls()
|
|
46
|
+
else:
|
|
47
|
+
# Use regular HTTPS context
|
|
48
|
+
ssl_context = self.ssl_manager.create_ssl_context()
|
|
49
|
+
connector = TCPConnector(ssl=ssl_context)
|
|
50
|
+
else:
|
|
51
|
+
# For HTTP URLs, use default connector without SSL
|
|
52
|
+
connector = TCPConnector()
|
|
53
|
+
|
|
54
|
+
# Create session
|
|
55
|
+
self.session = ClientSession(timeout=timeout, connector=connector)
|
|
56
|
+
return self
|
|
57
|
+
|
|
58
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
59
|
+
"""Async context manager exit."""
|
|
60
|
+
if self.session:
|
|
61
|
+
await self.session.close()
|
|
62
|
+
|
|
63
|
+
async def test_health_check(
|
|
64
|
+
self, server_url: str, auth_type: str = "none", **kwargs
|
|
65
|
+
) -> TestResult:
|
|
66
|
+
"""Test health check endpoint."""
|
|
67
|
+
start_time = time.time()
|
|
68
|
+
test_name = f"Health Check ({auth_type})"
|
|
69
|
+
try:
|
|
70
|
+
headers = self.auth_manager.create_auth_headers(auth_type, **kwargs)
|
|
71
|
+
async with self.session.get(
|
|
72
|
+
f"{server_url}/health", headers=headers
|
|
73
|
+
) as response:
|
|
74
|
+
duration = time.time() - start_time
|
|
75
|
+
if response.status == 200:
|
|
76
|
+
data = await response.json()
|
|
77
|
+
return TestResult(
|
|
78
|
+
test_name=test_name,
|
|
79
|
+
server_url=server_url,
|
|
80
|
+
auth_type=auth_type,
|
|
81
|
+
success=True,
|
|
82
|
+
status_code=response.status,
|
|
83
|
+
response_data=data,
|
|
84
|
+
duration=duration
|
|
85
|
+
)
|
|
86
|
+
else:
|
|
87
|
+
error_text = await response.text()
|
|
88
|
+
return TestResult(
|
|
89
|
+
test_name=test_name,
|
|
90
|
+
server_url=server_url,
|
|
91
|
+
auth_type=auth_type,
|
|
92
|
+
success=False,
|
|
93
|
+
status_code=response.status,
|
|
94
|
+
error_message=f"HTTP {response.status}: {error_text}",
|
|
95
|
+
duration=duration
|
|
96
|
+
)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
duration = time.time() - start_time
|
|
99
|
+
return TestResult(
|
|
100
|
+
test_name=test_name,
|
|
101
|
+
server_url=server_url,
|
|
102
|
+
auth_type=auth_type,
|
|
103
|
+
success=False,
|
|
104
|
+
error_message=str(e),
|
|
105
|
+
duration=duration
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
async def test_echo_command(
|
|
109
|
+
self, server_url: str, auth_type: str = "none", **kwargs
|
|
110
|
+
) -> TestResult:
|
|
111
|
+
"""Test echo command endpoint."""
|
|
112
|
+
start_time = time.time()
|
|
113
|
+
test_name = f"Echo Command ({auth_type})"
|
|
114
|
+
try:
|
|
115
|
+
headers = self.auth_manager.create_auth_headers(auth_type, **kwargs)
|
|
116
|
+
payload = {
|
|
117
|
+
"jsonrpc": "2.0",
|
|
118
|
+
"method": "echo",
|
|
119
|
+
"params": {"message": "Hello from security test client"},
|
|
120
|
+
"id": 1
|
|
121
|
+
}
|
|
122
|
+
async with self.session.post(
|
|
123
|
+
f"{server_url}/api/jsonrpc", json=payload, headers=headers
|
|
124
|
+
) as response:
|
|
125
|
+
duration = time.time() - start_time
|
|
126
|
+
if response.status == 200:
|
|
127
|
+
data = await response.json()
|
|
128
|
+
return TestResult(
|
|
129
|
+
test_name=test_name,
|
|
130
|
+
server_url=server_url,
|
|
131
|
+
auth_type=auth_type,
|
|
132
|
+
success=True,
|
|
133
|
+
status_code=response.status,
|
|
134
|
+
response_data=data,
|
|
135
|
+
duration=duration
|
|
136
|
+
)
|
|
137
|
+
else:
|
|
138
|
+
error_text = await response.text()
|
|
139
|
+
return TestResult(
|
|
140
|
+
test_name=test_name,
|
|
141
|
+
server_url=server_url,
|
|
142
|
+
auth_type=auth_type,
|
|
143
|
+
success=False,
|
|
144
|
+
status_code=response.status,
|
|
145
|
+
error_message=f"HTTP {response.status}: {error_text}",
|
|
146
|
+
duration=duration
|
|
147
|
+
)
|
|
148
|
+
except Exception as e:
|
|
149
|
+
duration = time.time() - start_time
|
|
150
|
+
return TestResult(
|
|
151
|
+
test_name=test_name,
|
|
152
|
+
server_url=server_url,
|
|
153
|
+
auth_type=auth_type,
|
|
154
|
+
success=False,
|
|
155
|
+
error_message=str(e),
|
|
156
|
+
duration=duration
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Test result data class for security testing.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from typing import Dict, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass
|
|
13
|
+
class TestResult:
|
|
14
|
+
"""Test result data class."""
|
|
15
|
+
test_name: str
|
|
16
|
+
server_url: str
|
|
17
|
+
auth_type: str
|
|
18
|
+
success: bool
|
|
19
|
+
status_code: Optional[int] = None
|
|
20
|
+
response_data: Optional[Dict] = None
|
|
21
|
+
error_message: Optional[str] = None
|
|
22
|
+
duration: float = 0.0
|