mcp-proxy-adapter 2.0.1__py3-none-any.whl → 6.9.50__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 (269) hide show
  1. mcp_proxy_adapter/__init__.py +47 -0
  2. mcp_proxy_adapter/__main__.py +13 -0
  3. mcp_proxy_adapter/api/__init__.py +0 -0
  4. mcp_proxy_adapter/api/app.py +66 -0
  5. mcp_proxy_adapter/api/core/__init__.py +18 -0
  6. mcp_proxy_adapter/api/core/app_factory.py +400 -0
  7. mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
  8. mcp_proxy_adapter/api/core/registration_context.py +356 -0
  9. mcp_proxy_adapter/api/core/registration_manager.py +307 -0
  10. mcp_proxy_adapter/api/core/registration_tasks.py +84 -0
  11. mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
  12. mcp_proxy_adapter/api/handlers.py +181 -0
  13. mcp_proxy_adapter/api/middleware/__init__.py +21 -0
  14. mcp_proxy_adapter/api/middleware/base.py +54 -0
  15. mcp_proxy_adapter/api/middleware/command_permission_middleware.py +73 -0
  16. mcp_proxy_adapter/api/middleware/error_handling.py +76 -0
  17. mcp_proxy_adapter/api/middleware/factory.py +147 -0
  18. mcp_proxy_adapter/api/middleware/logging.py +31 -0
  19. mcp_proxy_adapter/api/middleware/performance.py +51 -0
  20. mcp_proxy_adapter/api/middleware/protocol_middleware.py +140 -0
  21. mcp_proxy_adapter/api/middleware/transport_middleware.py +87 -0
  22. mcp_proxy_adapter/api/middleware/unified_security.py +223 -0
  23. mcp_proxy_adapter/api/middleware/user_info_middleware.py +132 -0
  24. mcp_proxy_adapter/api/openapi/__init__.py +21 -0
  25. mcp_proxy_adapter/api/openapi/command_integration.py +105 -0
  26. mcp_proxy_adapter/api/openapi/openapi_generator.py +40 -0
  27. mcp_proxy_adapter/api/openapi/openapi_registry.py +62 -0
  28. mcp_proxy_adapter/api/openapi/schema_loader.py +116 -0
  29. mcp_proxy_adapter/api/schemas.py +270 -0
  30. mcp_proxy_adapter/api/tool_integration.py +131 -0
  31. mcp_proxy_adapter/api/tools.py +163 -0
  32. mcp_proxy_adapter/cli/__init__.py +12 -0
  33. mcp_proxy_adapter/cli/commands/__init__.py +15 -0
  34. mcp_proxy_adapter/cli/commands/client.py +100 -0
  35. mcp_proxy_adapter/cli/commands/config_generate.py +105 -0
  36. mcp_proxy_adapter/cli/commands/config_validate.py +94 -0
  37. mcp_proxy_adapter/cli/commands/generate.py +259 -0
  38. mcp_proxy_adapter/cli/commands/server.py +174 -0
  39. mcp_proxy_adapter/cli/commands/sets.py +132 -0
  40. mcp_proxy_adapter/cli/commands/testconfig.py +177 -0
  41. mcp_proxy_adapter/cli/examples/__init__.py +8 -0
  42. mcp_proxy_adapter/cli/examples/http_basic.py +82 -0
  43. mcp_proxy_adapter/cli/examples/https_token.py +96 -0
  44. mcp_proxy_adapter/cli/examples/mtls_roles.py +103 -0
  45. mcp_proxy_adapter/cli/main.py +63 -0
  46. mcp_proxy_adapter/cli/parser.py +338 -0
  47. mcp_proxy_adapter/cli/validators.py +231 -0
  48. mcp_proxy_adapter/client/jsonrpc_client/__init__.py +9 -0
  49. mcp_proxy_adapter/client/jsonrpc_client/client.py +42 -0
  50. mcp_proxy_adapter/client/jsonrpc_client/command_api.py +45 -0
  51. mcp_proxy_adapter/client/jsonrpc_client/proxy_api.py +224 -0
  52. mcp_proxy_adapter/client/jsonrpc_client/queue_api.py +60 -0
  53. mcp_proxy_adapter/client/jsonrpc_client/transport.py +108 -0
  54. mcp_proxy_adapter/client/proxy.py +123 -0
  55. mcp_proxy_adapter/commands/__init__.py +66 -0
  56. mcp_proxy_adapter/commands/auth_validation_command.py +69 -0
  57. mcp_proxy_adapter/commands/base.py +389 -0
  58. mcp_proxy_adapter/commands/builtin_commands.py +30 -0
  59. mcp_proxy_adapter/commands/catalog/__init__.py +20 -0
  60. mcp_proxy_adapter/commands/catalog/catalog_loader.py +34 -0
  61. mcp_proxy_adapter/commands/catalog/catalog_manager.py +122 -0
  62. mcp_proxy_adapter/commands/catalog/catalog_syncer.py +149 -0
  63. mcp_proxy_adapter/commands/catalog/command_catalog.py +43 -0
  64. mcp_proxy_adapter/commands/catalog/dependency_manager.py +37 -0
  65. mcp_proxy_adapter/commands/catalog_manager.py +97 -0
  66. mcp_proxy_adapter/commands/cert_monitor_command.py +552 -0
  67. mcp_proxy_adapter/commands/certificate_management_command.py +562 -0
  68. mcp_proxy_adapter/commands/command_registry.py +298 -0
  69. mcp_proxy_adapter/commands/config_command.py +102 -0
  70. mcp_proxy_adapter/commands/dependency_container.py +40 -0
  71. mcp_proxy_adapter/commands/dependency_manager.py +143 -0
  72. mcp_proxy_adapter/commands/echo_command.py +48 -0
  73. mcp_proxy_adapter/commands/health_command.py +142 -0
  74. mcp_proxy_adapter/commands/help_command.py +175 -0
  75. mcp_proxy_adapter/commands/hooks.py +172 -0
  76. mcp_proxy_adapter/commands/key_management_command.py +484 -0
  77. mcp_proxy_adapter/commands/load_command.py +123 -0
  78. mcp_proxy_adapter/commands/plugins_command.py +246 -0
  79. mcp_proxy_adapter/commands/protocol_management_command.py +216 -0
  80. mcp_proxy_adapter/commands/proxy_registration_command.py +319 -0
  81. mcp_proxy_adapter/commands/queue_commands.py +750 -0
  82. mcp_proxy_adapter/commands/registration_status_command.py +76 -0
  83. mcp_proxy_adapter/commands/registry/__init__.py +18 -0
  84. mcp_proxy_adapter/commands/registry/command_info.py +103 -0
  85. mcp_proxy_adapter/commands/registry/command_loader.py +207 -0
  86. mcp_proxy_adapter/commands/registry/command_manager.py +119 -0
  87. mcp_proxy_adapter/commands/registry/command_registry.py +217 -0
  88. mcp_proxy_adapter/commands/reload_command.py +136 -0
  89. mcp_proxy_adapter/commands/result.py +157 -0
  90. mcp_proxy_adapter/commands/role_test_command.py +99 -0
  91. mcp_proxy_adapter/commands/roles_management_command.py +502 -0
  92. mcp_proxy_adapter/commands/security_command.py +472 -0
  93. mcp_proxy_adapter/commands/settings_command.py +113 -0
  94. mcp_proxy_adapter/commands/ssl_setup_command.py +306 -0
  95. mcp_proxy_adapter/commands/token_management_command.py +500 -0
  96. mcp_proxy_adapter/commands/transport_management_command.py +129 -0
  97. mcp_proxy_adapter/commands/unload_command.py +92 -0
  98. mcp_proxy_adapter/config.py +32 -0
  99. mcp_proxy_adapter/core/__init__.py +8 -0
  100. mcp_proxy_adapter/core/app_factory.py +560 -0
  101. mcp_proxy_adapter/core/app_runner.py +318 -0
  102. mcp_proxy_adapter/core/auth_validator.py +508 -0
  103. mcp_proxy_adapter/core/certificate/__init__.py +20 -0
  104. mcp_proxy_adapter/core/certificate/certificate_creator.py +372 -0
  105. mcp_proxy_adapter/core/certificate/certificate_extractor.py +185 -0
  106. mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
  107. mcp_proxy_adapter/core/certificate/certificate_validator.py +481 -0
  108. mcp_proxy_adapter/core/certificate/ssl_context_manager.py +65 -0
  109. mcp_proxy_adapter/core/certificate_utils.py +249 -0
  110. mcp_proxy_adapter/core/client.py +608 -0
  111. mcp_proxy_adapter/core/client_manager.py +271 -0
  112. mcp_proxy_adapter/core/client_security.py +411 -0
  113. mcp_proxy_adapter/core/config/__init__.py +18 -0
  114. mcp_proxy_adapter/core/config/config.py +237 -0
  115. mcp_proxy_adapter/core/config/config_factory.py +22 -0
  116. mcp_proxy_adapter/core/config/config_loader.py +66 -0
  117. mcp_proxy_adapter/core/config/feature_manager.py +31 -0
  118. mcp_proxy_adapter/core/config/simple_config.py +204 -0
  119. mcp_proxy_adapter/core/config/simple_config_generator.py +131 -0
  120. mcp_proxy_adapter/core/config/simple_config_validator.py +476 -0
  121. mcp_proxy_adapter/core/config_converter.py +252 -0
  122. mcp_proxy_adapter/core/config_validator.py +211 -0
  123. mcp_proxy_adapter/core/crl_utils.py +362 -0
  124. mcp_proxy_adapter/core/errors.py +276 -0
  125. mcp_proxy_adapter/core/job_manager.py +54 -0
  126. mcp_proxy_adapter/core/logging.py +250 -0
  127. mcp_proxy_adapter/core/mtls_asgi.py +140 -0
  128. mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
  129. mcp_proxy_adapter/core/mtls_proxy.py +229 -0
  130. mcp_proxy_adapter/core/mtls_server.py +154 -0
  131. mcp_proxy_adapter/core/protocol_manager.py +232 -0
  132. mcp_proxy_adapter/core/proxy/__init__.py +19 -0
  133. mcp_proxy_adapter/core/proxy/auth_manager.py +26 -0
  134. mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +160 -0
  135. mcp_proxy_adapter/core/proxy/registration_client.py +186 -0
  136. mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
  137. mcp_proxy_adapter/core/proxy_client.py +184 -0
  138. mcp_proxy_adapter/core/proxy_registration.py +80 -0
  139. mcp_proxy_adapter/core/role_utils.py +103 -0
  140. mcp_proxy_adapter/core/security_adapter.py +343 -0
  141. mcp_proxy_adapter/core/security_factory.py +96 -0
  142. mcp_proxy_adapter/core/security_integration.py +342 -0
  143. mcp_proxy_adapter/core/server_adapter.py +251 -0
  144. mcp_proxy_adapter/core/server_engine.py +217 -0
  145. mcp_proxy_adapter/core/settings.py +260 -0
  146. mcp_proxy_adapter/core/signal_handler.py +107 -0
  147. mcp_proxy_adapter/core/ssl_utils.py +161 -0
  148. mcp_proxy_adapter/core/transport_manager.py +153 -0
  149. mcp_proxy_adapter/core/unified_config_adapter.py +471 -0
  150. mcp_proxy_adapter/core/utils.py +101 -0
  151. mcp_proxy_adapter/core/validation/__init__.py +21 -0
  152. mcp_proxy_adapter/core/validation/config_validator.py +219 -0
  153. mcp_proxy_adapter/core/validation/file_validator.py +131 -0
  154. mcp_proxy_adapter/core/validation/protocol_validator.py +205 -0
  155. mcp_proxy_adapter/core/validation/security_validator.py +140 -0
  156. mcp_proxy_adapter/core/validation/validation_result.py +27 -0
  157. mcp_proxy_adapter/custom_openapi.py +58 -0
  158. mcp_proxy_adapter/examples/__init__.py +16 -0
  159. mcp_proxy_adapter/examples/basic_framework/__init__.py +9 -0
  160. mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
  161. mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
  162. mcp_proxy_adapter/examples/basic_framework/main.py +52 -0
  163. mcp_proxy_adapter/examples/bugfix_certificate_config.py +261 -0
  164. mcp_proxy_adapter/examples/cert_manager_bugfix.py +203 -0
  165. mcp_proxy_adapter/examples/check_config.py +413 -0
  166. mcp_proxy_adapter/examples/client_usage_example.py +164 -0
  167. mcp_proxy_adapter/examples/commands/__init__.py +5 -0
  168. mcp_proxy_adapter/examples/config_builder.py +234 -0
  169. mcp_proxy_adapter/examples/config_cli.py +282 -0
  170. mcp_proxy_adapter/examples/create_test_configs.py +174 -0
  171. mcp_proxy_adapter/examples/debug_request_state.py +130 -0
  172. mcp_proxy_adapter/examples/debug_role_chain.py +191 -0
  173. mcp_proxy_adapter/examples/demo_client.py +287 -0
  174. mcp_proxy_adapter/examples/full_application/__init__.py +12 -0
  175. mcp_proxy_adapter/examples/full_application/commands/__init__.py +8 -0
  176. mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +45 -0
  177. mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +52 -0
  178. mcp_proxy_adapter/examples/full_application/commands/echo_command.py +32 -0
  179. mcp_proxy_adapter/examples/full_application/commands/help_command.py +54 -0
  180. mcp_proxy_adapter/examples/full_application/commands/list_command.py +57 -0
  181. mcp_proxy_adapter/examples/full_application/hooks/__init__.py +5 -0
  182. mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +29 -0
  183. mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +27 -0
  184. mcp_proxy_adapter/examples/full_application/main.py +311 -0
  185. mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +161 -0
  186. mcp_proxy_adapter/examples/full_application/run_mtls.py +252 -0
  187. mcp_proxy_adapter/examples/full_application/run_simple.py +152 -0
  188. mcp_proxy_adapter/examples/full_application/test_minimal_server.py +45 -0
  189. mcp_proxy_adapter/examples/full_application/test_server.py +163 -0
  190. mcp_proxy_adapter/examples/full_application/test_simple_server.py +62 -0
  191. mcp_proxy_adapter/examples/generate_config.py +502 -0
  192. mcp_proxy_adapter/examples/proxy_registration_example.py +335 -0
  193. mcp_proxy_adapter/examples/queue_demo_simple.py +632 -0
  194. mcp_proxy_adapter/examples/queue_integration_example.py +578 -0
  195. mcp_proxy_adapter/examples/queue_server_demo.py +82 -0
  196. mcp_proxy_adapter/examples/queue_server_example.py +85 -0
  197. mcp_proxy_adapter/examples/queue_server_simple.py +173 -0
  198. mcp_proxy_adapter/examples/required_certificates.py +208 -0
  199. mcp_proxy_adapter/examples/run_example.py +77 -0
  200. mcp_proxy_adapter/examples/run_full_test_suite.py +619 -0
  201. mcp_proxy_adapter/examples/run_proxy_server.py +153 -0
  202. mcp_proxy_adapter/examples/run_security_tests_fixed.py +435 -0
  203. mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
  204. mcp_proxy_adapter/examples/security_test/auth_manager.py +14 -0
  205. mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +28 -0
  206. mcp_proxy_adapter/examples/security_test/test_client.py +159 -0
  207. mcp_proxy_adapter/examples/security_test/test_result.py +22 -0
  208. mcp_proxy_adapter/examples/security_test_client.py +72 -0
  209. mcp_proxy_adapter/examples/setup/__init__.py +24 -0
  210. mcp_proxy_adapter/examples/setup/certificate_manager.py +215 -0
  211. mcp_proxy_adapter/examples/setup/config_generator.py +12 -0
  212. mcp_proxy_adapter/examples/setup/config_validator.py +118 -0
  213. mcp_proxy_adapter/examples/setup/environment_setup.py +62 -0
  214. mcp_proxy_adapter/examples/setup/test_files_generator.py +10 -0
  215. mcp_proxy_adapter/examples/setup/test_runner.py +89 -0
  216. mcp_proxy_adapter/examples/setup_test_environment.py +235 -0
  217. mcp_proxy_adapter/examples/simple_protocol_test.py +125 -0
  218. mcp_proxy_adapter/examples/test_chk_hostname_automated.py +211 -0
  219. mcp_proxy_adapter/examples/test_config.py +205 -0
  220. mcp_proxy_adapter/examples/test_config_builder.py +110 -0
  221. mcp_proxy_adapter/examples/test_examples.py +308 -0
  222. mcp_proxy_adapter/examples/test_framework_complete.py +267 -0
  223. mcp_proxy_adapter/examples/test_mcp_server.py +187 -0
  224. mcp_proxy_adapter/examples/test_protocol_examples.py +337 -0
  225. mcp_proxy_adapter/examples/universal_client.py +674 -0
  226. mcp_proxy_adapter/examples/update_config_certificates.py +135 -0
  227. mcp_proxy_adapter/examples/validate_generator_compatibility.py +385 -0
  228. mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +61 -0
  229. mcp_proxy_adapter/integrations/__init__.py +25 -0
  230. mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
  231. mcp_proxy_adapter/main.py +311 -0
  232. mcp_proxy_adapter/openapi.py +375 -0
  233. mcp_proxy_adapter/schemas/base_schema.json +114 -0
  234. mcp_proxy_adapter/schemas/openapi_schema.json +314 -0
  235. mcp_proxy_adapter/schemas/roles.json +37 -0
  236. mcp_proxy_adapter/schemas/roles_schema.json +162 -0
  237. mcp_proxy_adapter/version.py +5 -0
  238. mcp_proxy_adapter-6.9.50.dist-info/METADATA +1088 -0
  239. mcp_proxy_adapter-6.9.50.dist-info/RECORD +242 -0
  240. {mcp_proxy_adapter-2.0.1.dist-info → mcp_proxy_adapter-6.9.50.dist-info}/WHEEL +1 -1
  241. mcp_proxy_adapter-6.9.50.dist-info/entry_points.txt +14 -0
  242. mcp_proxy_adapter-6.9.50.dist-info/top_level.txt +1 -0
  243. adapters/__init__.py +0 -16
  244. analyzers/__init__.py +0 -14
  245. analyzers/docstring_analyzer.py +0 -199
  246. analyzers/type_analyzer.py +0 -151
  247. cli/__init__.py +0 -12
  248. cli/__main__.py +0 -79
  249. cli/command_runner.py +0 -233
  250. dispatchers/__init__.py +0 -14
  251. dispatchers/base_dispatcher.py +0 -85
  252. dispatchers/json_rpc_dispatcher.py +0 -198
  253. generators/__init__.py +0 -14
  254. generators/endpoint_generator.py +0 -172
  255. generators/openapi_generator.py +0 -254
  256. generators/rest_api_generator.py +0 -207
  257. mcp_proxy_adapter-2.0.1.dist-info/METADATA +0 -272
  258. mcp_proxy_adapter-2.0.1.dist-info/RECORD +0 -28
  259. mcp_proxy_adapter-2.0.1.dist-info/licenses/LICENSE +0 -21
  260. mcp_proxy_adapter-2.0.1.dist-info/top_level.txt +0 -7
  261. openapi_schema/__init__.py +0 -38
  262. openapi_schema/command_registry.py +0 -312
  263. openapi_schema/rest_schema.py +0 -510
  264. openapi_schema/rpc_generator.py +0 -307
  265. openapi_schema/rpc_schema.py +0 -416
  266. validators/__init__.py +0 -14
  267. validators/base_validator.py +0 -23
  268. validators/docstring_validator.py +0 -75
  269. validators/metadata_validator.py +0 -76
