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