mcp-proxy-adapter 6.9.17__py3-none-any.whl → 6.9.19__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.
Files changed (87) hide show
  1. mcp_proxy_adapter/api/app.py +52 -52
  2. mcp_proxy_adapter/api/handlers.py +5 -5
  3. mcp_proxy_adapter/api/middleware/__init__.py +8 -8
  4. mcp_proxy_adapter/api/middleware/base.py +14 -14
  5. mcp_proxy_adapter/api/middleware/command_permission_middleware.py +7 -7
  6. mcp_proxy_adapter/api/middleware/error_handling.py +9 -9
  7. mcp_proxy_adapter/api/middleware/factory.py +17 -17
  8. mcp_proxy_adapter/api/middleware/logging.py +6 -6
  9. mcp_proxy_adapter/api/middleware/performance.py +3 -3
  10. mcp_proxy_adapter/api/middleware/protocol_middleware.py +19 -19
  11. mcp_proxy_adapter/api/middleware/transport_middleware.py +3 -3
  12. mcp_proxy_adapter/api/middleware/unified_security.py +11 -11
  13. mcp_proxy_adapter/api/middleware/user_info_middleware.py +21 -21
  14. mcp_proxy_adapter/api/tool_integration.py +3 -2
  15. mcp_proxy_adapter/api/tools.py +4 -3
  16. mcp_proxy_adapter/commands/auth_validation_command.py +6 -5
  17. mcp_proxy_adapter/commands/base.py +10 -10
  18. mcp_proxy_adapter/commands/builtin_commands.py +6 -6
  19. mcp_proxy_adapter/commands/catalog_manager.py +74 -74
  20. mcp_proxy_adapter/commands/cert_monitor_command.py +13 -12
  21. mcp_proxy_adapter/commands/certificate_management_command.py +20 -19
  22. mcp_proxy_adapter/commands/command_registry.py +68 -67
  23. mcp_proxy_adapter/commands/config_command.py +3 -1
  24. mcp_proxy_adapter/commands/dependency_manager.py +10 -10
  25. mcp_proxy_adapter/commands/help_command.py +21 -20
  26. mcp_proxy_adapter/commands/hooks.py +27 -27
  27. mcp_proxy_adapter/commands/key_management_command.py +19 -18
  28. mcp_proxy_adapter/commands/plugins_command.py +2 -1
  29. mcp_proxy_adapter/commands/protocol_management_command.py +6 -6
  30. mcp_proxy_adapter/commands/proxy_registration_command.py +9 -9
  31. mcp_proxy_adapter/commands/registration_status_command.py +4 -4
  32. mcp_proxy_adapter/commands/reload_command.py +5 -5
  33. mcp_proxy_adapter/commands/role_test_command.py +2 -1
  34. mcp_proxy_adapter/commands/roles_management_command.py +9 -8
  35. mcp_proxy_adapter/commands/security_command.py +3 -2
  36. mcp_proxy_adapter/commands/ssl_setup_command.py +7 -6
  37. mcp_proxy_adapter/commands/token_management_command.py +12 -11
  38. mcp_proxy_adapter/commands/transport_management_command.py +2 -2
  39. mcp_proxy_adapter/config.py +3 -3
  40. mcp_proxy_adapter/core/__init__.py +1 -1
  41. mcp_proxy_adapter/core/app_runner.py +3 -3
  42. mcp_proxy_adapter/core/auth_validator.py +9 -9
  43. mcp_proxy_adapter/core/certificate_utils.py +27 -27
  44. mcp_proxy_adapter/core/client_manager.py +13 -13
  45. mcp_proxy_adapter/core/client_security.py +26 -26
  46. mcp_proxy_adapter/core/config_converter.py +18 -18
  47. mcp_proxy_adapter/core/config_validator.py +5 -1
  48. mcp_proxy_adapter/core/crl_utils.py +22 -22
  49. mcp_proxy_adapter/core/logging.py +21 -13
  50. mcp_proxy_adapter/core/mtls_asgi.py +7 -7
  51. mcp_proxy_adapter/core/mtls_asgi_app.py +9 -9
  52. mcp_proxy_adapter/core/mtls_proxy.py +9 -9
  53. mcp_proxy_adapter/core/mtls_server.py +18 -18
  54. mcp_proxy_adapter/core/protocol_manager.py +29 -29
  55. mcp_proxy_adapter/core/proxy_registration.py +67 -67
  56. mcp_proxy_adapter/core/security_adapter.py +18 -18
  57. mcp_proxy_adapter/core/security_factory.py +16 -16
  58. mcp_proxy_adapter/core/security_integration.py +6 -6
  59. mcp_proxy_adapter/core/server_adapter.py +12 -12
  60. mcp_proxy_adapter/core/server_engine.py +17 -17
  61. mcp_proxy_adapter/core/signal_handler.py +12 -12
  62. mcp_proxy_adapter/core/ssl_utils.py +12 -12
  63. mcp_proxy_adapter/core/transport_manager.py +14 -14
  64. mcp_proxy_adapter/core/unified_config_adapter.py +6 -6
  65. mcp_proxy_adapter/core/utils.py +5 -5
  66. mcp_proxy_adapter/custom_openapi.py +7 -7
  67. mcp_proxy_adapter/examples/cert_manager_bugfix.py +2 -2
  68. mcp_proxy_adapter/examples/full_application/commands/__init__.py +6 -5
  69. mcp_proxy_adapter/examples/full_application/commands/echo_command.py +44 -0
  70. mcp_proxy_adapter/examples/full_application/commands/help_command.py +66 -0
  71. mcp_proxy_adapter/examples/full_application/commands/list_command.py +64 -0
  72. mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +21 -21
  73. mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +6 -6
  74. mcp_proxy_adapter/examples/full_application/main.py +28 -0
  75. mcp_proxy_adapter/examples/proxy_registration_example.py +38 -38
  76. mcp_proxy_adapter/examples/test_framework_complete.py +35 -35
  77. mcp_proxy_adapter/examples/test_mcp_server.py +2 -2
  78. mcp_proxy_adapter/examples/validate_generator_compatibility.py +386 -0
  79. mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +248 -0
  80. mcp_proxy_adapter/main.py +3 -0
  81. mcp_proxy_adapter/version.py +1 -1
  82. {mcp_proxy_adapter-6.9.17.dist-info → mcp_proxy_adapter-6.9.19.dist-info}/METADATA +1 -1
  83. mcp_proxy_adapter-6.9.19.dist-info/RECORD +149 -0
  84. mcp_proxy_adapter-6.9.17.dist-info/RECORD +0 -144
  85. {mcp_proxy_adapter-6.9.17.dist-info → mcp_proxy_adapter-6.9.19.dist-info}/WHEEL +0 -0
  86. {mcp_proxy_adapter-6.9.17.dist-info → mcp_proxy_adapter-6.9.19.dist-info}/entry_points.txt +0 -0
  87. {mcp_proxy_adapter-6.9.17.dist-info → mcp_proxy_adapter-6.9.19.dist-info}/top_level.txt +0 -0
