mcp-proxy-adapter 6.9.28__py3-none-any.whl → 6.9.30__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.

Files changed (212) hide show
  1. mcp_proxy_adapter/__init__.py +10 -0
  2. mcp_proxy_adapter/__main__.py +8 -21
  3. mcp_proxy_adapter/api/app.py +10 -913
  4. mcp_proxy_adapter/api/core/__init__.py +18 -0
  5. mcp_proxy_adapter/api/core/app_factory.py +243 -0
  6. mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
  7. mcp_proxy_adapter/api/core/registration_manager.py +166 -0
  8. mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
  9. mcp_proxy_adapter/api/handlers.py +78 -199
  10. mcp_proxy_adapter/api/middleware/__init__.py +1 -44
  11. mcp_proxy_adapter/api/middleware/base.py +0 -42
  12. mcp_proxy_adapter/api/middleware/command_permission_middleware.py +0 -85
  13. mcp_proxy_adapter/api/middleware/error_handling.py +1 -127
  14. mcp_proxy_adapter/api/middleware/factory.py +0 -94
  15. mcp_proxy_adapter/api/middleware/logging.py +0 -112
  16. mcp_proxy_adapter/api/middleware/performance.py +0 -35
  17. mcp_proxy_adapter/api/middleware/protocol_middleware.py +2 -98
  18. mcp_proxy_adapter/api/middleware/transport_middleware.py +0 -37
  19. mcp_proxy_adapter/api/middleware/unified_security.py +10 -10
  20. mcp_proxy_adapter/api/middleware/user_info_middleware.py +0 -118
  21. mcp_proxy_adapter/api/openapi/__init__.py +21 -0
  22. mcp_proxy_adapter/api/openapi/command_integration.py +105 -0
  23. mcp_proxy_adapter/api/openapi/openapi_generator.py +40 -0
  24. mcp_proxy_adapter/api/openapi/openapi_registry.py +62 -0
  25. mcp_proxy_adapter/api/openapi/schema_loader.py +116 -0
  26. mcp_proxy_adapter/api/schemas.py +0 -61
  27. mcp_proxy_adapter/api/tool_integration.py +0 -117
  28. mcp_proxy_adapter/api/tools.py +0 -46
  29. mcp_proxy_adapter/cli/__init__.py +12 -0
  30. mcp_proxy_adapter/cli/commands/__init__.py +15 -0
  31. mcp_proxy_adapter/cli/commands/client.py +100 -0
  32. mcp_proxy_adapter/cli/commands/config_generate.py +21 -0
  33. mcp_proxy_adapter/cli/commands/config_validate.py +36 -0
  34. mcp_proxy_adapter/cli/commands/generate.py +259 -0
  35. mcp_proxy_adapter/cli/commands/server.py +174 -0
  36. mcp_proxy_adapter/cli/commands/sets.py +128 -0
  37. mcp_proxy_adapter/cli/commands/testconfig.py +177 -0
  38. mcp_proxy_adapter/cli/examples/__init__.py +8 -0
  39. mcp_proxy_adapter/cli/examples/http_basic.py +82 -0
  40. mcp_proxy_adapter/cli/examples/https_token.py +96 -0
  41. mcp_proxy_adapter/cli/examples/mtls_roles.py +103 -0
  42. mcp_proxy_adapter/cli/main.py +63 -0
  43. mcp_proxy_adapter/cli/parser.py +324 -0
  44. mcp_proxy_adapter/cli/validators.py +231 -0
  45. mcp_proxy_adapter/client/jsonrpc_client.py +406 -0
  46. mcp_proxy_adapter/client/proxy.py +45 -0
  47. mcp_proxy_adapter/commands/__init__.py +44 -28
  48. mcp_proxy_adapter/commands/auth_validation_command.py +7 -344
  49. mcp_proxy_adapter/commands/base.py +19 -43
  50. mcp_proxy_adapter/commands/builtin_commands.py +0 -75
  51. mcp_proxy_adapter/commands/catalog/__init__.py +20 -0
  52. mcp_proxy_adapter/commands/catalog/catalog_loader.py +34 -0
  53. mcp_proxy_adapter/commands/catalog/catalog_manager.py +122 -0
  54. mcp_proxy_adapter/commands/catalog/catalog_syncer.py +149 -0
  55. mcp_proxy_adapter/commands/catalog/command_catalog.py +43 -0
  56. mcp_proxy_adapter/commands/catalog/dependency_manager.py +37 -0
  57. mcp_proxy_adapter/commands/catalog_manager.py +58 -928
  58. mcp_proxy_adapter/commands/cert_monitor_command.py +0 -88
  59. mcp_proxy_adapter/commands/certificate_management_command.py +0 -45
  60. mcp_proxy_adapter/commands/command_registry.py +172 -904
  61. mcp_proxy_adapter/commands/config_command.py +0 -28
  62. mcp_proxy_adapter/commands/dependency_container.py +1 -70
  63. mcp_proxy_adapter/commands/dependency_manager.py +0 -128
  64. mcp_proxy_adapter/commands/echo_command.py +0 -34
  65. mcp_proxy_adapter/commands/health_command.py +0 -3
  66. mcp_proxy_adapter/commands/help_command.py +0 -159
  67. mcp_proxy_adapter/commands/hooks.py +0 -137
  68. mcp_proxy_adapter/commands/key_management_command.py +0 -25
  69. mcp_proxy_adapter/commands/load_command.py +7 -78
  70. mcp_proxy_adapter/commands/plugins_command.py +0 -16
  71. mcp_proxy_adapter/commands/protocol_management_command.py +0 -28
  72. mcp_proxy_adapter/commands/proxy_registration_command.py +0 -88
  73. mcp_proxy_adapter/commands/queue_commands.py +750 -0
  74. mcp_proxy_adapter/commands/registration_status_command.py +0 -43
  75. mcp_proxy_adapter/commands/registry/__init__.py +18 -0
  76. mcp_proxy_adapter/commands/registry/command_info.py +103 -0
  77. mcp_proxy_adapter/commands/registry/command_loader.py +207 -0
  78. mcp_proxy_adapter/commands/registry/command_manager.py +119 -0
  79. mcp_proxy_adapter/commands/registry/command_registry.py +217 -0
  80. mcp_proxy_adapter/commands/reload_command.py +0 -80
  81. mcp_proxy_adapter/commands/result.py +25 -77
  82. mcp_proxy_adapter/commands/role_test_command.py +0 -44
  83. mcp_proxy_adapter/commands/roles_management_command.py +0 -199
  84. mcp_proxy_adapter/commands/security_command.py +0 -30
  85. mcp_proxy_adapter/commands/settings_command.py +0 -68
  86. mcp_proxy_adapter/commands/ssl_setup_command.py +0 -42
  87. mcp_proxy_adapter/commands/token_management_command.py +0 -1
  88. mcp_proxy_adapter/commands/transport_management_command.py +0 -20
  89. mcp_proxy_adapter/commands/unload_command.py +0 -71
  90. mcp_proxy_adapter/config.py +15 -626
  91. mcp_proxy_adapter/core/__init__.py +5 -39
  92. mcp_proxy_adapter/core/app_factory.py +14 -36
  93. mcp_proxy_adapter/core/app_runner.py +0 -27
  94. mcp_proxy_adapter/core/auth_validator.py +1 -93
  95. mcp_proxy_adapter/core/certificate/__init__.py +20 -0
  96. mcp_proxy_adapter/core/certificate/certificate_creator.py +371 -0
  97. mcp_proxy_adapter/core/certificate/certificate_extractor.py +183 -0
  98. mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
  99. mcp_proxy_adapter/core/certificate/certificate_validator.py +110 -0
  100. mcp_proxy_adapter/core/certificate/ssl_context_manager.py +70 -0
  101. mcp_proxy_adapter/core/certificate_utils.py +64 -903
  102. mcp_proxy_adapter/core/client.py +10 -9
  103. mcp_proxy_adapter/core/client_manager.py +0 -19
  104. mcp_proxy_adapter/core/client_security.py +0 -2
  105. mcp_proxy_adapter/core/config/__init__.py +18 -0
  106. mcp_proxy_adapter/core/config/config.py +195 -0
  107. mcp_proxy_adapter/core/config/config_factory.py +22 -0
  108. mcp_proxy_adapter/core/config/config_loader.py +66 -0
  109. mcp_proxy_adapter/core/config/feature_manager.py +31 -0
  110. mcp_proxy_adapter/core/config/simple_config.py +112 -0
  111. mcp_proxy_adapter/core/config/simple_config_generator.py +50 -0
  112. mcp_proxy_adapter/core/config/simple_config_validator.py +96 -0
  113. mcp_proxy_adapter/core/config_converter.py +0 -186
  114. mcp_proxy_adapter/core/config_validator.py +96 -1238
  115. mcp_proxy_adapter/core/errors.py +7 -42
  116. mcp_proxy_adapter/core/job_manager.py +54 -0
  117. mcp_proxy_adapter/core/logging.py +2 -22
  118. mcp_proxy_adapter/core/mtls_asgi.py +0 -20
  119. mcp_proxy_adapter/core/mtls_asgi_app.py +0 -12
  120. mcp_proxy_adapter/core/mtls_proxy.py +0 -80
  121. mcp_proxy_adapter/core/mtls_server.py +3 -173
  122. mcp_proxy_adapter/core/protocol_manager.py +1 -191
  123. mcp_proxy_adapter/core/proxy/__init__.py +22 -0
  124. mcp_proxy_adapter/core/proxy/auth_manager.py +27 -0
  125. mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +137 -0
  126. mcp_proxy_adapter/core/proxy/registration_client.py +60 -0
  127. mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
  128. mcp_proxy_adapter/core/proxy_client.py +0 -1
  129. mcp_proxy_adapter/core/proxy_registration.py +36 -913
  130. mcp_proxy_adapter/core/role_utils.py +0 -308
  131. mcp_proxy_adapter/core/security_adapter.py +1 -36
  132. mcp_proxy_adapter/core/security_factory.py +1 -150
  133. mcp_proxy_adapter/core/security_integration.py +0 -33
  134. mcp_proxy_adapter/core/server_adapter.py +1 -40
  135. mcp_proxy_adapter/core/server_engine.py +2 -173
  136. mcp_proxy_adapter/core/settings.py +0 -127
  137. mcp_proxy_adapter/core/signal_handler.py +0 -65
  138. mcp_proxy_adapter/core/ssl_utils.py +19 -137
  139. mcp_proxy_adapter/core/transport_manager.py +0 -151
  140. mcp_proxy_adapter/core/unified_config_adapter.py +1 -193
  141. mcp_proxy_adapter/core/utils.py +1 -182
  142. mcp_proxy_adapter/core/validation/__init__.py +21 -0
  143. mcp_proxy_adapter/core/validation/config_validator.py +211 -0
  144. mcp_proxy_adapter/core/validation/file_validator.py +73 -0
  145. mcp_proxy_adapter/core/validation/protocol_validator.py +191 -0
  146. mcp_proxy_adapter/core/validation/security_validator.py +58 -0
  147. mcp_proxy_adapter/core/validation/validation_result.py +27 -0
  148. mcp_proxy_adapter/custom_openapi.py +33 -652
  149. mcp_proxy_adapter/examples/bugfix_certificate_config.py +0 -23
  150. mcp_proxy_adapter/examples/check_config.py +0 -2
  151. mcp_proxy_adapter/examples/client_usage_example.py +164 -0
  152. mcp_proxy_adapter/examples/config_builder.py +13 -2
  153. mcp_proxy_adapter/examples/config_cli.py +0 -1
  154. mcp_proxy_adapter/examples/create_test_configs.py +0 -46
  155. mcp_proxy_adapter/examples/debug_request_state.py +0 -1
  156. mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +0 -47
  157. mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +0 -45
  158. mcp_proxy_adapter/examples/full_application/commands/echo_command.py +0 -12
  159. mcp_proxy_adapter/examples/full_application/commands/help_command.py +0 -12
  160. mcp_proxy_adapter/examples/full_application/commands/list_command.py +0 -7
  161. mcp_proxy_adapter/examples/full_application/hooks/__init__.py +0 -2
  162. mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +0 -59
  163. mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +0 -54
  164. mcp_proxy_adapter/examples/full_application/main.py +186 -150
  165. mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +0 -107
  166. mcp_proxy_adapter/examples/full_application/test_minimal_server.py +0 -24
  167. mcp_proxy_adapter/examples/full_application/test_server.py +0 -58
  168. mcp_proxy_adapter/examples/generate_config.py +65 -11
  169. mcp_proxy_adapter/examples/queue_demo_simple.py +632 -0
  170. mcp_proxy_adapter/examples/queue_integration_example.py +578 -0
  171. mcp_proxy_adapter/examples/queue_server_demo.py +82 -0
  172. mcp_proxy_adapter/examples/queue_server_example.py +85 -0
  173. mcp_proxy_adapter/examples/queue_server_simple.py +173 -0
  174. mcp_proxy_adapter/examples/required_certificates.py +0 -2
  175. mcp_proxy_adapter/examples/run_full_test_suite.py +0 -29
  176. mcp_proxy_adapter/examples/run_proxy_server.py +31 -71
  177. mcp_proxy_adapter/examples/run_security_tests_fixed.py +0 -27
  178. mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
  179. mcp_proxy_adapter/examples/security_test/auth_manager.py +14 -0
  180. mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +28 -0
  181. mcp_proxy_adapter/examples/security_test/test_client.py +159 -0
  182. mcp_proxy_adapter/examples/security_test/test_result.py +22 -0
  183. mcp_proxy_adapter/examples/security_test_client.py +24 -1075
  184. mcp_proxy_adapter/examples/setup/__init__.py +24 -0
  185. mcp_proxy_adapter/examples/setup/certificate_manager.py +215 -0
  186. mcp_proxy_adapter/examples/setup/config_generator.py +12 -0
  187. mcp_proxy_adapter/examples/setup/config_validator.py +118 -0
  188. mcp_proxy_adapter/examples/setup/environment_setup.py +62 -0
  189. mcp_proxy_adapter/examples/setup/test_files_generator.py +10 -0
  190. mcp_proxy_adapter/examples/setup/test_runner.py +89 -0
  191. mcp_proxy_adapter/examples/setup_test_environment.py +133 -1425
  192. mcp_proxy_adapter/examples/test_config.py +0 -3
  193. mcp_proxy_adapter/examples/test_config_builder.py +25 -405
  194. mcp_proxy_adapter/examples/test_examples.py +0 -1
  195. mcp_proxy_adapter/examples/test_framework_complete.py +0 -2
  196. mcp_proxy_adapter/examples/test_mcp_server.py +0 -1
  197. mcp_proxy_adapter/examples/test_protocol_examples.py +0 -1
  198. mcp_proxy_adapter/examples/universal_client.py +0 -6
  199. mcp_proxy_adapter/examples/update_config_certificates.py +0 -1
  200. mcp_proxy_adapter/examples/validate_generator_compatibility.py +0 -1
  201. mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +0 -187
  202. mcp_proxy_adapter/integrations/__init__.py +25 -0
  203. mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
  204. mcp_proxy_adapter/main.py +70 -62
  205. mcp_proxy_adapter/openapi.py +0 -22
  206. mcp_proxy_adapter/version.py +1 -1
  207. {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.30.dist-info}/METADATA +2 -1
  208. mcp_proxy_adapter-6.9.30.dist-info/RECORD +235 -0
  209. {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.30.dist-info}/entry_points.txt +1 -1
  210. mcp_proxy_adapter-6.9.28.dist-info/RECORD +0 -149
  211. {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.30.dist-info}/WHEEL +0 -0
  212. {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.30.dist-info}/top_level.txt +0 -0
