mcp-proxy-adapter 6.0.0__py3-none-any.whl → 6.0.1__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 (212) hide show
  1. mcp_proxy_adapter/__main__.py +27 -7
  2. mcp_proxy_adapter/api/app.py +209 -79
  3. mcp_proxy_adapter/api/handlers.py +16 -5
  4. mcp_proxy_adapter/api/middleware/__init__.py +14 -9
  5. mcp_proxy_adapter/api/middleware/command_permission_middleware.py +148 -0
  6. mcp_proxy_adapter/api/middleware/factory.py +36 -12
  7. mcp_proxy_adapter/api/middleware/protocol_middleware.py +84 -18
  8. mcp_proxy_adapter/api/middleware/unified_security.py +197 -0
  9. mcp_proxy_adapter/api/middleware/user_info_middleware.py +158 -0
  10. mcp_proxy_adapter/commands/__init__.py +7 -1
  11. mcp_proxy_adapter/commands/base.py +7 -4
  12. mcp_proxy_adapter/commands/builtin_commands.py +8 -2
  13. mcp_proxy_adapter/commands/command_registry.py +8 -0
  14. mcp_proxy_adapter/commands/echo_command.py +81 -0
  15. mcp_proxy_adapter/commands/health_command.py +1 -1
  16. mcp_proxy_adapter/commands/help_command.py +21 -14
  17. mcp_proxy_adapter/commands/proxy_registration_command.py +326 -185
  18. mcp_proxy_adapter/commands/role_test_command.py +141 -0
  19. mcp_proxy_adapter/commands/security_command.py +488 -0
  20. mcp_proxy_adapter/commands/ssl_setup_command.py +234 -351
  21. mcp_proxy_adapter/commands/token_management_command.py +1 -1
  22. mcp_proxy_adapter/config.py +323 -40
  23. mcp_proxy_adapter/core/app_factory.py +410 -0
  24. mcp_proxy_adapter/core/app_runner.py +272 -0
  25. mcp_proxy_adapter/core/certificate_utils.py +291 -73
  26. mcp_proxy_adapter/core/client.py +574 -0
  27. mcp_proxy_adapter/core/client_manager.py +284 -0
  28. mcp_proxy_adapter/core/client_security.py +384 -0
  29. mcp_proxy_adapter/core/logging.py +8 -3
  30. mcp_proxy_adapter/core/mtls_asgi.py +156 -0
  31. mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
  32. mcp_proxy_adapter/core/protocol_manager.py +169 -10
  33. mcp_proxy_adapter/core/proxy_client.py +602 -0
  34. mcp_proxy_adapter/core/proxy_registration.py +299 -47
  35. mcp_proxy_adapter/core/security_adapter.py +12 -15
  36. mcp_proxy_adapter/core/security_integration.py +286 -0
  37. mcp_proxy_adapter/core/server_adapter.py +282 -0
  38. mcp_proxy_adapter/core/server_engine.py +270 -0
  39. mcp_proxy_adapter/core/ssl_utils.py +13 -12
  40. mcp_proxy_adapter/core/transport_manager.py +5 -5
  41. mcp_proxy_adapter/core/unified_config_adapter.py +579 -0
  42. mcp_proxy_adapter/examples/__init__.py +13 -4
  43. mcp_proxy_adapter/examples/basic_framework/__init__.py +9 -0
  44. mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
  45. mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
  46. mcp_proxy_adapter/examples/basic_framework/main.py +44 -0
  47. mcp_proxy_adapter/examples/commands/__init__.py +5 -0
  48. mcp_proxy_adapter/examples/create_certificates_simple.py +550 -0
  49. mcp_proxy_adapter/examples/debug_request_state.py +112 -0
  50. mcp_proxy_adapter/examples/debug_role_chain.py +158 -0
  51. mcp_proxy_adapter/examples/demo_client.py +275 -0
  52. mcp_proxy_adapter/examples/examples/basic_framework/__init__.py +9 -0
  53. mcp_proxy_adapter/examples/examples/basic_framework/commands/__init__.py +4 -0
  54. mcp_proxy_adapter/examples/examples/basic_framework/hooks/__init__.py +4 -0
  55. mcp_proxy_adapter/examples/examples/basic_framework/main.py +44 -0
  56. mcp_proxy_adapter/examples/examples/full_application/__init__.py +12 -0
  57. mcp_proxy_adapter/examples/examples/full_application/commands/__init__.py +7 -0
  58. mcp_proxy_adapter/examples/examples/full_application/commands/custom_echo_command.py +80 -0
  59. mcp_proxy_adapter/examples/examples/full_application/commands/dynamic_calculator_command.py +90 -0
  60. mcp_proxy_adapter/examples/examples/full_application/hooks/__init__.py +7 -0
  61. mcp_proxy_adapter/examples/examples/full_application/hooks/application_hooks.py +75 -0
  62. mcp_proxy_adapter/examples/examples/full_application/hooks/builtin_command_hooks.py +71 -0
  63. mcp_proxy_adapter/examples/examples/full_application/main.py +173 -0
  64. mcp_proxy_adapter/examples/examples/full_application/proxy_endpoints.py +154 -0
  65. mcp_proxy_adapter/examples/full_application/__init__.py +12 -0
  66. mcp_proxy_adapter/examples/full_application/commands/__init__.py +7 -0
  67. mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +80 -0
  68. mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +90 -0
  69. mcp_proxy_adapter/examples/full_application/hooks/__init__.py +7 -0
  70. mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +75 -0
  71. mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +71 -0
  72. mcp_proxy_adapter/examples/full_application/main.py +173 -0
  73. mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +154 -0
  74. mcp_proxy_adapter/examples/generate_all_certificates.py +362 -0
  75. mcp_proxy_adapter/examples/generate_certificates.py +177 -0
  76. mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +369 -0
  77. mcp_proxy_adapter/examples/generate_test_configs.py +331 -0
  78. mcp_proxy_adapter/examples/proxy_registration_example.py +334 -0
  79. mcp_proxy_adapter/examples/run_example.py +59 -0
  80. mcp_proxy_adapter/examples/run_full_test_suite.py +318 -0
  81. mcp_proxy_adapter/examples/run_proxy_server.py +146 -0
  82. mcp_proxy_adapter/examples/run_security_tests.py +544 -0
  83. mcp_proxy_adapter/examples/run_security_tests_fixed.py +247 -0
  84. mcp_proxy_adapter/examples/scripts/config_generator.py +740 -0
  85. mcp_proxy_adapter/examples/scripts/create_certificates_simple.py +560 -0
  86. mcp_proxy_adapter/examples/scripts/generate_certificates_and_tokens.py +369 -0
  87. mcp_proxy_adapter/examples/security_test_client.py +782 -0
  88. mcp_proxy_adapter/examples/setup_test_environment.py +328 -0
  89. mcp_proxy_adapter/examples/test_config.py +148 -0
  90. mcp_proxy_adapter/examples/test_config_generator.py +86 -0
  91. mcp_proxy_adapter/examples/test_examples.py +281 -0
  92. mcp_proxy_adapter/examples/universal_client.py +620 -0
  93. mcp_proxy_adapter/main.py +66 -148
  94. mcp_proxy_adapter/utils/config_generator.py +1008 -0
  95. mcp_proxy_adapter/version.py +5 -2
  96. mcp_proxy_adapter-6.0.1.dist-info/METADATA +679 -0
  97. mcp_proxy_adapter-6.0.1.dist-info/RECORD +140 -0
  98. mcp_proxy_adapter-6.0.1.dist-info/entry_points.txt +2 -0
  99. {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/licenses/LICENSE +2 -2
  100. mcp_proxy_adapter/api/middleware/auth.py +0 -146
  101. mcp_proxy_adapter/api/middleware/auth_adapter.py +0 -235
  102. mcp_proxy_adapter/api/middleware/mtls_adapter.py +0 -305
  103. mcp_proxy_adapter/api/middleware/mtls_middleware.py +0 -296
  104. mcp_proxy_adapter/api/middleware/rate_limit.py +0 -152
  105. mcp_proxy_adapter/api/middleware/rate_limit_adapter.py +0 -241
  106. mcp_proxy_adapter/api/middleware/roles_adapter.py +0 -365
  107. mcp_proxy_adapter/api/middleware/roles_middleware.py +0 -381
  108. mcp_proxy_adapter/api/middleware/security.py +0 -376
  109. mcp_proxy_adapter/api/middleware/token_auth_middleware.py +0 -261
  110. mcp_proxy_adapter/examples/README.md +0 -124
  111. mcp_proxy_adapter/examples/basic_server/README.md +0 -60
  112. mcp_proxy_adapter/examples/basic_server/__init__.py +0 -7
  113. mcp_proxy_adapter/examples/basic_server/basic_custom_settings.json +0 -39
  114. mcp_proxy_adapter/examples/basic_server/config.json +0 -70
  115. mcp_proxy_adapter/examples/basic_server/config_all_protocols.json +0 -54
  116. mcp_proxy_adapter/examples/basic_server/config_http.json +0 -70
  117. mcp_proxy_adapter/examples/basic_server/config_http_only.json +0 -52
  118. mcp_proxy_adapter/examples/basic_server/config_https.json +0 -58
  119. mcp_proxy_adapter/examples/basic_server/config_mtls.json +0 -58
  120. mcp_proxy_adapter/examples/basic_server/config_ssl.json +0 -46
  121. mcp_proxy_adapter/examples/basic_server/custom_settings_example.py +0 -238
  122. mcp_proxy_adapter/examples/basic_server/server.py +0 -114
  123. mcp_proxy_adapter/examples/custom_commands/README.md +0 -127
  124. mcp_proxy_adapter/examples/custom_commands/__init__.py +0 -27
  125. mcp_proxy_adapter/examples/custom_commands/advanced_hooks.py +0 -566
  126. mcp_proxy_adapter/examples/custom_commands/auto_commands/__init__.py +0 -6
  127. mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_echo_command.py +0 -103
  128. mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_info_command.py +0 -111
  129. mcp_proxy_adapter/examples/custom_commands/auto_commands/test_command.py +0 -105
  130. mcp_proxy_adapter/examples/custom_commands/catalog/commands/test_command.py +0 -129
  131. mcp_proxy_adapter/examples/custom_commands/config.json +0 -118
  132. mcp_proxy_adapter/examples/custom_commands/config_all_protocols.json +0 -46
  133. mcp_proxy_adapter/examples/custom_commands/config_https_only.json +0 -46
  134. mcp_proxy_adapter/examples/custom_commands/config_https_transport.json +0 -33
  135. mcp_proxy_adapter/examples/custom_commands/config_mtls_only.json +0 -46
  136. mcp_proxy_adapter/examples/custom_commands/config_mtls_transport.json +0 -33
  137. mcp_proxy_adapter/examples/custom_commands/config_single_transport.json +0 -33
  138. mcp_proxy_adapter/examples/custom_commands/custom_health_command.py +0 -169
  139. mcp_proxy_adapter/examples/custom_commands/custom_help_command.py +0 -215
  140. mcp_proxy_adapter/examples/custom_commands/custom_openapi_generator.py +0 -76
  141. mcp_proxy_adapter/examples/custom_commands/custom_settings.json +0 -96
  142. mcp_proxy_adapter/examples/custom_commands/custom_settings_manager.py +0 -241
  143. mcp_proxy_adapter/examples/custom_commands/data_transform_command.py +0 -135
  144. mcp_proxy_adapter/examples/custom_commands/echo_command.py +0 -122
  145. mcp_proxy_adapter/examples/custom_commands/full_help_response.json +0 -1
  146. mcp_proxy_adapter/examples/custom_commands/generated_openapi.json +0 -629
  147. mcp_proxy_adapter/examples/custom_commands/get_openapi.py +0 -103
  148. mcp_proxy_adapter/examples/custom_commands/hooks.py +0 -230
  149. mcp_proxy_adapter/examples/custom_commands/intercept_command.py +0 -123
  150. mcp_proxy_adapter/examples/custom_commands/loadable_commands/test_ignored.py +0 -129
  151. mcp_proxy_adapter/examples/custom_commands/manual_echo_command.py +0 -103
  152. mcp_proxy_adapter/examples/custom_commands/proxy_connection_manager.py +0 -278
  153. mcp_proxy_adapter/examples/custom_commands/server.py +0 -252
  154. mcp_proxy_adapter/examples/custom_commands/simple_openapi_server.py +0 -75
  155. mcp_proxy_adapter/examples/custom_commands/start_server_with_proxy_manager.py +0 -299
  156. mcp_proxy_adapter/examples/custom_commands/start_server_with_registration.py +0 -278
  157. mcp_proxy_adapter/examples/custom_commands/test_hooks.py +0 -176
  158. mcp_proxy_adapter/examples/custom_commands/test_openapi.py +0 -27
  159. mcp_proxy_adapter/examples/custom_commands/test_registry.py +0 -23
  160. mcp_proxy_adapter/examples/custom_commands/test_simple.py +0 -19
  161. mcp_proxy_adapter/examples/custom_project_example/README.md +0 -103
  162. mcp_proxy_adapter/examples/custom_project_example/README_EN.md +0 -103
  163. mcp_proxy_adapter/examples/deployment/README.md +0 -49
  164. mcp_proxy_adapter/examples/deployment/__init__.py +0 -7
  165. mcp_proxy_adapter/examples/deployment/config.development.json +0 -8
  166. mcp_proxy_adapter/examples/deployment/config.json +0 -29
  167. mcp_proxy_adapter/examples/deployment/config.production.json +0 -12
  168. mcp_proxy_adapter/examples/deployment/config.staging.json +0 -11
  169. mcp_proxy_adapter/examples/deployment/docker-compose.yml +0 -31
  170. mcp_proxy_adapter/examples/deployment/run.sh +0 -43
  171. mcp_proxy_adapter/examples/deployment/run_docker.sh +0 -84
  172. mcp_proxy_adapter/examples/simple_custom_commands/README.md +0 -149
  173. mcp_proxy_adapter/examples/simple_custom_commands/README_EN.md +0 -149
  174. mcp_proxy_adapter/schemas/base_schema.json +0 -114
  175. mcp_proxy_adapter/schemas/openapi_schema.json +0 -314
  176. mcp_proxy_adapter/schemas/roles_schema.json +0 -162
  177. mcp_proxy_adapter/tests/__init__.py +0 -0
  178. mcp_proxy_adapter/tests/api/__init__.py +0 -3
  179. mcp_proxy_adapter/tests/api/test_cmd_endpoint.py +0 -115
  180. mcp_proxy_adapter/tests/api/test_custom_openapi.py +0 -617
  181. mcp_proxy_adapter/tests/api/test_handlers.py +0 -522
  182. mcp_proxy_adapter/tests/api/test_middleware.py +0 -340
  183. mcp_proxy_adapter/tests/api/test_schemas.py +0 -546
  184. mcp_proxy_adapter/tests/api/test_tool_integration.py +0 -531
  185. mcp_proxy_adapter/tests/commands/__init__.py +0 -3
  186. mcp_proxy_adapter/tests/commands/test_config_command.py +0 -211
  187. mcp_proxy_adapter/tests/commands/test_echo_command.py +0 -127
  188. mcp_proxy_adapter/tests/commands/test_help_command.py +0 -136
  189. mcp_proxy_adapter/tests/conftest.py +0 -131
  190. mcp_proxy_adapter/tests/functional/__init__.py +0 -3
  191. mcp_proxy_adapter/tests/functional/test_api.py +0 -253
  192. mcp_proxy_adapter/tests/integration/__init__.py +0 -3
  193. mcp_proxy_adapter/tests/integration/test_cmd_integration.py +0 -129
  194. mcp_proxy_adapter/tests/integration/test_integration.py +0 -255
  195. mcp_proxy_adapter/tests/performance/__init__.py +0 -3
  196. mcp_proxy_adapter/tests/performance/test_performance.py +0 -189
  197. mcp_proxy_adapter/tests/stubs/__init__.py +0 -10
  198. mcp_proxy_adapter/tests/stubs/echo_command.py +0 -104
  199. mcp_proxy_adapter/tests/test_api_endpoints.py +0 -271
  200. mcp_proxy_adapter/tests/test_api_handlers.py +0 -289
  201. mcp_proxy_adapter/tests/test_base_command.py +0 -123
  202. mcp_proxy_adapter/tests/test_batch_requests.py +0 -117
  203. mcp_proxy_adapter/tests/test_command_registry.py +0 -281
  204. mcp_proxy_adapter/tests/test_config.py +0 -127
  205. mcp_proxy_adapter/tests/test_utils.py +0 -65
  206. mcp_proxy_adapter/tests/unit/__init__.py +0 -3
  207. mcp_proxy_adapter/tests/unit/test_base_command.py +0 -436
  208. mcp_proxy_adapter/tests/unit/test_config.py +0 -270
  209. mcp_proxy_adapter-6.0.0.dist-info/METADATA +0 -201
  210. mcp_proxy_adapter-6.0.0.dist-info/RECORD +0 -179
  211. {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/WHEEL +0 -0
  212. {mcp_proxy_adapter-6.0.0.dist-info → mcp_proxy_adapter-6.0.1.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,6 @@
1
- """Version information for MCP Microservice."""
1
+ """
2
+ Version information for MCP Proxy Adapter.
3
+ """
4
+
5
+ __version__ = "6.2.24"
2
6
 
3
- __version__ = "5.0.0"
@@ -0,0 +1,679 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-proxy-adapter
3
+ Version: 6.0.1
4
+ Summary: Powerful JSON-RPC microservices framework with built-in security, authentication, and proxy registration
5
+ Home-page: https://github.com/maverikod/mcp-proxy-adapter
6
+ Author: Vasiliy Zdanovskiy
7
+ Author-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
8
+ Maintainer-email: Vasiliy Zdanovskiy <vasilyvz@gmail.com>
9
+ Project-URL: Homepage, https://github.com/maverikod/mcp-proxy-adapter
10
+ Project-URL: Documentation, https://github.com/maverikod/mcp-proxy-adapter#readme
11
+ Project-URL: Source, https://github.com/maverikod/mcp-proxy-adapter
12
+ Project-URL: Tracker, https://github.com/maverikod/mcp-proxy-adapter/issues
13
+ Project-URL: PyPI, https://pypi.org/project/mcp-proxy-adapter/
14
+ Keywords: json-rpc,microservices,fastapi,security,authentication,authorization,proxy,mcp,mtls,ssl,rest,api
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Framework :: FastAPI
25
+ Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: fastapi<1.0.0,>=0.95.0
32
+ Requires-Dist: pydantic>=2.0.0
33
+ Requires-Dist: hypercorn<1.0.0,>=0.15.0
34
+ Requires-Dist: docstring-parser<1.0.0,>=0.15
35
+ Requires-Dist: typing-extensions<5.0.0,>=4.5.0
36
+ Requires-Dist: jsonrpc>=1.2.0
37
+ Requires-Dist: psutil>=5.9.0
38
+ Requires-Dist: mcp_security_framework>=1.1.2
39
+ Requires-Dist: packaging>=20.0
40
+ Requires-Dist: aiohttp<4.0.0,>=3.8.0
41
+ Requires-Dist: requests<3.0.0,>=2.28.0
42
+ Provides-Extra: dev
43
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
44
+ Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
45
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
46
+ Requires-Dist: black>=23.0.0; extra == "dev"
47
+ Requires-Dist: isort>=5.12.0; extra == "dev"
48
+ Provides-Extra: test
49
+ Requires-Dist: pytest>=7.0.0; extra == "test"
50
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
51
+ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
52
+ Requires-Dist: httpx>=0.24.0; extra == "test"
53
+ Requires-Dist: pytest-mock>=3.10.0; extra == "test"
54
+ Dynamic: author
55
+ Dynamic: home-page
56
+ Dynamic: license-file
57
+ Dynamic: requires-python
58
+
59
+ # MCP Proxy Adapter
60
+
61
+ [![PyPI version](https://badge.fury.io/py/mcp-proxy-adapter.svg)](https://pypi.org/project/mcp-proxy-adapter/)
62
+ [![Python versions](https://img.shields.io/pypi/pyversions/mcp-proxy-adapter.svg)](https://pypi.org/project/mcp-proxy-adapter/)
63
+ [![License](https://img.shields.io/pypi/l/mcp-proxy-adapter.svg)](https://github.com/maverikod/mcp-proxy-adapter/blob/main/LICENSE)
64
+
65
+ A powerful framework for creating JSON-RPC-enabled microservices with built-in security, authentication, and proxy registration capabilities.
66
+
67
+ ## 🚀 Quick Install
68
+
69
+ ```bash
70
+ pip install mcp-proxy-adapter
71
+ ```
72
+
73
+ ## ✨ Key Features
74
+
75
+ - **🔒 Security First**: Built-in mTLS, JWT, API Key authentication
76
+ - **🌐 JSON-RPC 2.0**: Complete protocol implementation
77
+ - **🔄 Proxy Registration**: Automatic service discovery and registration
78
+ - **⚡ High Performance**: Built on FastAPI with async support
79
+ - **🛡️ Role-Based Access**: Fine-grained permission control
80
+ - **📡 Universal Client**: Supports all authentication methods
81
+
82
+ ## 🏃‍♂️ Quick Example
83
+
84
+ Create a secure JSON-RPC microservice in minutes:
85
+
86
+ ```python
87
+ from mcp_proxy_adapter import create_app, Command, SuccessResult
88
+
89
+ # Create a custom command
90
+ class HelloCommand(Command):
91
+ name = "hello"
92
+ description = "Say hello"
93
+
94
+ async def execute(self, **kwargs) -> SuccessResult:
95
+ name = kwargs.get("name", "World")
96
+ return SuccessResult(f"Hello, {name}!")
97
+
98
+ # Create and run the application
99
+ app = create_app()
100
+ ```
101
+
102
+ **📖 [Full Documentation](https://github.com/maverikod/mcp-proxy-adapter#readme)** - Complete usage guide, examples, and API reference.
103
+
104
+ ## 📋 Usage Examples
105
+
106
+ ### Basic Server Setup
107
+
108
+ ```python
109
+ from mcp_proxy_adapter import create_app
110
+ import uvicorn
111
+
112
+ app = create_app()
113
+
114
+ if __name__ == "__main__":
115
+ uvicorn.run(app, host="0.0.0.0", port=8000)
116
+ ```
117
+
118
+ ### With Security Configuration
119
+
120
+ ```python
121
+ from mcp_proxy_adapter import create_app
122
+ from mcp_proxy_adapter.config import Config
123
+
124
+ # Load configuration
125
+ config = Config.from_file("config.json")
126
+ app = create_app(config)
127
+ ```
128
+
129
+ ### Client Usage
130
+
131
+ ```python
132
+ from mcp_proxy_adapter.core.client import UniversalClient
133
+
134
+ async def main():
135
+ async with UniversalClient({"server_url": "http://localhost:8000"}) as client:
136
+ result = await client.execute_command("help")
137
+ print(result)
138
+
139
+ import asyncio
140
+ asyncio.run(main())
141
+ ```
142
+
143
+ ## 🔧 Requirements
144
+
145
+ - **Python**: 3.9+
146
+ - **Dependencies**:
147
+ - `fastapi` - Web framework
148
+ - `pydantic` - Data validation
149
+ - `hypercorn` - ASGI server
150
+ - `mcp_security_framework` - Security components
151
+ - `jsonrpc` - JSON-RPC protocol
152
+
153
+ ## Features
154
+
155
+ - **JSON-RPC Framework**: Complete JSON-RPC 2.0 implementation
156
+ - **Security Integration**: Built-in support for mcp_security_framework
157
+ - **Authentication**: Multiple auth methods (API Key, JWT, Certificate, Basic Auth)
158
+ - **Proxy Registration**: Automatic registration and discovery of services
159
+ - **Command System**: Extensible command framework with role-based access control
160
+ - **SSL/TLS Support**: Full SSL/TLS support including mTLS
161
+ - **Async Support**: Built on FastAPI with full async support
162
+ - **Extensible**: Plugin system for custom commands and middleware
163
+
164
+ ## Quick Start
165
+
166
+ ### Installation
167
+
168
+ ```bash
169
+ pip install mcp-proxy-adapter
170
+ ```
171
+
172
+ ## Detailed Usage Guide
173
+
174
+ ### Step 1: Initialize Working Environment
175
+
176
+ Первый шаг - создание изолированного рабочего окружения с помощью скрипта копирования:
177
+
178
+ ```bash
179
+ # Создание рабочего окружения
180
+ python scripts/init_working_environment.py my_test_env
181
+
182
+ # Переход в созданную директорию
183
+ cd my_test_env
184
+ ```
185
+
186
+ **Что делает скрипт `init_working_environment.py`:**
187
+
188
+ 1. **Создает изолированную директорию** с именем, которое вы указали
189
+ 2. **Копирует все примеры** из проекта:
190
+ - `basic_framework/` - базовый пример приложения
191
+ - `full_application/` - полный пример с proxy endpoints
192
+ - `universal_client.py` - универсальный клиент
193
+ 3. **Копирует утилитарные скрипты**:
194
+ - `config_generator.py` - генератор конфигураций
195
+ - `create_certificates_simple.py` - генератор сертификатов
196
+ 4. **Копирует тестовые скрипты**:
197
+ - `generate_certificates_and_tokens.py` - генерация сертификатов и токенов
198
+ - `setup_test_environment.py` - настройка тестового окружения
199
+ - `test_config.py` - тестирование конфигураций
200
+ - `generate_test_configs.py` - генерация тестовых конфигураций
201
+ - `test_proxy_registration.py` - тестирование proxy registration
202
+ 5. **Автоматически генерирует конфигурации** для всех режимов работы
203
+ 6. **Создает сертификаты** для SSL и mTLS тестирования
204
+ 7. **Создает локальную документацию** в виде README.md
205
+
206
+ ### Step 2: Генерация конфигураций
207
+
208
+ После создания рабочего окружения, сгенерируйте тестовые конфигурации:
209
+
210
+ ```bash
211
+ # Генерация всех типов конфигураций
212
+ python scripts/generate_test_configs.py --output-dir configs
213
+
214
+ # Просмотр созданных конфигураций
215
+ ls -la configs/
216
+ ```
217
+
218
+ **Создаются следующие конфигурации:**
219
+
220
+ - `http_simple.json` - HTTP без аутентификации
221
+ - `http_token.json` - HTTP с токен аутентификацией
222
+ - `https_simple.json` - HTTPS без аутентификации
223
+ - `https_token.json` - HTTPS с токен аутентификацией
224
+ - `mtls_no_roles.json` - mTLS без ролей
225
+ - `mtls_with_roles.json` - mTLS с ролями
226
+ - `roles.json` - конфигурация ролей и разрешений
227
+
228
+ ### Step 3: Запуск базового примера
229
+
230
+ Начните с самого простого примера - HTTP без аутентификации:
231
+
232
+ ```bash
233
+ # Запуск сервера с HTTP конфигурацией
234
+ python examples/basic_framework/main.py --config configs/http_simple.json
235
+ ```
236
+
237
+ В другом терминале протестируйте подключение:
238
+
239
+ ```bash
240
+ # Тестирование базовой функциональности
241
+ python scripts/test_config.py --config configs/http_simple.json
242
+ ```
243
+
244
+ ### Step 4: Тестирование различных режимов безопасности
245
+
246
+ #### HTTP с токен аутентификацией
247
+
248
+ ```bash
249
+ # Запуск сервера
250
+ python examples/basic_framework/main.py --config configs/http_token.json
251
+
252
+ # Тестирование в другом терминале
253
+ python scripts/test_config.py --config configs/http_token.json
254
+ ```
255
+
256
+ #### HTTPS с сертификатами
257
+
258
+ ```bash
259
+ # Запуск сервера
260
+ python examples/basic_framework/main.py --config configs/https_simple.json
261
+
262
+ # Тестирование в другом терминале
263
+ python scripts/test_config.py --config configs/https_simple.json
264
+ ```
265
+
266
+ #### mTLS (Mutual TLS) аутентификация
267
+
268
+ ```bash
269
+ # Запуск сервера с mTLS
270
+ python examples/basic_framework/main.py --config configs/mtls_no_roles.json
271
+
272
+ # Тестирование в другом терминале
273
+ python scripts/test_config.py --config configs/mtls_no_roles.json
274
+ ```
275
+
276
+ ### Step 5: Тестирование Proxy Registration
277
+
278
+ Запустите полный тест всех режимов proxy registration:
279
+
280
+ ```bash
281
+ # Полный тест proxy registration для всех режимов
282
+ python scripts/test_proxy_registration.py
283
+ ```
284
+
285
+ Этот тест проверит:
286
+ - ✅ HTTP без ролей
287
+ - ✅ HTTP с ролями
288
+ - ✅ HTTPS без ролей
289
+ - ✅ HTTPS с ролями
290
+ - ✅ mTLS без ролей
291
+ - ✅ mTLS с ролями
292
+
293
+ ### Step 6: Использование универсального клиента
294
+
295
+ Универсальный клиент поддерживает все режимы аутентификации:
296
+
297
+ #### Создание конфигурации клиента
298
+
299
+ ```bash
300
+ # Пример конфигурации для mTLS
301
+ cat > client_config.json << 'EOF'
302
+ {
303
+ "server_url": "https://127.0.0.1:8443",
304
+ "timeout": 30,
305
+ "retry_attempts": 3,
306
+ "retry_delay": 1,
307
+ "security": {
308
+ "auth_method": "certificate",
309
+ "ssl": {
310
+ "enabled": true,
311
+ "check_hostname": false,
312
+ "verify": false,
313
+ "ca_cert_file": "./certs/ca_cert.pem"
314
+ },
315
+ "certificate": {
316
+ "enabled": true,
317
+ "cert_file": "./certs/admin_cert.pem",
318
+ "key_file": "./certs/admin_key.pem"
319
+ }
320
+ }
321
+ }
322
+ EOF
323
+ ```
324
+
325
+ #### Тестирование с помощью клиента
326
+
327
+ ```bash
328
+ # Тестирование подключения
329
+ python examples/universal_client.py --config client_config.json --test-connection
330
+
331
+ # Выполнение команды help
332
+ python examples/universal_client.py --config client_config.json --method help
333
+
334
+ # Регистрация в proxy
335
+ python examples/universal_client.py --config client_config.json --method proxy_register --params '{"server_id": "test-server", "server_url": "http://127.0.0.1:8001", "server_name": "Test Server"}'
336
+ ```
337
+
338
+ ### Step 7: Работа с полным примером приложения
339
+
340
+ Запустите полный пример с proxy endpoints:
341
+
342
+ ```bash
343
+ # Запуск полного примера
344
+ python examples/full_application/main.py --config configs/mtls_with_roles.json
345
+ ```
346
+
347
+ Этот пример включает:
348
+ - Proxy discovery endpoint (`/proxy/discover`)
349
+ - Server registration endpoint (`/proxy/register`)
350
+ - Heartbeat endpoint (`/proxy/heartbeat`)
351
+ - Server unregistration endpoint (`/proxy/unregister`)
352
+
353
+ #### Тестирование proxy endpoints
354
+
355
+ ```bash
356
+ # Discovery - получение информации о proxy
357
+ curl -X GET "https://127.0.0.1:8443/proxy/discover" \
358
+ --cert ./certs/admin_cert.pem \
359
+ --key ./certs/admin_key.pem \
360
+ --cacert ./certs/ca_cert.pem
361
+
362
+ # Registration - регистрация сервера
363
+ curl -X POST "https://127.0.0.1:8443/proxy/register" \
364
+ -H "Content-Type: application/json" \
365
+ -d '{
366
+ "server_id": "test-server-1",
367
+ "server_url": "http://127.0.0.1:8001",
368
+ "server_name": "Test Server",
369
+ "description": "Test server for proxy registration",
370
+ "version": "1.0.0",
371
+ "capabilities": ["jsonrpc", "rest"],
372
+ "endpoints": {
373
+ "jsonrpc": "/api/jsonrpc",
374
+ "rest": "/cmd",
375
+ "health": "/health"
376
+ },
377
+ "auth_method": "certificate",
378
+ "security_enabled": true
379
+ }' \
380
+ --cert ./certs/admin_cert.pem \
381
+ --key ./certs/admin_key.pem \
382
+ --cacert ./certs/ca_cert.pem
383
+
384
+ # Heartbeat - отправка heartbeat
385
+ curl -X POST "https://127.0.0.1:8443/proxy/heartbeat" \
386
+ -H "Content-Type: application/json" \
387
+ -d '{
388
+ "server_id": "test-server-1",
389
+ "server_key": "returned_server_key",
390
+ "timestamp": 1234567890,
391
+ "status": "healthy"
392
+ }' \
393
+ --cert ./certs/admin_cert.pem \
394
+ --key ./certs/admin_key.pem \
395
+ --cacert ./certs/ca_cert.pem
396
+ ```
397
+
398
+ ### Step 8: Создание собственных команд
399
+
400
+ Создайте собственную команду, наследуясь от базового класса:
401
+
402
+ ```python
403
+ from mcp_proxy_adapter.commands.base import Command
404
+ from mcp_proxy_adapter.core.result import SuccessResult, ErrorResult
405
+
406
+ class MyCustomCommand(Command):
407
+ name = "my_command"
408
+ description = "Моя собственная команда"
409
+
410
+ async def execute(self, **kwargs) -> SuccessResult:
411
+ param1 = kwargs.get("param1", "default_value")
412
+
413
+ # Ваша логика здесь
414
+ result = f"Выполнена команда с параметром: {param1}"
415
+
416
+ return SuccessResult(result)
417
+ ```
418
+
419
+ ### Структура созданного рабочего окружения
420
+
421
+ После выполнения `init_working_environment.py` у вас будет следующая структура:
422
+
423
+ ```
424
+ my_test_env/
425
+ ├── examples/ # Примеры приложений
426
+ │ ├── basic_framework/
427
+ │ ├── full_application/
428
+ │ └── universal_client.py
429
+ ├── scripts/ # Скрипты для тестирования
430
+ │ ├── generate_test_configs.py
431
+ │ ├── test_proxy_registration.py
432
+ │ ├── test_config.py
433
+ │ └── ...
434
+ ├── configs/ # Сгенерированные конфигурации
435
+ │ ├── http_simple.json
436
+ │ ├── https_simple.json
437
+ │ ├── mtls_no_roles.json
438
+ │ ├── mtls_with_roles.json
439
+ │ └── roles.json
440
+ ├── certs/ # Сертификаты для SSL/mTLS
441
+ │ ├── ca_cert.pem
442
+ │ ├── server_cert.pem
443
+ │ ├── admin_cert.pem
444
+ │ ├── user_cert.pem
445
+ │ └── ...
446
+ ├── keys/ # Приватные ключи
447
+ │ ├── server_key.pem
448
+ │ ├── admin_key.pem
449
+ │ └── ...
450
+ └── README.md # Локальная документация
451
+ ```
452
+
453
+ ### Troubleshooting
454
+
455
+ #### Распространенные проблемы и решения
456
+
457
+ **1. Проблемы с сертификатами mTLS:**
458
+
459
+ ```bash
460
+ # Проверьте, что сертификаты созданы
461
+ ls -la certs/
462
+ ls -la keys/
463
+
464
+ # Проверьте содержимое сертификатов
465
+ openssl x509 -in certs/admin_cert.pem -text -noout
466
+ openssl x509 -in certs/ca_cert.pem -text -noout
467
+ ```
468
+
469
+ **2. Ошибки подключения:**
470
+
471
+ ```bash
472
+ # Проверьте, что порт свободен
473
+ netstat -tlnp | grep :8443
474
+
475
+ # Или используйте lsof
476
+ lsof -i :8443
477
+ ```
478
+
479
+ **3. Ошибки импортов:**
480
+
481
+ ```bash
482
+ # Убедитесь, что виртуальное окружение активировано
483
+ source .venv/bin/activate
484
+
485
+ # Проверьте установку зависимостей
486
+ pip list | grep mcp
487
+ pip list | grep hypercorn
488
+ ```
489
+
490
+ **4. Проблемы с правами доступа:**
491
+
492
+ ```bash
493
+ # Убедитесь, что файлы сертификатов доступны для чтения
494
+ chmod 644 certs/*.pem
495
+ chmod 600 keys/*.pem
496
+ ```
497
+
498
+ ### Конфигурационные файлы
499
+
500
+ #### Структура конфигурации сервера
501
+
502
+ ```json
503
+ {
504
+ "server": {
505
+ "host": "127.0.0.1",
506
+ "port": 8000
507
+ },
508
+ "ssl": {
509
+ "enabled": true,
510
+ "cert_file": "./certs/server_cert.pem",
511
+ "key_file": "./certs/server_key.pem",
512
+ "ca_cert": "./certs/ca_cert.pem",
513
+ "verify_client": true
514
+ },
515
+ "security": {
516
+ "enabled": true,
517
+ "auth": {
518
+ "enabled": true,
519
+ "methods": ["certificate"]
520
+ },
521
+ "permissions": {
522
+ "enabled": true,
523
+ "roles_file": "./configs/roles.json"
524
+ }
525
+ },
526
+ "commands": {
527
+ "auto_discovery": true,
528
+ "builtin_commands": ["echo", "health", "config"]
529
+ },
530
+ "logging": {
531
+ "level": "INFO",
532
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
533
+ }
534
+ }
535
+ ```
536
+
537
+ #### Структура конфигурации клиента
538
+
539
+ ```json
540
+ {
541
+ "server_url": "https://127.0.0.1:8443",
542
+ "timeout": 30,
543
+ "retry_attempts": 3,
544
+ "retry_delay": 1,
545
+ "security": {
546
+ "auth_method": "certificate",
547
+ "ssl": {
548
+ "enabled": true,
549
+ "check_hostname": false,
550
+ "verify": false,
551
+ "ca_cert_file": "./certs/ca_cert.pem"
552
+ },
553
+ "certificate": {
554
+ "enabled": true,
555
+ "cert_file": "./certs/admin_cert.pem",
556
+ "key_file": "./certs/admin_key.pem"
557
+ }
558
+ }
559
+ }
560
+ ```
561
+
562
+ ### API Reference
563
+
564
+ #### Основные endpoints
565
+
566
+ - `GET /health` - Проверка здоровья сервиса
567
+ - `POST /api/jsonrpc` - JSON-RPC endpoint
568
+ - `GET /proxy/discover` - Proxy discovery (только в full_application)
569
+ - `POST /proxy/register` - Регистрация сервера в proxy
570
+ - `POST /proxy/heartbeat` - Отправка heartbeat
571
+ - `POST /proxy/unregister` - Отмена регистрации сервера
572
+
573
+ #### JSON-RPC методы
574
+
575
+ - `echo` - Возврат переданных параметров
576
+ - `help` - Список доступных команд
577
+ - `config` - Информация о конфигурации
578
+ - `proxy_discover` - Обнаружение proxy
579
+ - `proxy_register` - Регистрация в proxy
580
+ - `proxy_heartbeat` - Отправка heartbeat
581
+
582
+ ### Development
583
+
584
+ #### Настройка среды разработки
585
+
586
+ ```bash
587
+ # Клонирование репозитория
588
+ git clone https://github.com/maverikod/mcp-proxy-adapter.git
589
+ cd mcp-proxy-adapter
590
+
591
+ # Создание виртуального окружения
592
+ python -m venv .venv
593
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
594
+
595
+ # Установка зависимостей
596
+ pip install -e ".[dev]"
597
+ ```
598
+
599
+ #### Запуск тестов
600
+
601
+ ```bash
602
+ # Запуск всех тестов
603
+ pytest tests/
604
+
605
+ # Запуск с покрытием кода
606
+ pytest --cov=mcp_proxy_adapter tests/
607
+
608
+ # Запуск конкретного теста
609
+ pytest tests/test_proxy_registration.py -v
610
+ ```
611
+
612
+ #### Запуск примеров в режиме разработки
613
+
614
+ ```bash
615
+ # Запуск сервера в режиме разработки
616
+ python -m mcp_proxy_adapter.main --config examples/server_configs/config_simple.json --reload
617
+
618
+ # Запуск с отладкой
619
+ PYTHONPATH=. python examples/basic_framework/main.py --config configs/http_simple.json --debug
620
+ ```
621
+
622
+ ### Contributing
623
+
624
+ 1. Fork the repository
625
+ 2. Create a feature branch (`git checkout -b feature/AmazingFeature`)
626
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
627
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
628
+ 5. Open a Pull Request
629
+
630
+ ### License
631
+
632
+ MIT License - see LICENSE file for details.
633
+
634
+ ## Author
635
+
636
+ **Vasiliy Zdanovskiy** - vasilyvz@gmail.com
637
+
638
+ ## 🤝 Support & Contributing
639
+
640
+ - **📧 Email**: vasilyvz@gmail.com
641
+ - **🐛 Issues**: [GitHub Issues](https://github.com/maverikod/mcp-proxy-adapter/issues)
642
+ - **📚 Documentation**: [GitHub Wiki](https://github.com/maverikod/mcp-proxy-adapter/wiki)
643
+ - **💬 Discussions**: [GitHub Discussions](https://github.com/maverikod/mcp-proxy-adapter/discussions)
644
+
645
+ ## 📄 License
646
+
647
+ MIT License - see [LICENSE](https://github.com/maverikod/mcp-proxy-adapter/blob/main/LICENSE) file for details.
648
+
649
+ ## 📊 Version
650
+
651
+ **6.2.9** - Production-ready release with comprehensive security, proxy registration, and PyPI optimization.
652
+
653
+ ---
654
+
655
+ *Built with ❤️ for secure microservices development*
656
+
657
+ ---
658
+
659
+ ## Быстрый старт (быстрая справка)
660
+
661
+ ```bash
662
+ # 1. Создание рабочего окружения
663
+ python scripts/init_working_environment.py test_env
664
+ cd test_env
665
+
666
+ # 2. Генерация конфигураций
667
+ python scripts/generate_test_configs.py --output-dir configs
668
+
669
+ # 3. Запуск сервера
670
+ python examples/basic_framework/main.py --config configs/http_simple.json
671
+
672
+ # 4. Тестирование (в другом терминале)
673
+ python scripts/test_config.py --config configs/http_simple.json
674
+
675
+ # 5. Полный тест proxy registration
676
+ python scripts/test_proxy_registration.py
677
+ ```
678
+
679
+ 🎉 **Готово! Теперь вы можете использовать MCP Proxy Adapter для создания безопасных JSON-RPC микросервисов с полной поддержкой аутентификации, авторизации и proxy registration.**