mcp-proxy-adapter 6.9.27__py3-none-any.whl โ†’ 6.9.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mcp-proxy-adapter might be problematic. Click here for more details.

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 +0 -6
  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 -912
  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.27.dist-info โ†’ mcp_proxy_adapter-6.9.29.dist-info}/METADATA +2 -1
  208. mcp_proxy_adapter-6.9.29.dist-info/RECORD +235 -0
  209. {mcp_proxy_adapter-6.9.27.dist-info โ†’ mcp_proxy_adapter-6.9.29.dist-info}/entry_points.txt +1 -1
  210. mcp_proxy_adapter-6.9.27.dist-info/RECORD +0 -149
  211. {mcp_proxy_adapter-6.9.27.dist-info โ†’ mcp_proxy_adapter-6.9.29.dist-info}/WHEEL +0 -0
  212. {mcp_proxy_adapter-6.9.27.dist-info โ†’ mcp_proxy_adapter-6.9.29.dist-info}/top_level.txt +0 -0
@@ -89,31 +89,8 @@ class FixedCertificateConfig(BaseModel):
89
89
 
90
90
  @field_validator("hash_algorithm")
91
91
  @classmethod
92
- def validate_hash_algorithm(cls, v):
93
- """Validate hash algorithm."""
94
- valid_algorithms = ["sha1", "sha256", "sha384", "sha512"]
95
- if v not in valid_algorithms:
96
- raise ValueError(
97
- f"Invalid hash algorithm. Must be one of: {valid_algorithms}"
98
- )
99
- return v
100
92
 
101
93
  @model_validator(mode="after")
102
- def validate_certificate_configuration(self):
103
- """Validate certificate configuration consistency."""
104
- if self.enabled:
105
- # BUGFIX: Only require CA paths if not in CA creation mode
106
- if not self.ca_creation_mode:
107
- if not self.ca_cert_path or not self.ca_key_path:
108
- raise ValueError(
109
- "Certificate management enabled but CA certificate and key paths are required. "
110
- "Set ca_creation_mode=True if you are creating a CA certificate."
111
- )
112
-
113
- if self.crl_enabled and not self.crl_path:
114
- raise ValueError("CRL enabled but CRL path is required")
115
-
116
- return self
117
94
 
118
95
 
119
96
  def create_patch_file():
@@ -12,13 +12,11 @@ import json
12
12
  import sys
13
13
  import os
14
14
  from pathlib import Path
15
- from typing import Dict, Any, List, Optional
16
15
 
17
16
  # Add the project root to the path
18
17
  sys.path.insert(0, str(Path(__file__).parent.parent.parent))
19
18
 
20
19
  from mcp_proxy_adapter.config import Config
21
- from mcp_proxy_adapter.examples.config_builder import ConfigBuilder, Protocol, AuthMethod
22
20
 
23
21
 