@@ -0,0 +1,234 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Simple Configuration Generator for MCP Proxy Adapter
4
+ Generates a complete configuration with HTTP protocol and all restrictions disabled.
5
+
6
+ Author: Vasiliy Zdanovskiy
7
+ email: vasilyvz@gmail.com
8
+ """
9
+
10
+ import json
11
+ import uuid
12
+ import argparse
13
+ from pathlib import Path
14
+ from typing import Dict, Any
15
+
16
+
17
+ def generate_complete_config(host: str = "0.0.0.0", port: int = 8000) -> Dict[str, Any]:
18
+ """
19
+ Generate a complete configuration with all required sections.
20
+ HTTP protocol with all security features disabled.
21
+
22
+ Args:
23
+ host: Server host
24
+ port: Server port
25
+
26
+ Returns:
27
+ Complete configuration dictionary
28
+ """
29
+ return {
30
+ "uuid": str(uuid.uuid4()), # This generates valid UUID4
31
+ "server": {
32
+ "host": host,
33
+ "port": port,
34
+ "protocol": "http",
35
+ "debug": False,
36
+ "log_level": "INFO"
37
+ },
38
+ "logging": {
39
+ "level": "INFO",
40
+ "file": None,
41
+ "log_dir": "./logs",
42
+ "log_file": "mcp_proxy_adapter.log",
43
+ "error_log_file": "mcp_proxy_adapter_error.log",
44
+ "access_log_file": "mcp_proxy_adapter_access.log",
45
+ "max_file_size": "10MB",
46
+ "backup_count": 5,
47
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
48
+ "date_format": "%Y-%m-%d %H:%M:%S",
49
+ "console_output": True,
50
+ "file_output": True
51
+ },
52
+ "commands": {
53
+ "auto_discovery": True,
54
+ "commands_directory": "./commands",
55
+ "catalog_directory": "./catalog",
56
+ "plugin_servers": [],
57
+ "auto_install_dependencies": True,
58
+ "enabled_commands": ["health", "echo", "list", "help"],
59
+ "disabled_commands": [],
60
+ "custom_commands_path": "./commands"
61
+ },
62
+ "transport": {
63
+ "type": "http",
64
+ "port": None,
65
+ "verify_client": False,
66
+ "chk_hostname": False
67
+ },
68
+ "proxy_registration": {
69
+ "enabled": False,
70
+ "protocol": "mtls",
71
+ "proxy_url": "https://172.28.0.10:3004",
72
+ "server_id": "mcp_proxy_adapter",
73
+ "server_name": "MCP Proxy Adapter",
74
+ "description": "JSON-RPC API for interacting with MCP Proxy",
75
+ "version": "6.2.33",
76
+ "registration_timeout": 30,
77
+ "retry_attempts": 3,
78
+ "retry_delay": 5,
79
+ "auto_register_on_startup": True,
80
+ "auto_unregister_on_shutdown": True,
81
+ "verify_ssl": True,
82
+ "verify_hostname": False,
83
+ "heartbeat": {
84
+ "enabled": True,
85
+ "interval": 30,
86
+ "timeout": 10,
87
+ "retry_attempts": 3,
88
+ "retry_delay": 5,
89
+ "url": "/heartbeat"
90
+ }
91
+ },
92
+ "debug": {
93
+ "enabled": False,
94
+ "level": "WARNING"
95
+ },
96
+ "ssl": {
97
+ "enabled": False,
98
+ "cert_file": None,
99
+ "key_file": None,
100
+ "ca_cert": None
101
+ },
102
+ "security": {
103
+ "enabled": False,
104
+ "tokens": {},
105
+ "roles": {},
106
+ "roles_file": None
107
+ },
108
+ "roles": {
109
+ "enabled": False,
110
+ "config_file": None,
111
+ "default_policy": {
112
+ "deny_by_default": False,
113
+ "require_role_match": False,
114
+ "case_sensitive": False,
115
+ "allow_wildcard": False
116
+ },
117
+ "auto_load": False,
118
+ "validation_enabled": False
119
+ }
120
+ }
121
+
122
+
123
+ def save_config(config: Dict[str, Any], output_file: str) -> None:
124
+ """
125
+ Save configuration to file.
126
+
127
+ Args:
128
+ config: Configuration dictionary
129
+ output_file: Output file path
130
+ """
131
+ output_path = Path(output_file)
132
+ output_path.parent.mkdir(parents=True, exist_ok=True)
133
+
134
+ with open(output_path, 'w', encoding='utf-8') as f:
135
+ json.dump(config, f, indent=2, ensure_ascii=False)
136
+
137
+ print(f"āœ… Configuration saved to: {output_path}")
138
+
139
+
140
+ def main():
141
+ """Main function to generate configuration."""
142
+ parser = argparse.ArgumentParser(
143
+ description="Generate complete MCP Proxy Adapter configuration",
144
+ formatter_class=argparse.RawDescriptionHelpFormatter,
145
+ epilog="""
146
+ Examples:
147
+ python config_builder.py
148
+ python config_builder.py --host 127.0.0.1 --port 9000
149
+ python config_builder.py --output ./configs/my_config.json
150
+ """
151
+ )
152
+
153
+ parser.add_argument(
154
+ "--host",
155
+ default="0.0.0.0",
156
+ help="Server host (default: 0.0.0.0)"
157
+ )
158
+
159
+ parser.add_argument(
160
+ "--port",
161
+ type=int,
162
+ default=8000,
163
+ help="Server port (default: 8000)"
164
+ )
165
+
166
+ parser.add_argument(
167
+ "--output",
168
+ default="config.json",
169
+ help="Output file path (default: config.json)"
170
+ )
171
+
172
+ parser.add_argument(
173
+ "--validate",
174
+ action="store_true",
175
+ help="Validate generated configuration"
176
+ )
177
+
178
+ args = parser.parse_args()
179
+
180
+ print("šŸ”§ Generating MCP Proxy Adapter configuration...")
181
+ print(f" Host: {args.host}")
182
+ print(f" Port: {args.port}")
183
+ print(f" Protocol: HTTP")
184
+ print(f" Security: Disabled")
185
+ print(f" SSL: Disabled")
186
+ print(f" Roles: Disabled")
187
+ print()
188
+
189
+ # Generate configuration
190
+ config = generate_complete_config(args.host, args.port)
191
+
192
+ # Save configuration
193
+ save_config(config, args.output)
194
+
195
+ # Validate if requested
196
+ if args.validate:
197
+ print("\nšŸ” Validating configuration...")
198
+ try:
199
+ from mcp_proxy_adapter.core.config_validator import ConfigValidator
200
+
201
+ validator = ConfigValidator()
202
+ validator.config_data = config
203
+ results = validator.validate_config()
204
+
205
+ if results:
206
+ print("āš ļø Validation issues found:")
207
+ for result in results:
208
+ level_symbol = {
209
+ "error": "āŒ",
210
+ "warning": "āš ļø",
211
+ "info": "ā„¹ļø"
212
+ }[result.level]
213
+ print(f" {level_symbol} {result.message}")
214
+ if result.suggestion:
215
+ print(f" Suggestion: {result.suggestion}")
216
+ else:
217
+ print("āœ… Configuration validation passed!")
218
+
219
+ except ImportError:
220
+ print("āš ļø Configuration validation not available")
221
+ except Exception as e:
222
+ print(f"āŒ Validation error: {e}")
223
+
224
+ print(f"\nšŸ“‹ Configuration summary:")
225
+ print(f" - Server: {config['server']['host']}:{config['server']['port']}")
226
+ print(f" - Protocol: {config['server']['protocol']}")
227
+ print(f" - Security: {'Enabled' if config['security']['enabled'] else 'Disabled'}")
228
+ print(f" - SSL: {'Enabled' if config.get('ssl', {}).get('enabled', False) else 'Disabled'}")
229
+ print(f" - Roles: {'Enabled' if config['roles']['enabled'] else 'Disabled'}")
230
+ print(f" - Proxy Registration: {'Enabled' if config['proxy_registration']['enabled'] else 'Disabled'}")
231
+
232
+
233
+ if __name__ == "__main__":
234
+ main()
@@ -0,0 +1,282 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ CLI Utility for MCP Proxy Adapter Configuration Builder
4
+ Command-line interface for creating configurations with various parameters.
5
+
6
+ Author: Vasiliy Zdanovskiy
7
+ email: vasilyvz@gmail.com
8
+ """
9
+ import argparse
10
+ import json
11
+ import sys
12
+ from pathlib import Path
13
+
14
+ from config_builder import ConfigBuilder, ConfigFactory, Protocol, AuthMethod
15
+
16
+
17
+ def parse_protocol(protocol_str: str) -> Protocol:
18
+ """Parse protocol string to Protocol enum."""
19
+ protocol_map = {
20
+ "http": Protocol.HTTP,
21
+ "https": Protocol.HTTPS,
22
+ "mtls": Protocol.MTLS
23
+ }
24
+ if protocol_str.lower() not in protocol_map:
25
+ raise ValueError(f"Invalid protocol: {protocol_str}. Must be one of: {list(protocol_map.keys())}")
26
+ return protocol_map[protocol_str.lower()]
27
+
28
+
29
+ def parse_auth_method(auth_str: str) -> AuthMethod:
30
+ """Parse authentication method string to AuthMethod enum."""
31
+ auth_map = {
32
+ "none": AuthMethod.NONE,
33
+ "token": AuthMethod.TOKEN,
34
+ "basic": AuthMethod.BASIC
35
+ }
36
+ if auth_str.lower() not in auth_map:
37
+ raise ValueError(f"Invalid auth method: {auth_str}. Must be one of: {list(auth_map.keys())}")
38
+ return auth_map[auth_str.lower()]
39
+
40
+
41
+ def parse_api_keys(api_keys_str: str) -> Dict[str, str]:
42
+ """Parse API keys from string format 'key1:value1,key2:value2'."""
43
+ if not api_keys_str:
44
+ return {}
45
+
46
+ api_keys = {}
47
+ for pair in api_keys_str.split(','):
48
+ if ':' not in pair:
49
+ raise ValueError(f"Invalid API key format: {pair}. Expected 'key:value'")
50
+ key, value = pair.split(':', 1)
51
+ api_keys[key.strip()] = value.strip()
52
+
53
+ return api_keys
54
+
55
+
56
+ def parse_roles(roles_str: str) -> Dict[str, List[str]]:
57
+ """Parse roles from string format 'role1:perm1,perm2;role2:perm3,perm4'."""
58
+ if not roles_str:
59
+ return {}
60
+
61
+ roles = {}
62
+ for role_def in roles_str.split(';'):
63
+ if ':' not in role_def:
64
+ raise ValueError(f"Invalid role format: {role_def}. Expected 'role:perm1,perm2'")
65
+ role, perms = role_def.split(':', 1)
66
+ roles[role.strip()] = [perm.strip() for perm in perms.split(',')]
67
+
68
+ return roles
69
+
70
+
71
+ def create_custom_config(args) -> Dict[str, Any]:
72
+ """Create custom configuration based on command line arguments."""
73
+ builder = ConfigBuilder()
74
+
75
+ # Set server configuration
76
+ builder.set_server(
77
+ host=args.host,
78
+ port=args.port,
79
+ debug=args.debug,
80
+ log_level=args.log_level
81
+ )
82
+
83
+ # Set logging configuration
84
+ builder.set_logging(
85
+ log_dir=args.log_dir,
86
+ level=args.log_level,
87
+ console_output=not args.no_console,
88
+ file_output=not args.no_file_log
89
+ )
90
+
91
+ # Set protocol
92
+ protocol = parse_protocol(args.protocol)
93
+ builder.set_protocol(
94
+ protocol,
95
+ cert_dir=args.cert_dir,
96
+ key_dir=args.key_dir
97
+ )
98
+
99
+ # Set authentication
100
+ auth_method = parse_auth_method(args.auth)
101
+ api_keys = parse_api_keys(args.api_keys) if args.api_keys else None
102
+ roles = parse_roles(args.roles) if args.roles else None
103
+
104
+ builder.set_auth(auth_method, api_keys=api_keys, roles=roles)
105
+
106
+ # Set proxy registration
107
+ if args.proxy_url:
108
+ builder.set_proxy_registration(
109
+ enabled=True,
110
+ proxy_url=args.proxy_url,
111
+ server_id=args.server_id,
112
+ cert_dir=args.cert_dir
113
+ )
114
+
115
+ # Set debug
116
+ if args.debug:
117
+ builder.set_debug(enabled=True, log_level=args.log_level)
118
+
119
+ # Set commands
120
+ if args.enabled_commands or args.disabled_commands:
121
+ enabled = args.enabled_commands.split(',') if args.enabled_commands else None
122
+ disabled = args.disabled_commands.split(',') if args.disabled_commands else None
123
+ builder.set_commands(enabled_commands=enabled, disabled_commands=disabled)
124
+
125
+ return builder.build()
126
+
127
+
128
+ def create_preset_config(preset: str, **kwargs) -> Dict[str, Any]:
129
+ """Create preset configuration."""
130
+ preset_map = {
131
+ "http_simple": ConfigFactory.create_http_simple,
132
+ "http_token": ConfigFactory.create_http_token,
133
+ "https_simple": ConfigFactory.create_https_simple,
134
+ "https_token": ConfigFactory.create_https_token,
135
+ "mtls_simple": ConfigFactory.create_mtls_simple,
136
+ "mtls_with_roles": ConfigFactory.create_mtls_with_roles,
137
+ "mtls_with_proxy": ConfigFactory.create_mtls_with_proxy,
138
+ "full_featured": ConfigFactory.create_full_featured,
139
+ }
140
+
141
+ if preset not in preset_map:
142
+ raise ValueError(f"Invalid preset: {preset}. Must be one of: {list(preset_map.keys())}")
143
+
144
+ return preset_map[preset](**kwargs)
145
+
146
+
147
+ def list_presets():
148
+ """List available presets."""
149
+ presets = [
150
+ ("http_simple", "Simple HTTP server without authentication"),
151
+ ("http_token", "HTTP server with token authentication"),
152
+ ("https_simple", "Simple HTTPS server without authentication"),
153
+ ("https_token", "HTTPS server with token authentication"),
154
+ ("mtls_simple", "Simple mTLS server without authentication"),
155
+ ("mtls_with_roles", "mTLS server with role-based access control"),
156
+ ("mtls_with_proxy", "mTLS server with proxy registration"),
157
+ ("full_featured", "Full-featured server with all options enabled"),
158
+ ]
159
+
160
+ print("šŸ“‹ Available Configuration Presets:")
161
+ print("=" * 50)
162
+ for preset, description in presets:
163
+ print(f" {preset:<20} - {description}")
164
+
165
+
166
+ def main():
167
+ """Main CLI function."""
168
+ parser = argparse.ArgumentParser(
169
+ description="MCP Proxy Adapter Configuration Builder CLI",
170
+ formatter_class=argparse.RawDescriptionHelpFormatter,
171
+ epilog="""
172
+ Examples:
173
+ # Create HTTP simple configuration
174
+ python config_cli.py --preset http_simple --output configs/http_simple.json
175
+
176
+ # Create custom HTTPS configuration with token auth
177
+ python config_cli.py --protocol https --auth token --api-keys "admin:admin-key,user:user-key" --output configs/https_token.json
178
+
179
+ # Create mTLS configuration with proxy registration
180
+ python config_cli.py --protocol mtls --proxy-url "https://proxy.example.com:8080" --server-id "my_server" --output configs/mtls_proxy.json
181
+
182
+ # List all available presets
183
+ python config_cli.py --list-presets
184
+ """
185
+ )
186
+
187
+ # Main options
188
+ parser.add_argument("--preset", help="Use a preset configuration")
189
+ parser.add_argument("--list-presets", action="store_true", help="List available presets")
190
+ parser.add_argument("--output", "-o", help="Output file path (default: stdout)")
191
+
192
+ # Server configuration
193
+ parser.add_argument("--host", default="0.0.0.0", help="Server host (default: 0.0.0.0)")
194
+ parser.add_argument("--port", type=int, default=8000, help="Server port (default: 8000)")
195
+ parser.add_argument("--debug", action="store_true", help="Enable debug mode")
196
+ parser.add_argument("--log-level", default="INFO", choices=["DEBUG", "INFO", "WARNING", "ERROR"], help="Log level (default: INFO)")
197
+
198
+ # Logging configuration
199
+ parser.add_argument("--log-dir", default="./logs", help="Log directory (default: ./logs)")
200
+ parser.add_argument("--no-console", action="store_true", help="Disable console output")
201
+ parser.add_argument("--no-file-log", action="store_true", help="Disable file logging")
202
+
203
+ # Protocol configuration
204
+ parser.add_argument("--protocol", choices=["http", "https", "mtls"], default="http", help="Protocol (default: http)")
205
+ parser.add_argument("--cert-dir", default="./certs", help="Certificate directory (default: ./certs)")
206
+ parser.add_argument("--key-dir", default="./keys", help="Key directory (default: ./keys)")
207
+
208
+ # Authentication configuration
209
+ parser.add_argument("--auth", choices=["none", "token", "basic"], default="none", help="Authentication method (default: none)")
210
+ parser.add_argument("--api-keys", help="API keys in format 'key1:value1,key2:value2'")
211
+ parser.add_argument("--roles", help="Roles in format 'role1:perm1,perm2;role2:perm3,perm4'")
212
+
213
+ # Proxy registration
214
+ parser.add_argument("--proxy-url", help="Proxy URL for registration")
215
+ parser.add_argument("--server-id", default="mcp_proxy_adapter", help="Server ID for proxy registration (default: mcp_proxy_adapter)")
216
+
217
+ # Commands configuration
218
+ parser.add_argument("--enabled-commands", help="Comma-separated list of enabled commands")
219
+ parser.add_argument("--disabled-commands", help="Comma-separated list of disabled commands")
220
+
221
+ # Preset-specific options
222
+ parser.add_argument("--preset-host", help="Host for preset configurations")
223
+ parser.add_argument("--preset-port", type=int, help="Port for preset configurations")
224
+ parser.add_argument("--preset-log-dir", help="Log directory for preset configurations")
225
+ parser.add_argument("--preset-cert-dir", help="Certificate directory for preset configurations")
226
+ parser.add_argument("--preset-key-dir", help="Key directory for preset configurations")
227
+ parser.add_argument("--preset-proxy-url", help="Proxy URL for preset configurations")
228
+ parser.add_argument("--preset-server-id", help="Server ID for preset configurations")
229
+
230
+ args = parser.parse_args()
231
+
232
+ try:
233
+ # Handle list presets
234
+ if args.list_presets:
235
+ list_presets()
236
+ return 0
237
+
238
+ # Create configuration
239
+ if args.preset:
240
+ # Use preset configuration
241
+ preset_kwargs = {}
242
+ if args.preset_host:
243
+ preset_kwargs["host"] = args.preset_host
244
+ if args.preset_port:
245
+ preset_kwargs["port"] = args.preset_port
246
+ if args.preset_log_dir:
247
+ preset_kwargs["log_dir"] = args.preset_log_dir
248
+ if args.preset_cert_dir:
249
+ preset_kwargs["cert_dir"] = args.preset_cert_dir
250
+ if args.preset_key_dir:
251
+ preset_kwargs["key_dir"] = args.preset_key_dir
252
+ if args.preset_proxy_url:
253
+ preset_kwargs["proxy_url"] = args.preset_proxy_url
254
+ if args.preset_server_id:
255
+ preset_kwargs["server_id"] = args.preset_server_id
256
+
257
+ config = create_preset_config(args.preset, **preset_kwargs)
258
+ else:
259
+ # Create custom configuration
260
+ config = create_custom_config(args)
261
+
262
+ # Output configuration
263
+ config_json = json.dumps(config, indent=2, ensure_ascii=False)
264
+
265
+ if args.output:
266
+ output_path = Path(args.output)
267
+ output_path.parent.mkdir(parents=True, exist_ok=True)
268
+ with open(output_path, 'w', encoding='utf-8') as f:
269
+ f.write(config_json)
270
+ print(f"āœ… Configuration saved to: {output_path}")
271
+ else:
272
+ print(config_json)
273
+
274
+ return 0
275
+
276
+ except Exception as e:
277
+ print(f"āŒ Error: {e}", file=sys.stderr)
278
+ return 1
279
+
280
+
281
+ if __name__ == "__main__":
282
+ sys.exit(main())
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test Configuration Generator
4
+ Creates test configurations using the advanced ConfigBuilder utility.
5
+ Author: Vasiliy Zdanovskiy
6
+ email: vasilyvz@gmail.com
7
+ """
8
+ import json
9
+ from pathlib import Path
10
+
11
+ from config_builder import ConfigBuilder, ConfigFactory, Protocol, AuthMethod
12
+
13
+
14
+ class TestConfigGenerator:
15
+ """Generator for test configurations using ConfigBuilder."""
16
+
17
+ def __init__(self, output_dir: str = "configs"):
18
+ """
19
+ Initialize the generator.
20
+
21
+ Args:
22
+ output_dir: Directory to output test configurations
23
+ """
24
+ self.output_dir = Path(output_dir)
25
+ self.output_dir.mkdir(exist_ok=True)
26
+
27
+ def _save_config(self, name: str, config: Dict[str, Any]) -> Path:
28
+ """Save configuration to file."""
29
+ output_path = self.output_dir / f"{name}.json"
30
+ with open(output_path, 'w', encoding='utf-8') as f:
31
+ json.dump(config, f, indent=2, ensure_ascii=False)
32
+ print(f"āœ… Created test config: {output_path}")
33
+ return output_path
34
+
35
+ def create_all_test_configs(self):
36
+ """Create all standard test configurations using ConfigFactory."""
37
+ print("šŸ”§ Creating test configurations using ConfigBuilder...")
38
+
39
+ # Create output directory
40
+ self.output_dir.mkdir(exist_ok=True)
41
+
42
+ # 1. HTTP Simple
43
+ config = ConfigFactory.create_http_simple(port=20020, log_dir=str(self.output_dir.parent / "logs"))
44
+ self._save_config("http_simple", config)
45
+
46
+ # 2. HTTP with Token Auth
47
+ api_keys = {
48
+ "admin": "admin-secret-key",
49
+ "user": "user-secret-key"
50
+ }
51
+ config = ConfigFactory.create_http_token(port=20021, log_dir=str(self.output_dir.parent / "logs"), api_keys=api_keys)
52
+ self._save_config("http_token", config)
53
+
54
+ # 3. HTTPS Simple
55
+ config = ConfigFactory.create_https_simple(
56
+ port=20022,
57
+ log_dir=str(self.output_dir.parent / "logs"),
58
+ cert_dir=str(self.output_dir.parent / "certs"),
59
+ key_dir=str(self.output_dir.parent / "keys")
60
+ )
61
+ self._save_config("https_simple", config)
62
+
63
+ # 4. HTTPS with Token Auth
64
+ config = ConfigFactory.create_https_token(
65
+ port=20023,
66
+ log_dir=str(self.output_dir.parent / "logs"),
67
+ cert_dir=str(self.output_dir.parent / "certs"),
68
+ key_dir=str(self.output_dir.parent / "keys"),
69
+ api_keys=api_keys
70
+ )
71
+ self._save_config("https_token", config)
72
+
73
+ # 5. mTLS Simple
74
+ config = ConfigFactory.create_mtls_simple(
75
+ port=20024,
76
+ log_dir=str(self.output_dir.parent / "logs"),
77
+ cert_dir=str(self.output_dir.parent / "certs"),
78
+ key_dir=str(self.output_dir.parent / "keys")
79
+ )
80
+ self._save_config("mtls_simple", config)
81
+
82
+ # 6. mTLS with Roles
83
+ roles = {
84
+ "admin": ["read", "write", "delete", "admin"],
85
+ "user": ["read", "write"],
86
+ "guest": ["read"]
87
+ }
88
+ config = ConfigFactory.create_mtls_with_roles(
89
+ port=20025,
90
+ log_dir=str(self.output_dir.parent / "logs"),
91
+ cert_dir=str(self.output_dir.parent / "certs"),
92
+ key_dir=str(self.output_dir.parent / "keys"),
93
+ roles=roles
94
+ )
95
+ self._save_config("mtls_with_roles", config)
96
+
97
+ # 7. mTLS with Proxy Registration
98
+ config = ConfigFactory.create_mtls_with_proxy(
99
+ port=20026,
100
+ log_dir=str(self.output_dir.parent / "logs"),
101
+ cert_dir=str(self.output_dir.parent / "certs"),
102
+ key_dir=str(self.output_dir.parent / "keys"),
103
+ proxy_url="https://127.0.0.1:20005",
104
+ server_id="mcp_test_server"
105
+ )
106
+ self._save_config("mtls_with_proxy", config)
107
+
108
+ # 8. Full Featured Configuration
109
+ config = ConfigFactory.create_full_featured(
110
+ port=20027,
111
+ log_dir=str(self.output_dir.parent / "logs"),
112
+ cert_dir=str(self.output_dir.parent / "certs"),
113
+ key_dir=str(self.output_dir.parent / "keys"),
114
+ proxy_url="https://127.0.0.1:20005",
115
+ server_id="mcp_full_server"
116
+ )
117
+ self._save_config("full_featured", config)
118
+
119
+ # 9. Additional configurations for comprehensive testing
120
+
121
+ # mTLS No Roles (for testing without role-based access)
122
+ config = ConfigFactory.create_mtls_simple(
123
+ port=20028,
124
+ log_dir=str(self.output_dir.parent / "logs"),
125
+ cert_dir=str(self.output_dir.parent / "certs"),
126
+ key_dir=str(self.output_dir.parent / "keys")
127
+ )
128
+ self._save_config("mtls_no_roles", config)
129
+
130
+ print(f"āœ… Created {len(list(self.output_dir.glob('*.json')))} test configurations in {self.output_dir}/")
131
+
132
+ # Create roles.json file for role-based configurations
133
+ self._create_roles_file(roles)
134
+
135
+ def _create_roles_file(self, roles: Dict[str, list]):
136
+ """Create roles.json file for role-based access control."""
137
+ roles_config = {
138
+ "enabled": True,
139
+ "default_policy": {
140
+ "deny_by_default": False,
141
+ "require_role_match": False,
142
+ "case_sensitive": False,
143
+ "allow_wildcard": False
144
+ },
145
+ "roles": roles,
146
+ "permissions": {
147
+ "read": ["GET"],
148
+ "write": ["POST", "PUT", "PATCH"],
149
+ "delete": ["DELETE"],
150
+ "admin": ["*"]
151
+ }
152
+ }
153
+
154
+ roles_path = self.output_dir / "roles.json"
155
+ with open(roles_path, 'w', encoding='utf-8') as f:
156
+ json.dump(roles_config, f, indent=2, ensure_ascii=False)
157
+ print(f"āœ… Created roles.json: {roles_path}")
158
+
159
+
160
+
161
+ def main():
162
+ """Main function to create all test configurations."""
163
+ print("šŸ”§ Creating Test Configurations")
164
+ print("=" * 40)
165
+
166
+ generator = TestConfigGenerator()
167
+ generator.create_all_test_configs()
168
+
169
+ print("\nšŸŽ‰ All test configurations created successfully!")
170
+ print(f"šŸ“ Output directory: {generator.output_dir}")
171
+
172
+
173
+ if __name__ == "__main__":
174
+ main()