@@ -13,11 +13,10 @@ Version: 1.0.0
13
13
  """
14
14
 
15
15
  import logging
16
- from typing import Dict, List, Any, Optional, Union
16
+ from typing import Union, Dict, Any
17
17
 
18
18
  from ..commands.base import Command
19
19
  from ..commands.result import SuccessResult, ErrorResult
20
- from ..core.auth_validator import AuthValidator, AuthValidationResult
21
20
 
22
21
 
23
22
  from mcp_proxy_adapter.core.logging import get_global_logger
@@ -35,208 +34,10 @@ class AuthValidationCommand(Command):
35
34
  self.validator = AuthValidator()
36
35
  self.logger = logging.getLogger(__name__)
37
36
 
38
- async def auth_validate(
39
- self, auth_data: Dict[str, Any]
40
- ) -> Union[SuccessResult, ErrorResult]:
41
- """
42
- Universal authentication validation.
43
-
44
- Validates authentication data based on the provided type.
45
- Supports certificate, token, mTLS, and SSL validation.
46
-
47
- Args:
48
- auth_data: Authentication data dictionary containing:
49
- - auth_type: Type of authentication (auto/certificate/token/mtls/ssl)
50
- - cert_path: Path to certificate file (for certificate/mtls/ssl)
51
- - cert_type: Type of certificate (server/client/ca)
52
- - token: Token string (for token validation)
53
- - token_type: Type of token (jwt/api)
54
- - client_cert: Path to client certificate (for mTLS)
55
- - ca_cert: Path to CA certificate (for mTLS)
56
- - server_cert: Path to server certificate (for SSL)
57
-
58
- Returns:
59
- CommandResult with validation status and extracted roles
60
- """
61
- try:
62
- auth_type = auth_data.get("auth_type", "auto")
63
-
64
- # Perform validation
65
- result = self.validator.validate_auth(auth_data, auth_type)
66
-
67
- if result.is_valid:
68
- return SuccessResult(
69
- data={"valid": True, "roles": result.roles, "auth_type": auth_type}
70
- )
71
- else:
72
- error_data = result.to_json_rpc_error()
73
- return ErrorResult(
74
- message=error_data["message"], code=error_data["code"]
75
- )
76
-
77
- except Exception as e:
78
- self.get_global_logger().error(f"Authentication validation error: {e}")
79
- return ErrorResult(
80
- message=f"Internal authentication validation error: {str(e)}",
81
- code=-32603,
82
- )
83
-
84
- async def auth_validate_cert(
85
- self, cert_path: str, cert_type: str = "server"
86
- ) -> Union[SuccessResult, ErrorResult]:
87
- """
88
- Validate certificate.
89
-
90
- Validates a certificate file and extracts roles if present.
91
-
92
- Args:
93
- cert_path: Path to certificate file
94
- cert_type: Type of certificate (server/client/ca)
95
-
96
- Returns:
97
- CommandResult with certificate validation status and roles
98
- """
99
- try:
100
- # Perform certificate validation
101
- result = self.validator.validate_certificate(cert_path, cert_type)
102
-
103
- if result.is_valid:
104
- return SuccessResult(
105
- data={
106
- "valid": True,
107
- "cert_path": cert_path,
108
- "cert_type": cert_type,
109
- "roles": result.roles,
110
- }
111
- )
112
- else:
113
- error_data = result.to_json_rpc_error()
114
- return ErrorResult(
115
- message=error_data["message"], code=error_data["code"]
116
- )
117
-
118
- except Exception as e:
119
- self.get_global_logger().error(f"Certificate validation error: {e}")
120
- return ErrorResult(
121
- message=f"Internal certificate validation error: {str(e)}", code=-32603
122
- )
123
-
124
- async def auth_validate_token(
125
- self, token: str, token_type: str = "jwt"
126
- ) -> Union[SuccessResult, ErrorResult]:
127
- """
128
- Validate token.
129
-
130
- Validates a token and extracts roles if present.
131
-
132
- Args:
133
- token: Token string to validate
134
- token_type: Type of token (jwt/api)
135
37
 
