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