@@ -10,6 +10,7 @@ from mcp_proxy_adapter.commands.base import Command
10
10
  from mcp_proxy_adapter.commands.result import CommandResult
11
11
  from mcp_proxy_adapter.commands.command_registry import registry
12
12
  from mcp_proxy_adapter.core.errors import NotFoundError
13
+ from mcp_proxy_adapter.core.logging import get_global_logger
13
14
 
14
15
  # Добавляем логирование
15
16
  logger = logging.getLogger("mcp_proxy_adapter.commands.help_command")
@@ -32,7 +33,7 @@ class HelpResult(CommandResult):
32
33
  commands_info: Information about all commands (for request without parameters)
33
34
  command_info: Information about a specific command (for request with cmdname parameter)
34
35
  """
35
- logger.debug(
36
+ get_global_logger().debug(
36
37
  f"HelpResult.__init__: commands_info={commands_info is not None}, command_info={command_info is not None}"
37
38
  )
38
39
  self.commands_info = commands_info
@@ -46,13 +47,13 @@ class HelpResult(CommandResult):
46
47
  Dict[str, Any]: Result as dictionary
47
48
  """
48
49
  try:
49
- logger.debug(
50
+ get_global_logger().debug(
50
51
  f"HelpResult.to_dict: command_info={self.command_info is not None}, commands_info={self.commands_info is not None}"
51
52
  )
52
53
 
53
54
  # Защита от None для self.command_info
54
55
  if self.command_info is not None:
55
- logger.debug(
56
+ get_global_logger().debug(
56
57
  f"HelpResult.to_dict: returning command_info for {self.command_info.get('name', 'unknown')}"
57
58
  )
58
59
  # Делаем безопасное получение всех полей с дефолтными значениями
@@ -70,7 +71,7 @@ class HelpResult(CommandResult):
70
71
 
71
72
  # Защита от None для self.commands_info
72
73
  if self.commands_info is None:
73
- logger.warning(
74
+ get_global_logger().warning(
74
75
  "HelpResult.to_dict: commands_info is None, создаем пустой результат"
75
76
  )
76
77
  # Возвращаем пустой список команд вместо ошибки
@@ -100,7 +101,7 @@ class HelpResult(CommandResult):
100
101
  }
101
102
 
102
103
  # For list of all commands, return as is (already formatted)
103
- logger.debug(
104
+ get_global_logger().debug(
104
105
  f"HelpResult.to_dict: processing commands_info with {len(self.commands_info.get('commands', {}))} commands"
105
106
  )
106
107
  result = self.commands_info.copy()
@@ -112,13 +113,13 @@ class HelpResult(CommandResult):
112
113
  'To get detailed information about a specific command, call help with parameter: POST /cmd {"command": "help", "params": {"cmdname": "<command_name>"}}'
113
114
  )
114
115
 
115
- logger.debug(
116
+ get_global_logger().debug(
116
117
  f"HelpResult.to_dict: returning result with {result['total']} commands"
117
118
  )
118
119
  return result
119
120
  except Exception as e:
120
- logger.error(f"Ошибка в HelpResult.to_dict: {e}")
121
- logger.debug(f"Трассировка: {traceback.format_exc()}")
121
+ get_global_logger().error(f"Ошибка в HelpResult.to_dict: {e}")
122
+ get_global_logger().debug(f"Трассировка: {traceback.format_exc()}")
122
123
  # В случае неожиданной ошибки возвращаем базовый ответ вместо ошибки
123
124
  return {
124
125
  "tool_info": {
@@ -206,21 +207,21 @@ class HelpCommand(Command):
206
207
  Raises:
207
208
  NotFoundError: If specified command not found
208
209
  """
209
- logger.debug(f"HelpCommand.execute начало: cmdname={cmdname}, kwargs={kwargs}")
210
+ get_global_logger().debug(f"HelpCommand.execute начало: cmdname={cmdname}, kwargs={kwargs}")
210
211
 
211
212
  try:
212
213
  # Handle case when cmdname is provided
213
214
  if cmdname is not None and cmdname != "":
214
- logger.debug(f"Обработка запроса для конкретной команды: {cmdname}")
215
+ get_global_logger().debug(f"Обработка запроса для конкретной команды: {cmdname}")
215
216
  try:
216
217
  # Get command info from registry
217
218
  command_info = registry.get_command_info(cmdname)
218
219
  if command_info is None:
219
220
  raise NotFoundError(f"Command '{cmdname}' not found")
220
- logger.debug(f"Получены метаданные для команды {cmdname}")
221
+ get_global_logger().debug(f"Получены метаданные для команды {cmdname}")
221
222
  return HelpResult(command_info=command_info)
222
223
  except NotFoundError:
223
- logger.warning(f"Команда '{cmdname}' не найдена")
224
+ get_global_logger().warning(f"Команда '{cmdname}' не найдена")
224
225
  # Получаем список всех команд
225
226
  all_commands = list(registry.get_all_commands().keys())
226
227
  if all_commands:
@@ -243,11 +244,11 @@ class HelpCommand(Command):
243
244
  )
244
245
 
245
246
  # Otherwise, return information about all available commands
246
- logger.debug("Обработка запроса для всех команд")
247
+ get_global_logger().debug("Обработка запроса для всех команд")
247
248
 
248
249
  # Get info for all commands
249
250
  all_commands_info = registry.get_all_commands_info()
250
- logger.debug(
251
+ get_global_logger().debug(
251
252
  f"Получены метаданные для {len(all_commands_info.get('commands', {}))} команд"
252
253
  )
253
254
 
@@ -279,7 +280,7 @@ class HelpCommand(Command):
279
280
  commands_data = all_commands_info.get("commands", {})
280
281
  for name, command_info in commands_data.items():
281
282
  try:
282
- logger.debug(f"Обработка метаданных команды {name}")
283
+ get_global_logger().debug(f"Обработка метаданных команды {name}")
283
284
  # Безопасное получение параметров с проверкой на наличие ключей
284
285
  metadata = command_info.get("metadata", {})
285
286
  schema = command_info.get("schema", {})
@@ -288,18 +289,18 @@ class HelpCommand(Command):
288
289
  "params_count": len(schema.get("properties", {})),
289
290
  }
290
291
  except Exception as e:
291
- logger.error(f"Ошибка при обработке метаданных команды {name}: {e}")
292
- logger.debug(f"Метаданные команды {name}: {command_info}")
292
+ get_global_logger().error(f"Ошибка при обработке метаданных команды {name}: {e}")
293
+ get_global_logger().debug(f"Метаданные команды {name}: {command_info}")
293
294
  # Пропускаем проблемную команду
294
295
  continue
295
296
 
296
- logger.debug(
297
+ get_global_logger().debug(
297
298
  f"HelpCommand.execute завершение: возвращаем результат с {len(result['commands'])} командами"
298
299
  )
299
300
  return HelpResult(commands_info=result)
300
301
  except Exception as e:
301
- logger.error(f"Неожиданная ошибка в HelpCommand.execute: {e}")
302
- logger.debug(f"Трассировка: {traceback.format_exc()}")
302
+ get_global_logger().error(f"Неожиданная ошибка в HelpCommand.execute: {e}")
303
+ get_global_logger().debug(f"Трассировка: {traceback.format_exc()}")
303
304
  # В случае неожиданной ошибки возвращаем пустой результат вместо ошибки
304
305
  return HelpResult(
305
306
  commands_info={
@@ -8,7 +8,7 @@ that will be called during system initialization.
8
8
  from typing import Callable, List, Optional, Dict, Any, Union
9
9
  from enum import Enum
10
10
  from dataclasses import dataclass
11
- from mcp_proxy_adapter.core.logging import logger
11
+ from mcp_proxy_adapter.core.logging import get_global_logger
12
12
 
13
13
 
14
14
  class HookType(Enum):
@@ -65,7 +65,7 @@ class CommandHooks:
65
65
  Should accept registry as parameter.
66
66
  """
67
67
  self._custom_commands_hooks.append(hook_func)
68
- logger.debug(f"Registered custom commands hook: {hook_func.__name__}")
68
+ get_global_logger().debug(f"Registered custom commands hook: {hook_func.__name__}")
69
69
 
70
70
  def register_before_init_hook(self, hook_func: Callable) -> None:
71
71
  """
@@ -75,7 +75,7 @@ class CommandHooks:
75
75
  hook_func: Function to call before initialization.
76
76
  """
77
77
  self._before_init_hooks.append(hook_func)
78
- logger.debug(f"Registered before init hook: {hook_func.__name__}")
78
+ get_global_logger().debug(f"Registered before init hook: {hook_func.__name__}")
79
79
 
80
80
  def register_after_init_hook(self, hook_func: Callable) -> None:
81
81
  """
@@ -85,7 +85,7 @@ class CommandHooks:
85
85
  hook_func: Function to call after initialization.
86
86
  """
87
87
  self._after_init_hooks.append(hook_func)
88
- logger.debug(f"Registered after init hook: {hook_func.__name__}")
88
+ get_global_logger().debug(f"Registered after init hook: {hook_func.__name__}")
89
89
 
90
90
  def register_before_command_hook(self, hook_func: Callable) -> None:
91
91
  """
@@ -96,7 +96,7 @@ class CommandHooks:
96
96
  Should accept command_name and params as parameters.
97
97
  """
98
98
  self._before_command_hooks.append(hook_func)
99
- logger.debug(f"Registered before command hook: {hook_func.__name__}")
99
+ get_global_logger().debug(f"Registered before command hook: {hook_func.__name__}")
100
100
 
101
101
  def register_after_command_hook(self, hook_func: Callable) -> None:
102
102
  """
@@ -107,7 +107,7 @@ class CommandHooks:
107
107
  Should accept command_name, params, and result as parameters.
108
108
  """
109
109
  self._after_command_hooks.append(hook_func)
110
- logger.debug(f"Registered after command hook: {hook_func.__name__}")
110
+ get_global_logger().debug(f"Registered after command hook: {hook_func.__name__}")
111
111
 
112
112
  def execute_custom_commands_hooks(self, registry) -> int:
113
113
  """
@@ -119,20 +119,20 @@ class CommandHooks:
119
119
  Returns:
120
120
  Number of hooks executed.
121
121
  """
122
- logger.debug("Executing custom commands hooks...")
122
+ get_global_logger().debug("Executing custom commands hooks...")
123
123
  hooks_executed = 0
124
124
 
125
125
  for hook_func in self._custom_commands_hooks:
126
126
  try:
127
127
  hook_func(registry)
128
128
  hooks_executed += 1
129
- logger.debug(f"Executed custom commands hook: {hook_func.__name__}")
129
+ get_global_logger().debug(f"Executed custom commands hook: {hook_func.__name__}")
130
130
  except Exception as e:
131
- logger.error(
131
+ get_global_logger().error(
132
132
  f"Failed to execute custom commands hook {hook_func.__name__}: {e}"
133
133
  )
134
134
 
135
- logger.info(f"Executed {hooks_executed} custom commands hooks")
135
+ get_global_logger().info(f"Executed {hooks_executed} custom commands hooks")
136
136
  return hooks_executed
137
137
 
138
138
  def execute_before_init_hooks(self) -> int:
@@ -142,20 +142,20 @@ class CommandHooks:
142
142
  Returns:
143
143
  Number of hooks executed.
144
144
  """
145
- logger.debug("Executing before init hooks...")
145
+ get_global_logger().debug("Executing before init hooks...")
146
146
  hooks_executed = 0
147
147
 
148
148
  for hook_func in self._before_init_hooks:
149
149
  try:
150
150
  hook_func()
151
151
  hooks_executed += 1
152
- logger.debug(f"Executed before init hook: {hook_func.__name__}")
152
+ get_global_logger().debug(f"Executed before init hook: {hook_func.__name__}")
153
153
  except Exception as e:
154
- logger.error(
154
+ get_global_logger().error(
155
155
  f"Failed to execute before init hook {hook_func.__name__}: {e}"
156
156
  )
157
157
 
158
- logger.debug(f"Executed {hooks_executed} before init hooks")
158
+ get_global_logger().debug(f"Executed {hooks_executed} before init hooks")
159
159
  return hooks_executed
160
160
 
161
161
  def execute_after_init_hooks(self) -> int:
@@ -165,20 +165,20 @@ class CommandHooks:
165
165
  Returns:
166
166
  Number of hooks executed.
167
167
  """
168
- logger.debug("Executing after init hooks...")
168
+ get_global_logger().debug("Executing after init hooks...")
169
169
  hooks_executed = 0
170
170
 
171
171
  for hook_func in self._after_init_hooks:
172
172
  try:
173
173
  hook_func()
174
174
  hooks_executed += 1
175
- logger.debug(f"Executed after init hook: {hook_func.__name__}")
175
+ get_global_logger().debug(f"Executed after init hook: {hook_func.__name__}")
176
176
  except Exception as e:
177
- logger.error(
177
+ get_global_logger().error(
178
178
  f"Failed to execute after init hook {hook_func.__name__}: {e}"
179
179
  )
180
180
 
181
- logger.debug(f"Executed {hooks_executed} after init hooks")
181
+ get_global_logger().debug(f"Executed {hooks_executed} after init hooks")
182
182
  return hooks_executed
183
183
 
184
184
  def execute_before_command_hooks(
@@ -194,20 +194,20 @@ class CommandHooks:
194
194
  Returns:
195
195
  Number of hooks executed.
196
196
  """
197
- logger.debug(f"Executing before command hooks for: {command_name}")
197
+ get_global_logger().debug(f"Executing before command hooks for: {command_name}")
198
198
  hooks_executed = 0
199
199
 
200
200
  for hook_func in self._before_command_hooks:
201
201
  try:
202
202
  hook_func(command_name, params)
203
203
  hooks_executed += 1
204
- logger.debug(f"Executed before command hook: {hook_func.__name__}")
204
+ get_global_logger().debug(f"Executed before command hook: {hook_func.__name__}")
205
205
  except Exception as e:
206
- logger.error(
206
+ get_global_logger().error(
207
207
  f"Failed to execute before command hook {hook_func.__name__}: {e}"
208
208
  )
209
209
 
210
- logger.debug(f"Executed {hooks_executed} before command hooks")
210
+ get_global_logger().debug(f"Executed {hooks_executed} before command hooks")
211
211
  return hooks_executed
212
212
 
213
213
  def execute_after_command_hooks(
@@ -224,20 +224,20 @@ class CommandHooks:
224
224
  Returns:
225
225
  Number of hooks executed.
226
226
  """
227
- logger.debug(f"Executing after command hooks for: {command_name}")
227
+ get_global_logger().debug(f"Executing after command hooks for: {command_name}")
228
228
  hooks_executed = 0
229
229
 
230
230
  for hook_func in self._after_command_hooks:
231
231
  try:
232
232
  hook_func(command_name, params, result)
233
233
  hooks_executed += 1
234
- logger.debug(f"Executed after command hook: {hook_func.__name__}")
234
+ get_global_logger().debug(f"Executed after command hook: {hook_func.__name__}")
235
235
  except Exception as e:
236
- logger.error(
236
+ get_global_logger().error(
237
237
  f"Failed to execute after command hook {hook_func.__name__}: {e}"
238
238
  )
239
239
 
240
- logger.debug(f"Executed {hooks_executed} after command hooks")
240
+ get_global_logger().debug(f"Executed {hooks_executed} after command hooks")
241
241
  return hooks_executed
242
242
 
243
243
  def clear_hooks(self) -> None:
@@ -249,7 +249,7 @@ class CommandHooks:
249
249
  self._after_init_hooks.clear()
250
250
  self._before_command_hooks.clear()
251
251
  self._after_command_hooks.clear()
252
- logger.debug("Cleared all hooks")
252
+ get_global_logger().debug("Cleared all hooks")
253
253
 
254
254
 
255
255
  # Global hooks instance
@@ -19,6 +19,7 @@ from .base import Command
19
19
  from .result import CommandResult, SuccessResult, ErrorResult
20
20
  from ..core.certificate_utils import CertificateUtils
21
21
 
22
+ from mcp_proxy_adapter.core.logging import get_global_logger
22
23
  logger = logging.getLogger(__name__)
23
24
 
24
25
 
@@ -205,7 +206,7 @@ class KeyManagementCommand(Command):
205
206
  CommandResult with key generation status
206
207
  """
207
208
  try:
208
- logger.info(f"Generating {key_type} key with size {key_size} bits")
209
+ get_global_logger().info(f"Generating {key_type} key with size {key_size} bits")
209
210
 
210
211
  # Validate parameters
211
212
  if key_type not in ["RSA", "ECDSA"]:
@@ -240,11 +241,11 @@ class KeyManagementCommand(Command):
240
241
  status="valid",
241
242
  )
242
243
 
243
- logger.info(f"Key generated successfully: {output_path}")
244
+ get_global_logger().info(f"Key generated successfully: {output_path}")
244
245
  return SuccessResult(data={"key": key_result.to_dict(), "details": result})
245
246
 
246
247
  except Exception as e:
247
- logger.error(f"Key generation failed: {e}")
248
+ get_global_logger().error(f"Key generation failed: {e}")
248
249
  return ErrorResult(message=f"Key generation failed: {str(e)}")
249
250
 
250
251
  async def key_validate(
@@ -261,7 +262,7 @@ class KeyManagementCommand(Command):
261
262
  CommandResult with key validation status
262
263
  """
263
264
  try:
264
- logger.info(f"Validating key: {key_path}")
265
+ get_global_logger().info(f"Validating key: {key_path}")
265
266
 
266
267
  # Validate parameters
267
268
  if not key_path or not os.path.exists(key_path):
@@ -281,11 +282,11 @@ class KeyManagementCommand(Command):
281
282
  status="valid",
282
283
  )
283
284
 
284
- logger.info(f"Key validation completed: {key_path}")
285
+ get_global_logger().info(f"Key validation completed: {key_path}")
285
286
  return SuccessResult(data={"key": key_result.to_dict()})
286
287
 
287
288
  except Exception as e:
288
- logger.error(f"Key validation failed: {e}")
289
+ get_global_logger().error(f"Key validation failed: {e}")
289
290
  return ErrorResult(message=f"Key validation failed: {str(e)}")
290
291
 
291
292
  async def key_rotate(
@@ -308,7 +309,7 @@ class KeyManagementCommand(Command):
308
309
  CommandResult with key rotation status
309
310
  """
310
311
  try:
311
- logger.info(f"Rotating key from {old_key_path} to {new_key_path}")
312
+ get_global_logger().info(f"Rotating key from {old_key_path} to {new_key_path}")
312
313
 
313
314
  # Validate parameters
314
315
  if not old_key_path or not os.path.exists(old_key_path):
@@ -338,7 +339,7 @@ class KeyManagementCommand(Command):
338
339
  f"{old_key_path}.backup.{datetime.now().strftime('%Y%m%d_%H%M%S')}"
339
340
  )
340
341
  shutil.copy2(old_key_path, backup_path)
341
- logger.info(f"Old key backed up to: {backup_path}")
342
+ get_global_logger().info(f"Old key backed up to: {backup_path}")
342
343
 
343
344
  # Update certificate if provided
344
345
  cert_updated = False
@@ -347,16 +348,16 @@ class KeyManagementCommand(Command):
347
348
  # This would require implementing certificate re-signing
348
349
  # For now, we'll just note that it needs to be done
349
350
  cert_updated = True
350
- logger.info(
351
+ get_global_logger().info(
351
352
  f"Certificate {cert_path} needs to be re-signed with new key"
352
353
  )
353
354
  except Exception as e:
354
- logger.warning(f"Could not update certificate {cert_path}: {e}")
355
+ get_global_logger().warning(f"Could not update certificate {cert_path}: {e}")
355
356
 
356
357
  # Replace old key with new key
357
358
  shutil.copy2(new_key_path, old_key_path)
358
359
 
359
- logger.info(f"Key rotation completed successfully")
360
+ get_global_logger().info(f"Key rotation completed successfully")
360
361
  return SuccessResult(
361
362
  data={
362
363
  "old_key_path": old_key_path,
@@ -368,7 +369,7 @@ class KeyManagementCommand(Command):
368
369
  )
369
370
 
370
371
  except Exception as e:
371
- logger.error(f"Key rotation failed: {e}")
372
+ get_global_logger().error(f"Key rotation failed: {e}")
372
373
  return ErrorResult(message=f"Key rotation failed: {str(e)}")
373
374
 
374
375
  async def key_backup(
@@ -391,7 +392,7 @@ class KeyManagementCommand(Command):
391
392
  CommandResult with backup status
392
393
  """
393
394
  try:
394
- logger.info(f"Backing up key: {key_path}")
395
+ get_global_logger().info(f"Backing up key: {key_path}")
395
396
 
396
397
  # Validate parameters
397
398
  if not key_path or not os.path.exists(key_path):
@@ -427,7 +428,7 @@ class KeyManagementCommand(Command):
427
428
  if not os.path.exists(backup_path):
428
429
  return ErrorResult(message="Backup file was not created")
429
430
 
430
- logger.info(f"Key backup completed successfully: {backup_path}")
431
+ get_global_logger().info(f"Key backup completed successfully: {backup_path}")
431
432
  return SuccessResult(
432
433
  data={
433
434
  "key_path": key_path,
@@ -439,7 +440,7 @@ class KeyManagementCommand(Command):
439
440
  )
440
441
 
441
442
  except Exception as e:
442
- logger.error(f"Key backup failed: {e}")
443
+ get_global_logger().error(f"Key backup failed: {e}")
443
444
  return ErrorResult(message=f"Key backup failed: {str(e)}")
444
445
 
445
446
  async def key_restore(
@@ -457,7 +458,7 @@ class KeyManagementCommand(Command):
457
458
  CommandResult with restore status
458
459
  """
459
460
  try:
460
- logger.info(f"Restoring key from backup: {backup_path}")
461
+ get_global_logger().info(f"Restoring key from backup: {backup_path}")
461
462
 
462
463
  # Validate parameters
463
464
  if not backup_path or not os.path.exists(backup_path):
@@ -489,7 +490,7 @@ class KeyManagementCommand(Command):
489
490
  message=f"Restored key validation failed: {key_validation.to_dict()['error']['message']}"
490
491
  )
491
492
 
492
- logger.info(f"Key restore completed successfully: {key_path}")
493
+ get_global_logger().info(f"Key restore completed successfully: {key_path}")
493
494
  return SuccessResult(
494
495
  data={
495
496
  "backup_path": backup_path,
@@ -504,5 +505,5 @@ class KeyManagementCommand(Command):
504
505
  )
505
506
 
506
507
  except Exception as e:
507
- logger.error(f"Key restore failed: {e}")
508
+ get_global_logger().error(f"Key restore failed: {e}")
508
509
  return ErrorResult(message=f"Key restore failed: {str(e)}")
@@ -7,7 +7,7 @@ from typing import Dict, Any, Optional, List
7
7
  from mcp_proxy_adapter.commands.base import Command
8
8
  from mcp_proxy_adapter.commands.result import CommandResult, SuccessResult
9
9
  from mcp_proxy_adapter.commands.command_registry import registry
10
- from mcp_proxy_adapter.config import config as config_instance
10
+ from mcp_proxy_adapter.config import get_config
11
11
 
12
12
 
13
13
  class PluginsResult(SuccessResult):
@@ -141,6 +141,7 @@ class PluginsCommand(Command):
141
141
  """
142
142
  try:
143
143
  # Get configuration from the global config instance
144
+ config_instance = get_config()
144
145
  plugins_server_url = config_instance.get("commands.plugins_server")
145
146
 
146
147
  if not plugins_server_url:
@@ -11,7 +11,7 @@ from dataclasses import dataclass
11
11
  from mcp_proxy_adapter.commands.base import Command
12
12
  from mcp_proxy_adapter.commands.result import SuccessResult, ErrorResult
13
13
  from mcp_proxy_adapter.core.protocol_manager import protocol_manager
14
- from mcp_proxy_adapter.core.logging import logger
14
+ from mcp_proxy_adapter.core.logging import get_global_logger
15
15
 
16
16
 
17
17
  @dataclass
@@ -112,7 +112,7 @@ class ProtocolManagementCommand(Command):
112
112
  return ErrorResult(f"Unknown action: {action}")
113
113
 
114
114
  except Exception as e:
115
- logger.error(f"Protocol management command error: {e}")
115
+ get_global_logger().error(f"Protocol management command error: {e}")
116
116
  return ErrorResult(f"Protocol management error: {str(e)}")
117
117
 
118
118
  async def _get_protocol_info(self) -> SuccessResult:
@@ -150,7 +150,7 @@ class ProtocolManagementCommand(Command):
150
150
  )
151
151
 
152
152
  except Exception as e:
153
- logger.error(f"Error getting protocol info: {e}")
153
+ get_global_logger().error(f"Error getting protocol info: {e}")
154
154
  return ErrorResult(f"Failed to get protocol info: {str(e)}")
155
155
 
156
156
  async def _validate_configuration(self) -> SuccessResult:
@@ -174,7 +174,7 @@ class ProtocolManagementCommand(Command):
174
174
  )
175
175
 
176
176
  except Exception as e:
177
- logger.error(f"Error validating configuration: {e}")
177
+ get_global_logger().error(f"Error validating configuration: {e}")
178
178
  return ErrorResult(f"Failed to validate configuration: {str(e)}")
179
179
 
180
180
  async def _get_allowed_protocols(self) -> SuccessResult:
@@ -196,7 +196,7 @@ class ProtocolManagementCommand(Command):
196
196
  )
197
197
 
198
198
  except Exception as e:
199
- logger.error(f"Error getting allowed protocols: {e}")
199
+ get_global_logger().error(f"Error getting allowed protocols: {e}")
200
200
  return ErrorResult(f"Failed to get allowed protocols: {str(e)}")
201
201
 
202
202
  async def _check_protocol(self, protocol: str) -> SuccessResult:
@@ -240,5 +240,5 @@ class ProtocolManagementCommand(Command):
240
240
  )
241
241
 
242
242
  except Exception as e:
243
- logger.error(f"Error checking protocol {protocol}: {e}")
243
+ get_global_logger().error(f"Error checking protocol {protocol}: {e}")
244
244
  return ErrorResult(f"Failed to check protocol {protocol}: {str(e)}")
@@ -16,7 +16,7 @@ from dataclasses import dataclass
16
16
 
17
17
  from mcp_proxy_adapter.commands.base import Command
18
18
  from mcp_proxy_adapter.commands.result import SuccessResult
19
- from mcp_proxy_adapter.core.logging import logger
19
+ from mcp_proxy_adapter.core.logging import get_global_logger
20
20
 
21
21
 
22
22
  @dataclass
@@ -125,7 +125,7 @@ class ProxyRegistrationCommand(Command):
125
125
 
126
126
  # Only check permissions if security is enabled
127
127
  if security_enabled:
128
- logger.info(
128
+ get_global_logger().info(
129
129
  f"Checking permissions: user_permissions={user_permissions}, required={required_permissions}"
130
130
  )
131
131
  if not self._check_permissions(user_permissions, required_permissions):
@@ -135,10 +135,10 @@ class ProxyRegistrationCommand(Command):
135
135
  message=f"Permission denied: {operation} requires {required_permissions}",
136
136
  )
137
137
  else:
138
- logger.debug(f"Security disabled, skipping permission check for operation: {operation}")
138
+ get_global_logger().debug(f"Security disabled, skipping permission check for operation: {operation}")
139
139
 
140
- logger.info(f"Executing proxy registration operation: {operation}")
141
- logger.debug(
140
+ get_global_logger().info(f"Executing proxy registration operation: {operation}")
141
+ get_global_logger().debug(
142
142
  f"User permissions: {user_permissions}, required: {required_permissions}"
143
143
  )
144
144
 
@@ -203,7 +203,7 @@ class ProxyRegistrationCommand(Command):
203
203
 
204
204
  self._registry[server_key] = server_record
205
205
 
206
- logger.info(f"Registered server: {server_key} at {server_url}")
206
+ get_global_logger().info(f"Registered server: {server_key} at {server_url}")
207
207
 
208
208
  return ProxyRegistrationCommandResult(
209
209
  operation="register",
@@ -235,7 +235,7 @@ class ProxyRegistrationCommand(Command):
235
235
 
236
236
  if server_key in self._registry:
237
237
  del self._registry[server_key]
238
- logger.info(f"Unregistered server: {server_key}")
238
+ get_global_logger().info(f"Unregistered server: {server_key}")
239
239
 
240
240
  return ProxyRegistrationCommandResult(
241
241
  operation="unregister",
@@ -271,7 +271,7 @@ class ProxyRegistrationCommand(Command):
271
271
  self._registry[server_key]["last_heartbeat"] = timestamp
272
272
  self._registry[server_key]["status"] = status
273
273
 
274
- logger.debug(f"Heartbeat received for server: {server_key}")
274
+ get_global_logger().debug(f"Heartbeat received for server: {server_key}")
275
275
 
276
276
  return ProxyRegistrationCommandResult(
277
277
  operation="heartbeat",
@@ -318,7 +318,7 @@ class ProxyRegistrationCommand(Command):
318
318
  }
319
319
  proxies.append(proxy_info)
320
320
 
321
- logger.info(f"Discovery request returned {len(proxies)} active servers")
321
+ get_global_logger().info(f"Discovery request returned {len(proxies)} active servers")
322
322
 
323
323
  return ProxyRegistrationCommandResult(
324
324
  operation="discover",
@@ -13,7 +13,7 @@ from dataclasses import dataclass
13
13
 
14
14
  from mcp_proxy_adapter.commands.base import Command
15
15
  from mcp_proxy_adapter.commands.result import SuccessResult
16
- from mcp_proxy_adapter.core.logging import logger
16
+ from mcp_proxy_adapter.core.logging import get_global_logger
17
17
 
18
18
 
19
19
  @dataclass
@@ -79,7 +79,7 @@ class RegistrationStatusCommand(Command):
79
79
  Returns:
80
80
  RegistrationStatusCommandResult with current status
81
81
  """
82
- logger.info("Executing registration status command")
82
+ get_global_logger().info("Executing registration status command")
83
83
 
84
84
  try:
85
85
  from mcp_proxy_adapter.core.async_proxy_registration import (
@@ -88,7 +88,7 @@ class RegistrationStatusCommand(Command):
88
88
 
89
89
  status = get_registration_status()
90
90
 
91
- logger.info(f"Registration status retrieved: {status}")
91
+ get_global_logger().info(f"Registration status retrieved: {status}")
92
92
 
93
93
  return RegistrationStatusCommandResult(
94
94
  status=status,
@@ -96,7 +96,7 @@ class RegistrationStatusCommand(Command):
96
96
  )
97
97
 
98
98
  except Exception as e:
99
- logger.error(f"Failed to get registration status: {e}")
99
+ get_global_logger().error(f"Failed to get registration status: {e}")
100
100
 
101
101
  error_status = {
102
102
  "state": "error",