136
- Returns:
137
- CommandResult with token validation status and roles
138
- """
139
- try:
140
- # Perform token validation
141
- result = self.validator.validate_token(token, token_type)
142
38
 
143
- if result.is_valid:
144
- return SuccessResult(
145
- data={
146
- "valid": True,
147
- "token_type": token_type,
148
- "roles": result.roles,
149
- }
150
- )
151
- else:
152
- error_data = result.to_json_rpc_error()
153
- return ErrorResult(
154
- message=error_data["message"], code=error_data["code"]
155
- )
156
39
 
157
- except Exception as e:
158
- self.get_global_logger().error(f"Token validation error: {e}")
159
- return ErrorResult(
160
- message=f"Internal token validation error: {str(e)}", code=-32603
161
- )
162
-
163
- async def auth_validate_mtls(
164
- self, client_cert: str, ca_cert: str
165
- ) -> Union[SuccessResult, ErrorResult]:
166
- """
167
- Validate mTLS connection.
168
-
169
- Validates client certificate against CA certificate and extracts roles.
170
-
171
- Args:
172
- client_cert: Path to client certificate
173
- ca_cert: Path to CA certificate
174
40
 
175
- Returns:
176
- CommandResult with mTLS validation status and roles
177
- """
178
- try:
179
- # Perform mTLS validation
180
- result = self.validator.validate_mtls(client_cert, ca_cert)
181
-
182
- if result.is_valid:
183
- return SuccessResult(
184
- data={
185
- "valid": True,
186
- "client_cert": client_cert,
187
- "ca_cert": ca_cert,
188
- "roles": result.roles,
189
- }
190
- )
191
- else:
192
- error_data = result.to_json_rpc_error()
193
- return ErrorResult(
194
- message=error_data["message"], code=error_data["code"]
195
- )
196
-
197
- except Exception as e:
198
- self.get_global_logger().error(f"mTLS validation error: {e}")
199
- return ErrorResult(
200
- message=f"Internal mTLS validation error: {str(e)}", code=-32603
201
- )
202
-
203
- async def auth_validate_ssl(
204
- self, server_cert: str
205
- ) -> Union[SuccessResult, ErrorResult]:
206
- """
207
- Validate SSL connection.
208
-
209
- Validates server certificate and extracts roles if present.
210
-
211
- Args:
212
- server_cert: Path to server certificate
213
-
214
- Returns:
215
- CommandResult with SSL validation status and roles
216
- """
217
- try:
218
- # Perform SSL validation
219
- result = self.validator.validate_ssl(server_cert)
220
-
221
- if result.is_valid:
222
- return SuccessResult(
223
- data={
224
- "valid": True,
225
- "server_cert": server_cert,
226
- "roles": result.roles,
227
- }
228
- )
229
- else:
230
- error_data = result.to_json_rpc_error()
231
- return ErrorResult(
232
- message=error_data["message"], code=error_data["code"]
233
- )
234
-
235
- except Exception as e:
236
- self.get_global_logger().error(f"SSL validation error: {e}")
237
- return ErrorResult(
238
- message=f"Internal SSL validation error: {str(e)}", code=-32603
239
- )
240
41
 
241
42
  async def execute(self, **kwargs) -> Union[SuccessResult, ErrorResult]:
242
43
  """