24
22
  class ConfigChecker:
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Author: Vasiliy Zdanovskiy
4
+ email: vasilyvz@gmail.com
5
+
6
+ Example of using JsonRpcClient library for MCP Proxy Adapter.
7
+
8
+ This example demonstrates:
9
+ - Basic client initialization
10
+ - Using built-in commands (echo, help, long_task, job_status)
11
+ - Using queue management commands (queue_add_job, queue_start_job, etc.)
12
+ - Error handling
13
+
14
+ Usage:
15
+ # Make sure server is running, then:
16
+ python -m mcp_proxy_adapter.examples.client_usage_example
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ import time
23
+ import uuid
24
+
25
+ from mcp_proxy_adapter.client.jsonrpc_client import JsonRpcClient
26
+
27
+
28
+ def example_builtin_commands(client: JsonRpcClient) -> None:
29
+ """Example of using built-in commands."""
30
+ print("\n" + "=" * 60)
31
+ print("๐Ÿ“‹ Example: Built-in Commands")
32
+ print("=" * 60)
33
+
34
+ # Echo command
35
+ print("\n1. Echo command:")
36
+ result = client.echo(message="Hello from client!")
37
+ print(f" Result: {json.dumps(result, ensure_ascii=False, indent=2)}")
38
+
39
+ # Help command
40
+ print("\n2. Help command:")
41
+ result = client.help()
42
+ print(f" Commands available: {len(result.get('data', {}).get('commands', []))}")
43
+
44
+ # Long task
45
+ print("\n3. Starting long task (5 seconds):")
46
+ result = client.long_task(seconds=5)
47
+ job_id = result.get("data", {}).get("job_id")
48
+ print(f" Job ID: {job_id}")
49
+
50
+ # Check job status
51
+ print("\n4. Checking job status:")
52
+ time.sleep(2)
53
+ result = client.job_status(job_id=job_id)
54
+ print(f" Status: {json.dumps(result, ensure_ascii=False, indent=2)}")
55
+
56
+ # Wait for completion
57
+ print("\n5. Waiting for task completion...")
58
+ time.sleep(4)
59
+ result = client.job_status(job_id=job_id)
60
+ status = result.get("data", {}).get("status")
61
+ print(f" Final status: {status}")
62
+
63
+
64
+ def example_queue_commands(client: JsonRpcClient) -> None:
65
+ """Example of using queue management commands."""
66
+ print("\n" + "=" * 60)
67
+ print("๐Ÿ“‹ Example: Queue Management Commands")
68
+ print("=" * 60)
69
+
70
+ job_id = f"example-{uuid.uuid4().hex[:8]}"
71
+
72
+ # Queue health
73
+ print("\n1. Queue health:")
74
+ try:
75
+ result = client.queue_health()
76
+ print(f" Result: {json.dumps(result, ensure_ascii=False, indent=2)}")
77
+ except RuntimeError as e:
78
+ print(f" โš ๏ธ Queue commands not available: {e}")
79
+ return
80
+
81
+ # Add job
82
+ print(f"\n2. Adding job (job_id={job_id}):")
83
+ result = client.queue_add_job(
84
+ job_type="long_running",
85
+ job_id=job_id,
86
+ params={"duration": 5, "task_type": "example_task"},
87
+ )
88
+ print(f" Result: {json.dumps(result, ensure_ascii=False, indent=2)}")
89
+
90
+ # Get job status (should be pending)
91
+ print("\n3. Getting job status (should be pending):")
92
+ result = client.queue_get_job_status(job_id=job_id)
93
+ print(f" Status: {json.dumps(result, ensure_ascii=False, indent=2)}")
94
+
95
+ # List jobs
96
+ print("\n4. Listing all jobs:")
97
+ result = client.queue_list_jobs()
98
+ print(f" Jobs count: {len(result.get('data', {}).get('jobs', []))}")
99
+
100
+ # Start job
101
+ print("\n5. Starting job:")
102
+ result = client.queue_start_job(job_id=job_id)
103
+ print(f" Result: {json.dumps(result, ensure_ascii=False, indent=2)}")
104
+
105
+ # Check status (should be running)
106
+ print("\n6. Checking status (should be running):")
107
+ time.sleep(1)
108
+ result = client.queue_get_job_status(job_id=job_id)
109
+ print(f" Status: {json.dumps(result, ensure_ascii=False, indent=2)}")
110
+
111
+ # Wait for completion
112
+ print("\n7. Waiting for job completion...")
113
+ time.sleep(6)
114
+ result = client.queue_get_job_status(job_id=job_id)
115
+ status = result.get("data", {}).get("status")
116
+ print(f" Final status: {status}")
117
+
118
+ # Delete job
119
+ print("\n8. Deleting job:")
120
+ result = client.queue_delete_job(job_id=job_id)
121
+ print(f" Result: {json.dumps(result, ensure_ascii=False, indent=2)}")
122
+
123
+
124
+ def main() -> None:
125
+ """Main example function."""
126
+ print("๐Ÿš€ JsonRpcClient Usage Example")
127
+ print("=" * 60)
128
+
129
+ # Initialize client (adjust protocol, host, port as needed)
130
+ client = JsonRpcClient(
131
+ protocol="http",
132
+ host="127.0.0.1",
133
+ port=8080,
134
+ )
135
+
136
+ # Check server health
137
+ print("\n๐Ÿ“ก Checking server health...")
138
+ try:
139
+ health = client.health()
140
+ print(f"โœ… Server is healthy: {json.dumps(health, ensure_ascii=False)}")
141
+ except Exception as e:
142
+ print(f"โŒ Server is not available: {e}")
143
+ print(" Make sure the server is running on http://127.0.0.1:8080")
144
+ return
145
+
146
+ # Run examples
147
+ try:
148
+ example_builtin_commands(client)
149
+ except Exception as e:
150
+ print(f"\nโŒ Error in built-in commands example: {e}")
151
+
152
+ try:
153
+ example_queue_commands(client)
154
+ except Exception as e:
155
+ print(f"\nโŒ Error in queue commands example: {e}")
156
+
157
+ print("\n" + "=" * 60)
158
+ print("โœ… Examples completed")
159
+ print("=" * 60)
160
+
161
+
162
+ if __name__ == "__main__":
163
+ main()
164
+
@@ -67,7 +67,8 @@ def generate_complete_config(host: str = "0.0.0.0", port: int = 8000) -> Dict[st
67
67
  },
