mcp-proxy-adapter 6.3.3__py3-none-any.whl → 6.3.5__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/__init__.py +9 -5
- mcp_proxy_adapter/__main__.py +1 -1
- mcp_proxy_adapter/api/app.py +227 -176
- mcp_proxy_adapter/api/handlers.py +68 -60
- mcp_proxy_adapter/api/middleware/__init__.py +7 -5
- mcp_proxy_adapter/api/middleware/base.py +19 -16
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +44 -34
- mcp_proxy_adapter/api/middleware/error_handling.py +57 -67
- mcp_proxy_adapter/api/middleware/factory.py +50 -52
- mcp_proxy_adapter/api/middleware/logging.py +46 -30
- mcp_proxy_adapter/api/middleware/performance.py +19 -16
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +80 -50
- mcp_proxy_adapter/api/middleware/transport_middleware.py +26 -24
- mcp_proxy_adapter/api/middleware/unified_security.py +70 -51
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +43 -34
- mcp_proxy_adapter/api/schemas.py +69 -43
- mcp_proxy_adapter/api/tool_integration.py +83 -63
- mcp_proxy_adapter/api/tools.py +60 -50
- mcp_proxy_adapter/commands/__init__.py +15 -6
- mcp_proxy_adapter/commands/auth_validation_command.py +107 -110
- mcp_proxy_adapter/commands/base.py +108 -112
- mcp_proxy_adapter/commands/builtin_commands.py +28 -18
- mcp_proxy_adapter/commands/catalog_manager.py +394 -265
- mcp_proxy_adapter/commands/cert_monitor_command.py +222 -204
- mcp_proxy_adapter/commands/certificate_management_command.py +210 -213
- mcp_proxy_adapter/commands/command_registry.py +275 -226
- mcp_proxy_adapter/commands/config_command.py +48 -33
- mcp_proxy_adapter/commands/dependency_container.py +22 -23
- mcp_proxy_adapter/commands/dependency_manager.py +65 -56
- mcp_proxy_adapter/commands/echo_command.py +15 -15
- mcp_proxy_adapter/commands/health_command.py +31 -29
- mcp_proxy_adapter/commands/help_command.py +97 -61
- mcp_proxy_adapter/commands/hooks.py +65 -49
- mcp_proxy_adapter/commands/key_management_command.py +148 -147
- mcp_proxy_adapter/commands/load_command.py +58 -40
- mcp_proxy_adapter/commands/plugins_command.py +80 -54
- mcp_proxy_adapter/commands/protocol_management_command.py +60 -48
- mcp_proxy_adapter/commands/proxy_registration_command.py +107 -115
- mcp_proxy_adapter/commands/reload_command.py +43 -37
- mcp_proxy_adapter/commands/result.py +26 -33
- mcp_proxy_adapter/commands/role_test_command.py +26 -26
- mcp_proxy_adapter/commands/roles_management_command.py +176 -173
- mcp_proxy_adapter/commands/security_command.py +134 -122
- mcp_proxy_adapter/commands/settings_command.py +47 -56
- mcp_proxy_adapter/commands/ssl_setup_command.py +109 -129
- mcp_proxy_adapter/commands/token_management_command.py +129 -158
- mcp_proxy_adapter/commands/transport_management_command.py +41 -36
- mcp_proxy_adapter/commands/unload_command.py +42 -37
- mcp_proxy_adapter/config.py +36 -35
- mcp_proxy_adapter/core/__init__.py +19 -21
- mcp_proxy_adapter/core/app_factory.py +30 -9
- mcp_proxy_adapter/core/app_runner.py +81 -64
- mcp_proxy_adapter/core/auth_validator.py +176 -182
- mcp_proxy_adapter/core/certificate_utils.py +469 -426
- mcp_proxy_adapter/core/client.py +155 -126
- mcp_proxy_adapter/core/client_manager.py +60 -54
- mcp_proxy_adapter/core/client_security.py +108 -88
- mcp_proxy_adapter/core/config_converter.py +176 -143
- mcp_proxy_adapter/core/config_validator.py +12 -4
- mcp_proxy_adapter/core/crl_utils.py +21 -7
- mcp_proxy_adapter/core/errors.py +64 -20
- mcp_proxy_adapter/core/logging.py +34 -29
- mcp_proxy_adapter/core/mtls_asgi.py +29 -25
- mcp_proxy_adapter/core/mtls_asgi_app.py +66 -54
- mcp_proxy_adapter/core/protocol_manager.py +154 -104
- mcp_proxy_adapter/core/proxy_client.py +202 -144
- mcp_proxy_adapter/core/proxy_registration.py +12 -2
- mcp_proxy_adapter/core/role_utils.py +139 -125
- mcp_proxy_adapter/core/security_adapter.py +88 -77
- mcp_proxy_adapter/core/security_factory.py +50 -44
- mcp_proxy_adapter/core/security_integration.py +72 -24
- mcp_proxy_adapter/core/server_adapter.py +68 -64
- mcp_proxy_adapter/core/server_engine.py +71 -53
- mcp_proxy_adapter/core/settings.py +68 -58
- mcp_proxy_adapter/core/ssl_utils.py +69 -56
- mcp_proxy_adapter/core/transport_manager.py +72 -60
- mcp_proxy_adapter/core/unified_config_adapter.py +201 -150
- mcp_proxy_adapter/core/utils.py +4 -2
- mcp_proxy_adapter/custom_openapi.py +107 -99
- mcp_proxy_adapter/examples/basic_framework/main.py +9 -2
- mcp_proxy_adapter/examples/commands/__init__.py +1 -1
- mcp_proxy_adapter/examples/create_certificates_simple.py +182 -71
- mcp_proxy_adapter/examples/debug_request_state.py +38 -19
- mcp_proxy_adapter/examples/debug_role_chain.py +53 -20
- mcp_proxy_adapter/examples/demo_client.py +48 -36
- mcp_proxy_adapter/examples/examples/basic_framework/main.py +9 -2
- mcp_proxy_adapter/examples/examples/full_application/__init__.py +1 -0
- mcp_proxy_adapter/examples/examples/full_application/commands/custom_echo_command.py +22 -10
- mcp_proxy_adapter/examples/examples/full_application/commands/dynamic_calculator_command.py +24 -17
- mcp_proxy_adapter/examples/examples/full_application/hooks/application_hooks.py +16 -3
- mcp_proxy_adapter/examples/examples/full_application/hooks/builtin_command_hooks.py +13 -3
- mcp_proxy_adapter/examples/examples/full_application/main.py +27 -2
- mcp_proxy_adapter/examples/examples/full_application/proxy_endpoints.py +48 -14
- mcp_proxy_adapter/examples/full_application/__init__.py +1 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +22 -10
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +24 -17
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +16 -3
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +13 -3
- mcp_proxy_adapter/examples/full_application/main.py +27 -2
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +48 -14
- mcp_proxy_adapter/examples/generate_all_certificates.py +198 -73
- mcp_proxy_adapter/examples/generate_certificates.py +31 -16
- mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +220 -74
- mcp_proxy_adapter/examples/generate_test_configs.py +68 -91
- mcp_proxy_adapter/examples/proxy_registration_example.py +76 -75
- mcp_proxy_adapter/examples/run_example.py +23 -5
- mcp_proxy_adapter/examples/run_full_test_suite.py +109 -71
- mcp_proxy_adapter/examples/run_proxy_server.py +22 -9
- mcp_proxy_adapter/examples/run_security_tests.py +103 -41
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +72 -36
- mcp_proxy_adapter/examples/scripts/config_generator.py +288 -187
- mcp_proxy_adapter/examples/scripts/create_certificates_simple.py +185 -72
- mcp_proxy_adapter/examples/scripts/generate_certificates_and_tokens.py +220 -74
- mcp_proxy_adapter/examples/security_test_client.py +196 -127
- mcp_proxy_adapter/examples/setup_test_environment.py +17 -29
- mcp_proxy_adapter/examples/test_config.py +19 -4
- mcp_proxy_adapter/examples/test_config_generator.py +23 -7
- mcp_proxy_adapter/examples/test_examples.py +84 -56
- mcp_proxy_adapter/examples/universal_client.py +119 -62
- mcp_proxy_adapter/openapi.py +108 -115
- mcp_proxy_adapter/utils/config_generator.py +429 -274
- mcp_proxy_adapter/version.py +1 -2
- {mcp_proxy_adapter-6.3.3.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/METADATA +1 -1
- mcp_proxy_adapter-6.3.5.dist-info/RECORD +143 -0
- mcp_proxy_adapter-6.3.3.dist-info/RECORD +0 -143
- {mcp_proxy_adapter-6.3.3.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.3.3.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.3.3.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.3.3.dist-info → mcp_proxy_adapter-6.3.5.dist-info}/top_level.txt +0 -0
@@ -17,6 +17,7 @@ from mcp_proxy_adapter.core.logging import logger
|
|
17
17
|
@dataclass
|
18
18
|
class ProtocolInfo:
|
19
19
|
"""Protocol information data class."""
|
20
|
+
|
20
21
|
name: str
|
21
22
|
enabled: bool
|
22
23
|
allowed: bool
|
@@ -28,6 +29,7 @@ class ProtocolInfo:
|
|
28
29
|
@dataclass
|
29
30
|
class ProtocolManagementResult:
|
30
31
|
"""Result data for protocol management operations."""
|
32
|
+
|
31
33
|
protocols: Dict[str, Dict[str, Any]]
|
32
34
|
allowed_protocols: List[str]
|
33
35
|
validation_errors: List[str]
|
@@ -38,22 +40,22 @@ class ProtocolManagementResult:
|
|
38
40
|
class ProtocolManagementCommand(Command):
|
39
41
|
"""
|
40
42
|
Command for managing and querying protocol configurations.
|
41
|
-
|
43
|
+
|
42
44
|
This command provides functionality to:
|
43
45
|
- Get information about all configured protocols
|
44
46
|
- Check protocol validation status
|
45
47
|
- Get allowed protocols list
|
46
48
|
- Validate protocol configurations
|
47
49
|
"""
|
48
|
-
|
50
|
+
|
49
51
|
name = "protocol_management"
|
50
52
|
descr = "Manage and query protocol configurations (HTTP, HTTPS, MTLS)"
|
51
|
-
|
53
|
+
|
52
54
|
@classmethod
|
53
55
|
def get_schema(cls) -> Dict[str, Any]:
|
54
56
|
"""
|
55
57
|
Get command schema.
|
56
|
-
|
58
|
+
|
57
59
|
Returns:
|
58
60
|
Command schema dictionary
|
59
61
|
"""
|
@@ -62,32 +64,37 @@ class ProtocolManagementCommand(Command):
|
|
62
64
|
"properties": {
|
63
65
|
"action": {
|
64
66
|
"type": "string",
|
65
|
-
"enum": [
|
66
|
-
|
67
|
+
"enum": [
|
68
|
+
"get_info",
|
69
|
+
"validate_config",
|
70
|
+
"get_allowed",
|
71
|
+
"check_protocol",
|
72
|
+
],
|
73
|
+
"description": "Action to perform",
|
67
74
|
},
|
68
75
|
"protocol": {
|
69
76
|
"type": "string",
|
70
77
|
"enum": ["http", "https", "mtls"],
|
71
|
-
"description": "Protocol to check (for check_protocol action)"
|
72
|
-
}
|
78
|
+
"description": "Protocol to check (for check_protocol action)",
|
79
|
+
},
|
73
80
|
},
|
74
|
-
"required": ["action"]
|
81
|
+
"required": ["action"],
|
75
82
|
}
|
76
|
-
|
83
|
+
|
77
84
|
async def execute(self, **kwargs) -> SuccessResult | ErrorResult:
|
78
85
|
"""
|
79
86
|
Execute protocol management command.
|
80
|
-
|
87
|
+
|
81
88
|
Args:
|
82
89
|
action: Action to perform (get_info, validate_config, get_allowed, check_protocol)
|
83
90
|
protocol: Protocol name for check_protocol action
|
84
|
-
|
91
|
+
|
85
92
|
Returns:
|
86
93
|
Command execution result
|
87
94
|
"""
|
88
95
|
try:
|
89
96
|
action = kwargs.get("action")
|
90
|
-
|
97
|
+
|
91
98
|
if action == "get_info":
|
92
99
|
return await self._get_protocol_info()
|
93
100
|
elif action == "validate_config":
|
@@ -97,19 +104,21 @@ class ProtocolManagementCommand(Command):
|
|
97
104
|
elif action == "check_protocol":
|
98
105
|
protocol = kwargs.get("protocol")
|
99
106
|
if not protocol:
|
100
|
-
return ErrorResult(
|
107
|
+
return ErrorResult(
|
108
|
+
"Protocol parameter required for check_protocol action"
|
109
|
+
)
|
101
110
|
return await self._check_protocol(protocol)
|
102
111
|
else:
|
103
112
|
return ErrorResult(f"Unknown action: {action}")
|
104
|
-
|
113
|
+
|
105
114
|
except Exception as e:
|
106
115
|
logger.error(f"Protocol management command error: {e}")
|
107
116
|
return ErrorResult(f"Protocol management error: {str(e)}")
|
108
|
-
|
117
|
+
|
109
118
|
async def _get_protocol_info(self) -> SuccessResult:
|
110
119
|
"""
|
111
120
|
Get information about all protocols.
|
112
|
-
|
121
|
+
|
113
122
|
Returns:
|
114
123
|
Success result with protocol information
|
115
124
|
"""
|
@@ -117,17 +126,17 @@ class ProtocolManagementCommand(Command):
|
|
117
126
|
protocol_info = protocol_manager.get_protocol_info()
|
118
127
|
allowed_protocols = protocol_manager.get_allowed_protocols()
|
119
128
|
validation_errors = protocol_manager.validate_protocol_configuration()
|
120
|
-
|
129
|
+
|
121
130
|
enabled_count = sum(1 for info in protocol_info.values() if info["enabled"])
|
122
|
-
|
131
|
+
|
123
132
|
result_data = ProtocolManagementResult(
|
124
133
|
protocols=protocol_info,
|
125
134
|
allowed_protocols=allowed_protocols,
|
126
135
|
validation_errors=validation_errors,
|
127
136
|
total_protocols=len(protocol_info),
|
128
|
-
enabled_protocols=enabled_count
|
137
|
+
enabled_protocols=enabled_count,
|
129
138
|
)
|
130
|
-
|
139
|
+
|
131
140
|
return SuccessResult(
|
132
141
|
data={
|
133
142
|
"protocol_info": result_data.protocols,
|
@@ -135,85 +144,88 @@ class ProtocolManagementCommand(Command):
|
|
135
144
|
"validation_errors": result_data.validation_errors,
|
136
145
|
"total_protocols": result_data.total_protocols,
|
137
146
|
"enabled_protocols": result_data.enabled_protocols,
|
138
|
-
"protocols_enabled": protocol_manager.enabled
|
147
|
+
"protocols_enabled": protocol_manager.enabled,
|
139
148
|
},
|
140
|
-
message="Protocol information retrieved successfully"
|
149
|
+
message="Protocol information retrieved successfully",
|
141
150
|
)
|
142
|
-
|
151
|
+
|
143
152
|
except Exception as e:
|
144
153
|
logger.error(f"Error getting protocol info: {e}")
|
145
154
|
return ErrorResult(f"Failed to get protocol info: {str(e)}")
|
146
|
-
|
155
|
+
|
147
156
|
async def _validate_configuration(self) -> SuccessResult:
|
148
157
|
"""
|
149
158
|
Validate protocol configuration.
|
150
|
-
|
159
|
+
|
151
160
|
Returns:
|
152
161
|
Success result with validation results
|
153
162
|
"""
|
154
163
|
try:
|
155
164
|
validation_errors = protocol_manager.validate_protocol_configuration()
|
156
165
|
is_valid = len(validation_errors) == 0
|
157
|
-
|
166
|
+
|
158
167
|
return SuccessResult(
|
159
168
|
data={
|
160
169
|
"is_valid": is_valid,
|
161
170
|
"validation_errors": validation_errors,
|
162
|
-
"error_count": len(validation_errors)
|
171
|
+
"error_count": len(validation_errors),
|
163
172
|
},
|
164
|
-
message=f"Configuration validation {'passed' if is_valid else 'failed'}"
|
173
|
+
message=f"Configuration validation {'passed' if is_valid else 'failed'}",
|
165
174
|
)
|
166
|
-
|
175
|
+
|
167
176
|
except Exception as e:
|
168
177
|
logger.error(f"Error validating configuration: {e}")
|
169
178
|
return ErrorResult(f"Failed to validate configuration: {str(e)}")
|
170
|
-
|
179
|
+
|
171
180
|
async def _get_allowed_protocols(self) -> SuccessResult:
|
172
181
|
"""
|
173
182
|
Get list of allowed protocols.
|
174
|
-
|
183
|
+
|
175
184
|
Returns:
|
176
185
|
Success result with allowed protocols
|
177
186
|
"""
|
178
187
|
try:
|
179
188
|
allowed_protocols = protocol_manager.get_allowed_protocols()
|
180
|
-
|
189
|
+
|
181
190
|
return SuccessResult(
|
182
191
|
data={
|
183
192
|
"allowed_protocols": allowed_protocols,
|
184
|
-
"count": len(allowed_protocols)
|
193
|
+
"count": len(allowed_protocols),
|
185
194
|
},
|
186
|
-
message="Allowed protocols retrieved successfully"
|
195
|
+
message="Allowed protocols retrieved successfully",
|
187
196
|
)
|
188
|
-
|
197
|
+
|
189
198
|
except Exception as e:
|
190
199
|
logger.error(f"Error getting allowed protocols: {e}")
|
191
200
|
return ErrorResult(f"Failed to get allowed protocols: {str(e)}")
|
192
|
-
|
201
|
+
|
193
202
|
async def _check_protocol(self, protocol: str) -> SuccessResult:
|
194
203
|
"""
|
195
204
|
Check specific protocol configuration.
|
196
|
-
|
205
|
+
|
197
206
|
Args:
|
198
207
|
protocol: Protocol name to check
|
199
|
-
|
208
|
+
|
200
209
|
Returns:
|
201
210
|
Success result with protocol check results
|
202
211
|
"""
|
203
212
|
try:
|
204
213
|
protocol_lower = protocol.lower()
|
205
|
-
|
214
|
+
|
206
215
|
if protocol_lower not in ["http", "https", "mtls"]:
|
207
216
|
return ErrorResult(f"Unknown protocol: {protocol}")
|
208
|
-
|
217
|
+
|
209
218
|
is_allowed = protocol_manager.is_protocol_allowed(protocol_lower)
|
210
219
|
port = protocol_manager.get_protocol_port(protocol_lower)
|
211
220
|
config = protocol_manager.get_protocol_config(protocol_lower)
|
212
|
-
|
221
|
+
|
213
222
|
ssl_context_available = None
|
214
223
|
if protocol_lower in ["https", "mtls"]:
|
215
|
-
ssl_context_available =
|
216
|
-
|
224
|
+
ssl_context_available = (
|
225
|
+
protocol_manager.get_ssl_context_for_protocol(protocol_lower)
|
226
|
+
is not None
|
227
|
+
)
|
228
|
+
|
217
229
|
return SuccessResult(
|
218
230
|
data={
|
219
231
|
"protocol": protocol_lower,
|
@@ -222,11 +234,11 @@ class ProtocolManagementCommand(Command):
|
|
222
234
|
"enabled": config.get("enabled", False),
|
223
235
|
"requires_ssl": protocol_lower in ["https", "mtls"],
|
224
236
|
"ssl_context_available": ssl_context_available,
|
225
|
-
"configuration": config
|
237
|
+
"configuration": config,
|
226
238
|
},
|
227
|
-
message=f"Protocol '{protocol}' check completed"
|
239
|
+
message=f"Protocol '{protocol}' check completed",
|
228
240
|
)
|
229
|
-
|
241
|
+
|
230
242
|
except Exception as e:
|
231
243
|
logger.error(f"Error checking protocol {protocol}: {e}")
|
232
|
-
return ErrorResult(f"Failed to check protocol {protocol}: {str(e)}")
|
244
|
+
return ErrorResult(f"Failed to check protocol {protocol}: {str(e)}")
|