@@ -258,149 +59,11 @@ class AuthValidationCommand(Command):
258
59
 
259
60
  @classmethod
260
61
  def get_schema(cls) -> Dict[str, Any]:
261
- """
262
- Get command schema for documentation.
263
-
264
- Returns:
265
- Dictionary containing command schema
266
- """
62
+ """Get JSON schema for auth validation command."""
267
63
  return {
268
- "auth_validate": {
269
- "description": "Universal authentication validation",
270
- "parameters": {
271
- "auth_data": {
272
- "type": "object",
273
- "description": "Authentication data dictionary",
274
- "properties": {
275
- "auth_type": {
276
- "type": "string",
277
- "enum": ["auto", "certificate", "token", "mtls", "ssl"],
278
- "description": "Type of authentication to validate",
279
- },
280
- "cert_path": {
281
- "type": "string",
282
- "description": "Path to certificate file",
283
- },
284
- "cert_type": {
285
- "type": "string",
286
- "enum": ["server", "client", "ca"],
287
- "description": "Type of certificate",
288
- },
289
- "token": {
290
- "type": "string",
291
- "description": "Token string to validate",
292
- },
293
- "token_type": {
294
- "type": "string",
295
- "enum": ["jwt", "api"],
296
- "description": "Type of token",
297
- },
298
- "client_cert": {
299
- "type": "string",
300
- "description": "Path to client certificate (for mTLS)",
301
- },
302
- "ca_cert": {
303
- "type": "string",
304
- "description": "Path to CA certificate (for mTLS)",
305
- },
306
- "server_cert": {
307
- "type": "string",
308
- "description": "Path to server certificate (for SSL)",
309
- },
310
- },
311
- }
312
- },
313
- "returns": {
314
- "type": "object",
315
- "properties": {
316
- "valid": {"type": "boolean"},
317
- "roles": {"type": "array", "items": {"type": "string"}},
318
- "auth_type": {"type": "string"},
319
- },
320
- },
321
- },
322
- "auth_validate_cert": {
323
- "description": "Validate certificate",
324
- "parameters": {
325
- "cert_path": {
326
- "type": "string",
327
- "description": "Path to certificate file",
328
- },
329
- "cert_type": {
330
- "type": "string",
331
- "enum": ["server", "client", "ca"],
332
- "description": "Type of certificate",
333
- },
334
- },
335
- "returns": {
336
- "type": "object",
337
- "properties": {
338
- "valid": {"type": "boolean"},
339
- "cert_path": {"type": "string"},
340
- "cert_type": {"type": "string"},
341
- "roles": {"type": "array", "items": {"type": "string"}},
342
- },
343
- },
344
- },
345
- "auth_validate_token": {
346
- "description": "Validate token",
347
- "parameters": {
348
- "token": {
349
- "type": "string",
350
- "description": "Token string to validate",
351
- },
352
- "token_type": {
353
- "type": "string",
354
- "enum": ["jwt", "api"],
355
- "description": "Type of token",
356
- },
357
- },
358
- "returns": {
359
- "type": "object",
360
- "properties": {
361
- "valid": {"type": "boolean"},
362
- "token_type": {"type": "string"},
363
- "roles": {"type": "array", "items": {"type": "string"}},
364
- },
365
- },
366
- },
367
- "auth_validate_mtls": {
368
- "description": "Validate mTLS connection",
369
- "parameters": {
370
- "client_cert": {
371
- "type": "string",
372
- "description": "Path to client certificate",
373
- },
374
- "ca_cert": {
375
- "type": "string",
376
- "description": "Path to CA certificate",
377
- },
378
- },
379
- "returns": {
380
- "type": "object",
381
- "properties": {
382
- "valid": {"type": "boolean"},
383
- "client_cert": {"type": "string"},
384
- "ca_cert": {"type": "string"},
385
- "roles": {"type": "array", "items": {"type": "string"}},
386
- },
387
- },
388
- },
389
- "auth_validate_ssl": {
390
- "description": "Validate SSL connection",
391
- "parameters": {
392
- "server_cert": {
393
- "type": "string",
394
- "description": "Path to server certificate",
395
- }
396
- },
397
- "returns": {
398
- "type": "object",
399
- "properties": {
400
- "valid": {"type": "boolean"},
401
- "server_cert": {"type": "string"},
402
- "roles": {"type": "array", "items": {"type": "string"}},
403
- },
404
- },
405
- },
64
+ "type": "object",
65
+ "properties": {
66
+ "method": {"type": "string", "enum": ["validate_token", "validate_certificate", "validate_mtls"]},
67
+ "params": {"type": "object"}
68
+ }
406
69
  }