68
68
  "proxy_registration": {
69
69
  "enabled": False,
70
- "proxy_url": "http://localhost:3004",
70
+ "protocol": "mtls",
71
+ "proxy_url": "https://172.28.0.10:3004",
71
72
  "server_id": "mcp_proxy_adapter",
72
73
  "server_name": "MCP Proxy Adapter",
73
74
  "description": "JSON-RPC API for interacting with MCP Proxy",
@@ -76,7 +77,17 @@ def generate_complete_config(host: str = "0.0.0.0", port: int = 8000) -> Dict[st
76
77
  "retry_attempts": 3,
77
78
  "retry_delay": 5,
78
79
  "auto_register_on_startup": True,
79
- "auto_unregister_on_shutdown": 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
+ }
80
91
  },
81
92
  "debug": {
82
93
  "enabled": False,
@@ -10,7 +10,6 @@ import argparse
10
10
  import json
11
11
  import sys
12
12
  from pathlib import Path
13
- from typing import Dict, Any, List, Optional
14
13
 
15
14
  from config_builder import ConfigBuilder, ConfigFactory, Protocol, AuthMethod
16
15
 
@@ -6,9 +6,7 @@ Author: Vasiliy Zdanovskiy
6
6
  email: vasilyvz@gmail.com
7
7
  """
8
8
  import json
9
- import uuid
10
9
  from pathlib import Path
11
- from typing import Dict, Any, Optional
12
10
 
13
11
  from config_builder import ConfigBuilder, ConfigFactory, Protocol, AuthMethod
14
12
 
@@ -158,50 +156,6 @@ class TestConfigGenerator:
158
156
  json.dump(roles_config, f, indent=2, ensure_ascii=False)
159
157
  print(f"โœ… Created roles.json: {roles_path}")
160
158
 
161
- def create_custom_config(self, name: str, protocol: str, auth: str = "none",
162
- port: int = 8000, **kwargs) -> Path:
163
- """
164
- Create a custom configuration.
165
-
166
- Args:
167
- name: Configuration name
168
- protocol: Protocol (http, https, mtls)
169
- auth: Authentication method (none, token, basic)
170
- port: Server port
171
- **kwargs: Additional configuration parameters
172
-
173
- Returns:
174
- Path to created configuration file
175
- """
176
- builder = ConfigBuilder()
177
-
178
- # Set basic server configuration
179
- builder.set_server(port=port, **kwargs.get('server', {}))
180
-
181
- # Set protocol
182
- protocol_enum = Protocol(protocol.lower())
183
- cert_dir = kwargs.get('cert_dir', str(self.output_dir.parent / "certs"))
184
- key_dir = kwargs.get('key_dir', str(self.output_dir.parent / "keys"))
185
- builder.set_protocol(protocol_enum, cert_dir=cert_dir, key_dir=key_dir)
186
-
187
- # Set authentication
188
- auth_enum = AuthMethod(auth.lower())
189
- api_keys = kwargs.get('api_keys')
190
- roles = kwargs.get('roles')
191
- builder.set_auth(auth_enum, api_keys=api_keys, roles=roles)
192
-
193
- # Set proxy registration if specified
194
- if kwargs.get('proxy_registration', False):
195
- proxy_url = kwargs.get('proxy_url', 'https://127.0.0.1:20005')
196
- server_id = kwargs.get('server_id', f'{name}_server')
197
- builder.set_proxy_registration(enabled=True, proxy_url=proxy_url, server_id=server_id, cert_dir=cert_dir)
198
-
199
- # Set debug if specified
200
- if kwargs.get('debug', False):
201
- builder.set_debug(enabled=True)
202
-
203
- config = builder.build()
204
- return self._save_config(name, config)
205
159
 
206
160
 
207
161
  def main():
@@ -13,7 +13,6 @@ from pathlib import Path
13
13
  # Add project root to path
14
14
  project_root = Path(__file__).parent.parent.parent
15
15
  sys.path.insert(0, str(project_root))
16
- from fastapi import FastAPI, Request
17
16
  from fastapi.testclient import TestClient
18
17
  from mcp_proxy_adapter.api.app import create_app
19
18
 
@@ -5,7 +5,6 @@ Author: Vasiliy Zdanovskiy
5
5
  email: vasilyvz@gmail.com
6
6
  """
7
7
 
8
- from typing import Dict, Any, Optional
9
8
  from mcp_proxy_adapter.commands.base import BaseCommand
10
9
  from mcp_proxy_adapter.commands.result import CommandResult
11
10
 
@@ -18,27 +17,7 @@ class CustomEchoResult(CommandResult):
18
17
  self.timestamp = timestamp
19
18
  self.echo_count = echo_count
20
19
 
21
- def to_dict(self) -> Dict[str, Any]:
22
- """Convert result to dictionary."""
23
- return {
24
- "message": self.message,
25
- "timestamp": self.timestamp,
26
- "echo_count": self.echo_count,
27
- "command_type": "custom_echo",
28
- }
29
20
 
30
- def get_schema(self) -> Dict[str, Any]:
31
- """Get result schema."""
32
- return {
33
- "type": "object",
34
- "properties": {
35
- "message": {"type": "string", "description": "Echoed message"},
36
- "timestamp": {"type": "string", "description": "Timestamp of echo"},
37
- "echo_count": {"type": "integer", "description": "Number of echoes"},
38
- "command_type": {"type": "string", "description": "Command type"},
39
- },
40
- "required": ["message", "timestamp", "echo_count", "command_type"],
41
- }
42
21
 
43
22
 
44
23
  class CustomEchoCommand(BaseCommand):
@@ -48,34 +27,8 @@ class CustomEchoCommand(BaseCommand):
48
27
  super().__init__()
49
28
  self.echo_count = 0
50
29
 
51
- def get_name(self) -> str:
52
- """Get command name."""
53
- return "custom_echo"
54
30
 
55
- def get_description(self) -> str:
56
- """Get command description."""
57
- return "Custom echo command with enhanced features"
58
31
 
59
- def get_schema(self) -> Dict[str, Any]:
60
- """Get command schema."""
61
- return {
62
- "type": "object",
63
- "properties": {
64
- "message": {
65
- "type": "string",
66
- "description": "Message to echo",
67
- "default": "Hello from custom echo!",
68
- },
69
- "repeat": {
70
- "type": "integer",
71
- "description": "Number of times to repeat",
72
- "default": 1,
73
- "minimum": 1,
74
- "maximum": 10,
75
- },
76
- },
77
- "required": ["message"],
78
- }
79
32
 
80
33
  async def execute(self, params: Dict[str, Any]) -> CustomEchoResult:
81
34
  """Execute the custom echo command."""
@@ -5,7 +5,6 @@ Author: Vasiliy Zdanovskiy
5
5
  email: vasilyvz@gmail.com
6
6
  """
7
7
 
8
- from typing import Dict, Any, Optional
9
8
  from mcp_proxy_adapter.commands.base import BaseCommand
10
9
  from mcp_proxy_adapter.commands.result import CommandResult
11
10
 
@@ -18,58 +17,14 @@ class CalculatorResult(CommandResult):
18
17
  self.result = result
19
18
  self.expression = expression
20
19
 
21
- def to_dict(self) -> Dict[str, Any]:
22
- """Convert result to dictionary."""
23
- return {
24
- "operation": self.operation,
25
- "result": self.result,
26
- "expression": self.expression,
27
- "command_type": "dynamic_calculator",
28
- }
29
20
 
30
- def get_schema(self) -> Dict[str, Any]:
31
- """Get result schema."""
32
- return {
33
- "type": "object",
34
- "properties": {
35
- "operation": {
36
- "type": "string",
37
- "description": "Mathematical operation",
38
- },
39
- "result": {"type": "number", "description": "Calculation result"},
40
- "expression": {"type": "string", "description": "Full expression"},
41
- "command_type": {"type": "string", "description": "Command type"},
42
- },
43
- "required": ["operation", "result", "expression", "command_type"],
44
- }
45
21
 
46
22
 
47
23
  class DynamicCalculatorCommand(BaseCommand):
48
24
  """Dynamic calculator command implementation."""
49
25
 
50
- def get_name(self) -> str:
51
- """Get command name."""
52
- return "dynamic_calculator"
53
26
 
54
- def get_description(self) -> str:
55
- """Get command description."""
56
- return "Dynamic calculator with basic mathematical operations"
57
27
 
58
- def get_schema(self) -> Dict[str, Any]:
59
- """Get command schema."""
60
- return {
61
- "type": "object",
62
- "properties": {
63
- "operation": {
64
- "type": "string",
65
- "description": "Mathematical operation (add, subtract, multiply, divide)",
66
- "enum": ["add", "subtract", "multiply", "divide"],
67
- },
68
- "a": {"type": "number", "description": "First number"},
69
- "b": {"type": "number", "description": "Second number"},
70
- },
71
- "required": ["operation", "a", "b"],
72
- }
73
28
 
74
29
  async def execute(self, params: Dict[str, Any]) -> CalculatorResult:
75
30
  """Execute the calculator command."""
@@ -14,18 +14,6 @@ class EchoCommand(BaseCommand):
14
14
  self.description = "Echo command that returns the input message"
15
15
  self.version = "1.0.0"
16
16
 
17
- def get_schema(self):
18
- """Get command schema."""
19
- return {
20
- "type": "object",
21
- "properties": {
22
- "message": {
23
- "type": "string",
24
- "description": "Message to echo back"
25
- }
26
- },
27
- "required": ["message"]
28
- }
29
17
 
30
18
  async def execute(self, params: dict) -> dict:
31
19
  """Execute echo command."""
@@ -14,18 +14,6 @@ class HelpCommand(BaseCommand):
14
14
  self.description = "Get help information"
15
15
  self.version = "1.0.0"
16
16
 
17
- def get_schema(self):
18
- """Get command schema."""
19
- return {
20
- "type": "object",
21
- "properties": {
22
- "command": {
23
- "type": "string",
24
- "description": "Command name to get help for (optional)"
25
- }
26
- },
27
- "required": []
28
- }
29
17
 
30
18
  async def execute(self, params: dict) -> dict:
31
19
  """Execute help command."""
@@ -14,13 +14,6 @@ class ListCommand(BaseCommand):
14
14
  self.description = "List available commands"
15
15
  self.version = "1.0.0"
16
16
 
17
- def get_schema(self):
18
- """Get command schema."""
19
- return {
20
- "type": "object",
21
- "properties": {},
22
- "required": []
23
- }
24
17
 
25
18
  async def execute(self, params: dict) -> dict:
26
19
  """Execute list command."""
@@ -3,5 +3,3 @@
3
3
  Application and command hooks for the full application example.
4
4
  """
5
5
 
6
- from .application_hooks import ApplicationHooks
7
- from .builtin_command_hooks import BuiltinCommandHooks
@@ -6,7 +6,6 @@ email: vasilyvz@gmail.com
6
6
  """
7
7
 
8
8
  import logging
9
- from typing import Dict, Any, Optional
10
9
  from datetime import datetime
11
10
 
12
11
  logger = logging.getLogger(__name__)
@@ -16,73 +15,15 @@ class ApplicationHooks:
16
15
  """Application-level hooks."""
17
16
 
18
17
  @staticmethod
19
- def on_startup():
20
- """Hook executed on application startup."""
21
- get_global_logger().info("๐Ÿš€ Application startup hook executed")
22
- # Initialize application-specific resources
23
- get_global_logger().info("๐Ÿ“Š Initializing application metrics")
24
- get_global_logger().info("๐Ÿ” Loading security configurations")
25
- get_global_logger().info("๐Ÿ“ Setting up logging")
26
18
 
27
19
  @staticmethod
28
- def on_shutdown():
29
- """Hook executed on application shutdown."""
30
- get_global_logger().info("๐Ÿ›‘ Application shutdown hook executed")
31
- # Cleanup application resources
32
- get_global_logger().info("๐Ÿงน Cleaning up resources")
33
- get_global_logger().info("๐Ÿ’พ Saving application state")
34
- get_global_logger().info("๐Ÿ“Š Finalizing metrics")
35
20
 
36
21
  @staticmethod
37
- def before_request(request_data: Dict[str, Any]) -> Dict[str, Any]:
38
- """Hook executed before processing any request."""
39
- get_global_logger().info(f"๐Ÿ”ง Application hook: before_request with data: {request_data}")
40
- # Add request metadata
41
- request_data["app_metadata"] = {
42
- "request_id": f"req_{datetime.now().timestamp()}",
43
- "timestamp": datetime.now().isoformat(),
44
- "application": "full_application_example",
45
- }
46
- return request_data
47
22
 
48
23
  @staticmethod
49
- def after_request(result: Dict[str, Any]) -> Dict[str, Any]:
50
- """Hook executed after processing any request."""
51
- get_global_logger().info(f"๐Ÿ”ง Application hook: after_request with result: {result}")
52
- # Add response metadata
53
- result["app_response_metadata"] = {
54
- "processed_at": datetime.now().isoformat(),
55
- "application": "full_application_example",
56
- "version": "1.0.0",
57
- }
58
- return result
59
24
 
60
25
  @staticmethod
61
- def on_error(error: Exception, context: Dict[str, Any]):
62
- """Hook executed when an error occurs."""
63
- get_global_logger().error(f"๐Ÿ”ง Application hook: on_error - {error} in context: {context}")
64
- # Log error details
65
- get_global_logger().error(f"Error type: {type(error).__name__}")
66
- get_global_logger().error(f"Error message: {str(error)}")
67
- get_global_logger().error(f"Context: {context}")
68
26
 
69
27
  @staticmethod
70
- def on_command_registered(command_name: str, command_info: Dict[str, Any]):
71
- """Hook executed when a command is registered."""
72
- get_global_logger().info(f"๐Ÿ”ง Application hook: on_command_registered - {command_name}")
73
- get_global_logger().info(f"Command info: {command_info}")
74
- # Track registered commands
75
- get_global_logger().info(f"๐Ÿ“ Command '{command_name}' registered successfully")
76
28
 
77
29
  @staticmethod
78
- def on_command_executed(command_name: str, execution_time: float, success: bool):
79
- """Hook executed when a command is executed."""
80
- get_global_logger().info(f"๐Ÿ”ง Application hook: on_command_executed - {command_name}")
81
- get_global_logger().info(f"Execution time: {execution_time}s, Success: {success}")
82
- # Track command execution metrics
83
- if success:
84
- get_global_logger().info(
85
- f"โœ… Command '{command_name}' executed successfully in {execution_time}s"
86
- )
87
- else:
88
- get_global_logger().warning(f"โš ๏ธ Command '{command_name}' failed after {execution_time}s")
@@ -6,7 +6,6 @@ email: vasilyvz@gmail.com
6
6
  """
7
7
 
8
8
  import logging
9
- from typing import Dict, Any, Optional
10
9
  from datetime import datetime
11
10
 
12
11
  logger = logging.getLogger(__name__)
@@ -16,66 +15,13 @@ class BuiltinCommandHooks:
16
15
  """Hooks for built-in commands."""
17
16
 
18
17
  @staticmethod
19
- def before_echo_command(params: Dict[str, Any]) -> Dict[str, Any]:
20
- """Hook executed before echo command."""
21
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: before_echo_command with params: {params}")
22
- # Add timestamp to message
23
- if "message" in params:
24
- timestamp = datetime.now().isoformat()
25
- params["message"] = f"[{timestamp}] {params['message']}"
26
- return params
27
18
 
28
19
  @staticmethod
29
- def after_echo_command(result: Dict[str, Any]) -> Dict[str, Any]:
30
- """Hook executed after echo command."""
31
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: after_echo_command with result: {result}")
32
- # Add hook metadata
33
- result["hook_metadata"] = {
34
- "hook_type": "builtin_after_echo",
35
- "timestamp": datetime.now().isoformat(),
36
- "processed": True,
37
- }
38
- return result
39
20
 
40
21
  @staticmethod
41
- def before_health_command(params: Dict[str, Any]) -> Dict[str, Any]:
42
- """Hook executed before health command."""
43
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: before_health_command with params: {params}")
44
- # Add custom health check parameters
45
- params["include_detailed_info"] = True
46
- params["check_dependencies"] = True
47
- return params
48
22
 
49
23
  @staticmethod
50
- def after_health_command(result: Dict[str, Any]) -> Dict[str, Any]:
51
- """Hook executed after health command."""
52
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: after_health_command with result: {result}")
53
- # Add custom health metrics
54
- if "status" in result and result["status"] == "healthy":
55
- result["custom_metrics"] = {
56
- "uptime": "24h",
57
- "memory_usage": "45%",
58
- "cpu_usage": "12%",
59
- }
60
- return result
61
24
 
62
25
  @staticmethod
63
- def before_config_command(params: Dict[str, Any]) -> Dict[str, Any]:
64
- """Hook executed before config command."""
65
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: before_config_command with params: {params}")
66
- # Add configuration validation
67
- params["validate_config"] = True
68
- params["include_secrets"] = False
69
- return params
70
26
 
71
27
  @staticmethod
72
- def after_config_command(result: Dict[str, Any]) -> Dict[str, Any]:
73
- """Hook executed after config command."""
74
- get_global_logger().info(f"๐Ÿ”ง Built-in hook: after_config_command with result: {result}")
75
- # Add configuration metadata
76
- result["config_metadata"] = {
77
- "last_modified": datetime.now().isoformat(),
78
- "version": "1.0.0",
79
- "environment": "development",
80
- }
81
- return result