@@ -4,11 +4,10 @@ Base command classes for MCP Microservice.
4
4
 
5
5
  import inspect
6
6
  from abc import ABC, abstractmethod
7
- from typing import Any, ClassVar, Dict, List, Optional, Type, TypeVar
7
+ from typing import TypeVar, Type, ClassVar, Dict, Any, List
8
8
 
9
9
  from docstring_parser import parse
10
10
 
11
- from mcp_proxy_adapter.commands.result import CommandResult, SuccessResult, ErrorResult
12
11
  from mcp_proxy_adapter.core.errors import (
13
12
  CommandError,
14
13
  InternalError,
@@ -19,6 +18,24 @@ from mcp_proxy_adapter.core.errors import (
19
18
  from mcp_proxy_adapter.core.logging import get_global_logger
20
19
 
21
20
 
21
+ class CommandResult:
22
+ """Base class for command results."""
23
+
24
+ def __init__(self, success: bool = True, data: dict = None, error: str = None):
25
+ self.success = success
26
+ self.data = data or {}
27
+ self.error = error
28
+
29
+ def to_dict(self) -> dict:
30
+ """Convert to dictionary."""
31
+ result = {"success": self.success}
32
+ if self.data:
33
+ result["data"] = self.data
34
+ if self.error:
35
+ result["error"] = self.error
36
+ return result
37
+
38
+
22
39
  T = TypeVar("T", bound=CommandResult)
23
40
 
24
41
 
@@ -260,47 +277,6 @@ class Command(ABC):
260
277
  return params
261
278
 
262
279
  @classmethod
263
- def get_metadata(cls) -> Dict[str, Any]:
264
- """
265
- Returns complete metadata about the command.
266
-
267
- Provides a single access point to all command metadata.
268
-
269
- Returns:
270
- Dict with command metadata
271
- """
272
- # Get and format docstring
273
- doc = cls.__doc__ or ""
274
- description = inspect.cleandoc(doc) if doc else ""
275
-
276
- # Extract first line for summary
277
- summary = description.split("\n")[0] if description else ""
278
-
279
- # Get parameters information
280
- param_info = cls.get_param_info()
281
-
282
- # Generate examples based on parameters
283
- examples = cls._generate_examples(param_info)
284
-
285
- return {
286
- "name": cls.name,
287
- "version": cls.version,
288
- "plugin": cls.plugin,
289
- "descr": cls.descr,
290
- "category": cls.category,
291
- "author": cls.author,
292
- "email": cls.email,
293
- "source_url": cls.source_url,
294
- "summary": summary,
295
- "description": description,
296
- "params": param_info,
297
- "examples": examples,
298
- "schema": cls.get_schema(),
299
- "result_schema": cls.get_result_schema(),
300
- "result_class": (
301
- cls.result_class.__name__ if hasattr(cls, "result_class") else None
302
- ),
303
- }
304
280
 
305
281
  @classmethod
306
282
  def _generate_examples(
@@ -26,80 +26,5 @@ from mcp_proxy_adapter.commands.role_test_command import RoleTestCommand
26
26
  from mcp_proxy_adapter.core.logging import get_global_logger
27
27
 
28
28
 
29
- def register_builtin_commands() -> int:
30
- """
31
- Register all built-in framework commands.
32
29
 
33
- Returns:
34
- Number of built-in commands registered.
35
- """
36
- get_global_logger().debug("Registering built-in framework commands...")
37
30
 
38
- builtin_commands = [
39
- HelpCommand,
40
- HealthCommand,
41
- ConfigCommand,
42
- ReloadCommand,
43
- SettingsCommand,
44
- LoadCommand,
45
- UnloadCommand,
46
- PluginsCommand,
47
- TransportManagementCommand,
48
- ProxyRegistrationCommand,
49
- EchoCommand,
50
- RoleTestCommand,
51
- ]
52
-
53
- registered_count = 0
54
-
55
- for command_class in builtin_commands:
56
- try:
57
- # Get command name for logging
58
- command_name = getattr(
59
- command_class, "name", command_class.__name__.lower()
60
- )
61
- if command_name.endswith("command"):
62
- command_name = command_name[:-7]
63
-
64
- # Check if command already exists (should not happen for built-in)
65
- if registry.command_exists(command_name):
66
- get_global_logger().warning(
67
- f"Built-in command '{command_name}' already exists, skipping"
68
- )
69
- continue
70
-
71
- # Register the command
72
- registry.register_builtin(command_class)
73
- registered_count += 1
74
- get_global_logger().debug(f"Registered built-in command: {command_name}")
75
-
76
- except Exception as e:
77
- get_global_logger().error(
78
- f"Failed to register built-in command {command_class.__name__}: {e}"
79
- )
80
-
81
- get_global_logger().info(f"Registered {registered_count} built-in framework commands")
82
- return registered_count
83
-
84
-
85
- def get_builtin_commands_list() -> list:
86
- """
87
- Get list of all built-in command classes.
88
-
89
- Returns:
90
- List of built-in command classes.
91
- """
92
- return [
93
- HelpCommand,
94
- HealthCommand,
95
- ConfigCommand,
96
- ReloadCommand,
97
- SettingsCommand,
98
- LoadCommand,
99
- UnloadCommand,
100
- PluginsCommand,
101
- TransportManagementCommand,
102
- ProxyRegistrationCommand,
103
- EchoCommand,
104
- RoleTestCommand,
105
- ]
@@ -0,0 +1,20 @@
1
+ """
2
+ Author: Vasiliy Zdanovskiy
3
+ email: vasilyvz@gmail.com
4
+
5
+ Command catalog management package for MCP Proxy Adapter.
6
+ """
7
+
8
+ from .command_catalog import CommandCatalog
9
+ from .catalog_manager import CatalogManager
10
+ from .catalog_loader import CatalogLoader
11
+ from .catalog_syncer import CatalogSyncer
12
+ from .dependency_manager import DependencyManager
13
+
14
+ __all__ = [
15
+ "CommandCatalog",
16
+ "CatalogManager",
17
+ "CatalogLoader",
18
+ "CatalogSyncer",
19
+ "DependencyManager",
20
+ ]
@@ -0,0 +1,34 @@
1
+ """
2
+ Author: Vasiliy Zdanovskiy
3
+ email: vasilyvz@gmail.com
4
+
5
+ Catalog loading utilities for MCP Proxy Adapter.
6
+ """
7
+
8
+ import json
9
+ from pathlib import Path
10
+
11
+ from mcp_proxy_adapter.core.logging import get_global_logger
12
+ from .command_catalog import CommandCatalog
13
+
14
+ # Try to import requests, but don't fail if not available
15
+ try:
16
+ import requests
17
+ REQUESTS_AVAILABLE = True
18
+ except ImportError:
19
+ REQUESTS_AVAILABLE = False
20
+ get_global_logger().warning(
21
+ "requests library not available, HTTP/HTTPS functionality will be limited"
22
+ )
23
+
24
+
25
+ class CatalogLoader:
26
+ """Loader for command catalogs from various sources."""
27
+
28
+ def __init__(self):
29
+ """Initialize catalog loader."""
30
+ self.logger = get_global_logger()
31
+
32
+
33
+
34
+