mcp-proxy-adapter 4.1.1__py3-none-any.whl → 6.1.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.
- mcp_proxy_adapter/__main__.py +12 -0
- mcp_proxy_adapter/api/app.py +254 -33
- mcp_proxy_adapter/api/handlers.py +32 -6
- mcp_proxy_adapter/api/middleware/__init__.py +36 -30
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +148 -0
- mcp_proxy_adapter/api/middleware/error_handling.py +9 -0
- mcp_proxy_adapter/api/middleware/factory.py +243 -0
- mcp_proxy_adapter/api/middleware/logging.py +32 -6
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +135 -0
- mcp_proxy_adapter/api/middleware/transport_middleware.py +122 -0
- mcp_proxy_adapter/api/middleware/unified_security.py +152 -0
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +83 -0
- mcp_proxy_adapter/commands/__init__.py +19 -4
- mcp_proxy_adapter/commands/auth_validation_command.py +408 -0
- mcp_proxy_adapter/commands/base.py +66 -32
- mcp_proxy_adapter/commands/builtin_commands.py +95 -0
- mcp_proxy_adapter/commands/catalog_manager.py +838 -0
- mcp_proxy_adapter/commands/cert_monitor_command.py +620 -0
- mcp_proxy_adapter/commands/certificate_management_command.py +608 -0
- mcp_proxy_adapter/commands/command_registry.py +711 -354
- mcp_proxy_adapter/commands/dependency_manager.py +245 -0
- mcp_proxy_adapter/commands/echo_command.py +81 -0
- mcp_proxy_adapter/commands/health_command.py +7 -0
- mcp_proxy_adapter/commands/help_command.py +21 -14
- mcp_proxy_adapter/commands/hooks.py +200 -167
- mcp_proxy_adapter/commands/key_management_command.py +506 -0
- mcp_proxy_adapter/commands/load_command.py +176 -0
- mcp_proxy_adapter/commands/plugins_command.py +235 -0
- mcp_proxy_adapter/commands/protocol_management_command.py +232 -0
- mcp_proxy_adapter/commands/proxy_registration_command.py +409 -0
- mcp_proxy_adapter/commands/reload_command.py +48 -50
- mcp_proxy_adapter/commands/result.py +1 -0
- mcp_proxy_adapter/commands/role_test_command.py +141 -0
- mcp_proxy_adapter/commands/roles_management_command.py +697 -0
- mcp_proxy_adapter/commands/security_command.py +488 -0
- mcp_proxy_adapter/commands/ssl_setup_command.py +483 -0
- mcp_proxy_adapter/commands/token_management_command.py +529 -0
- mcp_proxy_adapter/commands/transport_management_command.py +144 -0
- mcp_proxy_adapter/commands/unload_command.py +158 -0
- mcp_proxy_adapter/config.py +159 -2
- mcp_proxy_adapter/core/app_factory.py +326 -0
- mcp_proxy_adapter/core/auth_validator.py +606 -0
- mcp_proxy_adapter/core/certificate_utils.py +827 -0
- mcp_proxy_adapter/core/client_security.py +384 -0
- mcp_proxy_adapter/core/config_converter.py +405 -0
- mcp_proxy_adapter/core/config_validator.py +218 -0
- mcp_proxy_adapter/core/logging.py +19 -3
- mcp_proxy_adapter/core/mtls_asgi.py +156 -0
- mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
- mcp_proxy_adapter/core/protocol_manager.py +235 -0
- mcp_proxy_adapter/core/proxy_client.py +602 -0
- mcp_proxy_adapter/core/proxy_registration.py +522 -0
- mcp_proxy_adapter/core/role_utils.py +426 -0
- mcp_proxy_adapter/core/security_adapter.py +370 -0
- mcp_proxy_adapter/core/security_factory.py +239 -0
- mcp_proxy_adapter/core/security_integration.py +277 -0
- mcp_proxy_adapter/core/server_adapter.py +345 -0
- mcp_proxy_adapter/core/server_engine.py +364 -0
- mcp_proxy_adapter/core/settings.py +1 -0
- mcp_proxy_adapter/core/ssl_utils.py +233 -0
- mcp_proxy_adapter/core/transport_manager.py +292 -0
- mcp_proxy_adapter/core/unified_config_adapter.py +579 -0
- mcp_proxy_adapter/custom_openapi.py +22 -11
- mcp_proxy_adapter/examples/README.md +230 -97
- mcp_proxy_adapter/examples/README_EN.md +258 -0
- mcp_proxy_adapter/examples/SECURITY_TESTING.md +455 -0
- mcp_proxy_adapter/examples/__pycache__/security_configurations.cpython-312.pyc +0 -0
- mcp_proxy_adapter/examples/__pycache__/security_test_client.cpython-312.pyc +0 -0
- mcp_proxy_adapter/examples/basic_framework/configs/http_auth.json +37 -0
- mcp_proxy_adapter/examples/basic_framework/configs/http_simple.json +23 -0
- mcp_proxy_adapter/examples/basic_framework/configs/https_auth.json +39 -0
- mcp_proxy_adapter/examples/basic_framework/configs/https_simple.json +25 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_roles.json +39 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_with_roles.json +45 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +63 -0
- mcp_proxy_adapter/examples/basic_framework/roles.json +21 -0
- mcp_proxy_adapter/examples/cert_config.json +9 -0
- mcp_proxy_adapter/examples/certs/admin.crt +32 -0
- mcp_proxy_adapter/examples/certs/admin.key +52 -0
- mcp_proxy_adapter/examples/certs/admin_cert.pem +21 -0
- mcp_proxy_adapter/examples/certs/admin_key.pem +28 -0
- mcp_proxy_adapter/examples/certs/ca_cert.pem +23 -0
- mcp_proxy_adapter/examples/certs/ca_cert.srl +1 -0
- mcp_proxy_adapter/examples/certs/ca_key.pem +28 -0
- mcp_proxy_adapter/examples/certs/cert_config.json +9 -0
- mcp_proxy_adapter/examples/certs/client.crt +32 -0
- mcp_proxy_adapter/examples/certs/client.key +52 -0
- mcp_proxy_adapter/examples/certs/client_admin.crt +32 -0
- mcp_proxy_adapter/examples/certs/client_admin.key +52 -0
- mcp_proxy_adapter/examples/certs/client_user.crt +32 -0
- mcp_proxy_adapter/examples/certs/client_user.key +52 -0
- mcp_proxy_adapter/examples/certs/guest_cert.pem +21 -0
- mcp_proxy_adapter/examples/certs/guest_key.pem +28 -0
- mcp_proxy_adapter/examples/certs/mcp_proxy_adapter_ca_ca.crt +23 -0
- mcp_proxy_adapter/examples/certs/proxy_cert.pem +21 -0
- mcp_proxy_adapter/examples/certs/proxy_key.pem +28 -0
- mcp_proxy_adapter/examples/certs/readonly.crt +32 -0
- mcp_proxy_adapter/examples/certs/readonly.key +52 -0
- mcp_proxy_adapter/examples/certs/readonly_cert.pem +21 -0
- mcp_proxy_adapter/examples/certs/readonly_key.pem +28 -0
- mcp_proxy_adapter/examples/certs/server.crt +32 -0
- mcp_proxy_adapter/examples/certs/server.key +52 -0
- mcp_proxy_adapter/examples/certs/server_cert.pem +32 -0
- mcp_proxy_adapter/examples/certs/server_key.pem +52 -0
- mcp_proxy_adapter/examples/certs/test_ca_ca.crt +20 -0
- mcp_proxy_adapter/examples/certs/user.crt +32 -0
- mcp_proxy_adapter/examples/certs/user.key +52 -0
- mcp_proxy_adapter/examples/certs/user_cert.pem +21 -0
- mcp_proxy_adapter/examples/certs/user_key.pem +28 -0
- mcp_proxy_adapter/examples/client_configs/api_key_client.json +13 -0
- mcp_proxy_adapter/examples/client_configs/basic_auth_client.json +13 -0
- mcp_proxy_adapter/examples/client_configs/certificate_client.json +22 -0
- mcp_proxy_adapter/examples/client_configs/jwt_client.json +15 -0
- mcp_proxy_adapter/examples/client_configs/no_auth_client.json +9 -0
- mcp_proxy_adapter/examples/commands/__init__.py +1 -0
- mcp_proxy_adapter/examples/create_certificates_simple.py +307 -0
- mcp_proxy_adapter/examples/debug_request_state.py +144 -0
- mcp_proxy_adapter/examples/debug_role_chain.py +205 -0
- mcp_proxy_adapter/examples/demo_client.py +341 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +99 -0
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +106 -0
- mcp_proxy_adapter/examples/full_application/configs/http_auth.json +37 -0
- mcp_proxy_adapter/examples/full_application/configs/http_simple.json +23 -0
- mcp_proxy_adapter/examples/full_application/configs/https_auth.json +39 -0
- mcp_proxy_adapter/examples/full_application/configs/https_simple.json +25 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles.json +39 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles.json +45 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +97 -0
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +95 -0
- mcp_proxy_adapter/examples/full_application/main.py +138 -0
- mcp_proxy_adapter/examples/full_application/roles.json +21 -0
- mcp_proxy_adapter/examples/generate_all_certificates.py +429 -0
- mcp_proxy_adapter/examples/generate_certificates.py +121 -0
- mcp_proxy_adapter/examples/keys/ca_key.pem +28 -0
- mcp_proxy_adapter/examples/keys/mcp_proxy_adapter_ca_ca.key +28 -0
- mcp_proxy_adapter/examples/keys/test_ca_ca.key +28 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log +220 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.1 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.2 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.3 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.4 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.5 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log +220 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.1 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.2 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.3 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.4 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.5 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log +2 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.1 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.2 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.3 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.4 +1 -0
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.5 +1 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +401 -0
- mcp_proxy_adapter/examples/roles.json +38 -0
- mcp_proxy_adapter/examples/run_example.py +81 -0
- mcp_proxy_adapter/examples/run_security_tests.py +326 -0
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +300 -0
- mcp_proxy_adapter/examples/security_test_client.py +743 -0
- mcp_proxy_adapter/examples/server_configs/config_basic_http.json +204 -0
- mcp_proxy_adapter/examples/server_configs/config_http_token.json +238 -0
- mcp_proxy_adapter/examples/server_configs/config_https.json +215 -0
- mcp_proxy_adapter/examples/server_configs/config_https_token.json +231 -0
- mcp_proxy_adapter/examples/server_configs/config_mtls.json +215 -0
- mcp_proxy_adapter/examples/server_configs/config_proxy_registration.json +250 -0
- mcp_proxy_adapter/examples/server_configs/config_simple.json +46 -0
- mcp_proxy_adapter/examples/server_configs/roles.json +38 -0
- mcp_proxy_adapter/examples/test_examples.py +344 -0
- mcp_proxy_adapter/examples/universal_client.py +628 -0
- mcp_proxy_adapter/main.py +186 -0
- mcp_proxy_adapter/utils/config_generator.py +639 -0
- mcp_proxy_adapter/version.py +2 -1
- mcp_proxy_adapter-6.1.0.dist-info/METADATA +205 -0
- mcp_proxy_adapter-6.1.0.dist-info/RECORD +193 -0
- mcp_proxy_adapter-6.1.0.dist-info/entry_points.txt +2 -0
- {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.1.0.dist-info}/licenses/LICENSE +2 -2
- mcp_proxy_adapter/api/middleware/auth.py +0 -146
- mcp_proxy_adapter/api/middleware/rate_limit.py +0 -152
- mcp_proxy_adapter/commands/reload_settings_command.py +0 -125
- mcp_proxy_adapter/examples/__init__.py +0 -7
- mcp_proxy_adapter/examples/basic_server/README.md +0 -60
- mcp_proxy_adapter/examples/basic_server/__init__.py +0 -7
- mcp_proxy_adapter/examples/basic_server/basic_custom_settings.json +0 -39
- mcp_proxy_adapter/examples/basic_server/config.json +0 -35
- mcp_proxy_adapter/examples/basic_server/custom_settings_example.py +0 -238
- mcp_proxy_adapter/examples/basic_server/server.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/README.md +0 -127
- mcp_proxy_adapter/examples/custom_commands/__init__.py +0 -27
- mcp_proxy_adapter/examples/custom_commands/advanced_hooks.py +0 -250
- mcp_proxy_adapter/examples/custom_commands/auto_commands/__init__.py +0 -6
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_echo_command.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_info_command.py +0 -111
- mcp_proxy_adapter/examples/custom_commands/config.json +0 -35
- mcp_proxy_adapter/examples/custom_commands/custom_health_command.py +0 -169
- mcp_proxy_adapter/examples/custom_commands/custom_help_command.py +0 -215
- mcp_proxy_adapter/examples/custom_commands/custom_openapi_generator.py +0 -76
- mcp_proxy_adapter/examples/custom_commands/custom_settings.json +0 -96
- mcp_proxy_adapter/examples/custom_commands/custom_settings_manager.py +0 -241
- mcp_proxy_adapter/examples/custom_commands/data_transform_command.py +0 -135
- mcp_proxy_adapter/examples/custom_commands/echo_command.py +0 -122
- mcp_proxy_adapter/examples/custom_commands/hooks.py +0 -230
- mcp_proxy_adapter/examples/custom_commands/intercept_command.py +0 -123
- mcp_proxy_adapter/examples/custom_commands/manual_echo_command.py +0 -103
- mcp_proxy_adapter/examples/custom_commands/server.py +0 -228
- mcp_proxy_adapter/examples/custom_commands/test_hooks.py +0 -176
- mcp_proxy_adapter/examples/deployment/README.md +0 -49
- mcp_proxy_adapter/examples/deployment/__init__.py +0 -7
- mcp_proxy_adapter/examples/deployment/config.development.json +0 -8
- mcp_proxy_adapter/examples/deployment/config.json +0 -29
- mcp_proxy_adapter/examples/deployment/config.production.json +0 -12
- mcp_proxy_adapter/examples/deployment/config.staging.json +0 -11
- mcp_proxy_adapter/examples/deployment/docker-compose.yml +0 -31
- mcp_proxy_adapter/examples/deployment/run.sh +0 -43
- mcp_proxy_adapter/examples/deployment/run_docker.sh +0 -84
- mcp_proxy_adapter/schemas/base_schema.json +0 -114
- mcp_proxy_adapter/schemas/openapi_schema.json +0 -314
- mcp_proxy_adapter/tests/__init__.py +0 -0
- mcp_proxy_adapter/tests/api/__init__.py +0 -3
- mcp_proxy_adapter/tests/api/test_cmd_endpoint.py +0 -115
- mcp_proxy_adapter/tests/api/test_custom_openapi.py +0 -617
- mcp_proxy_adapter/tests/api/test_handlers.py +0 -522
- mcp_proxy_adapter/tests/api/test_middleware.py +0 -340
- mcp_proxy_adapter/tests/api/test_schemas.py +0 -546
- mcp_proxy_adapter/tests/api/test_tool_integration.py +0 -531
- mcp_proxy_adapter/tests/commands/__init__.py +0 -3
- mcp_proxy_adapter/tests/commands/test_config_command.py +0 -211
- mcp_proxy_adapter/tests/commands/test_echo_command.py +0 -127
- mcp_proxy_adapter/tests/commands/test_help_command.py +0 -136
- mcp_proxy_adapter/tests/conftest.py +0 -131
- mcp_proxy_adapter/tests/functional/__init__.py +0 -3
- mcp_proxy_adapter/tests/functional/test_api.py +0 -253
- mcp_proxy_adapter/tests/integration/__init__.py +0 -3
- mcp_proxy_adapter/tests/integration/test_cmd_integration.py +0 -129
- mcp_proxy_adapter/tests/integration/test_integration.py +0 -255
- mcp_proxy_adapter/tests/performance/__init__.py +0 -3
- mcp_proxy_adapter/tests/performance/test_performance.py +0 -189
- mcp_proxy_adapter/tests/stubs/__init__.py +0 -10
- mcp_proxy_adapter/tests/stubs/echo_command.py +0 -104
- mcp_proxy_adapter/tests/test_api_endpoints.py +0 -271
- mcp_proxy_adapter/tests/test_api_handlers.py +0 -289
- mcp_proxy_adapter/tests/test_base_command.py +0 -123
- mcp_proxy_adapter/tests/test_batch_requests.py +0 -117
- mcp_proxy_adapter/tests/test_command_registry.py +0 -281
- mcp_proxy_adapter/tests/test_config.py +0 -127
- mcp_proxy_adapter/tests/test_utils.py +0 -65
- mcp_proxy_adapter/tests/unit/__init__.py +0 -3
- mcp_proxy_adapter/tests/unit/test_base_command.py +0 -436
- mcp_proxy_adapter/tests/unit/test_config.py +0 -217
- mcp_proxy_adapter-4.1.1.dist-info/METADATA +0 -200
- mcp_proxy_adapter-4.1.1.dist-info/RECORD +0 -110
- {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.1.0.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.1.0.dist-info}/top_level.txt +0 -0
@@ -1,124 +1,257 @@
|
|
1
|
-
# MCP Proxy Adapter Examples
|
1
|
+
# MCP Proxy Adapter - Examples and Security Testing
|
2
2
|
|
3
|
-
|
3
|
+
Этот каталог содержит примеры использования MCP Proxy Adapter с различными конфигурациями безопасности и комплексную систему тестирования.
|
4
4
|
|
5
|
-
##
|
5
|
+
## 📁 Структура каталога
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
```
|
8
|
+
examples/
|
9
|
+
├── README.md # Эта документация
|
10
|
+
├── SECURITY_TESTING.md # Документация по тестированию безопасности
|
11
|
+
├── generate_certificates.py # Скрипт генерации сертификатов
|
12
|
+
├── security_test_client.py # Клиент для тестирования безопасности
|
13
|
+
├── run_security_tests.py # Основной скрипт запуска тестов
|
14
|
+
├── cert_config.json # Конфигурация для генерации сертификатов
|
15
|
+
├── certs/ # Сгенерированные сертификаты
|
16
|
+
├── keys/ # Приватные ключи
|
17
|
+
├── server_configs/ # Конфигурации серверов
|
18
|
+
│ ├── config_basic_http.json # Базовый HTTP
|
19
|
+
│ ├── config_http_token.json # HTTP + токен
|
20
|
+
│ ├── config_https.json # HTTPS
|
21
|
+
│ ├── config_https_token.json # HTTPS + токен
|
22
|
+
│ ├── config_mtls.json # mTLS
|
23
|
+
│ └── roles.json # Роли и разрешения
|
24
|
+
└── commands/ # Пользовательские команды
|
25
|
+
└── __init__.py
|
26
|
+
```
|
13
27
|
|
14
|
-
|
15
|
-
Advanced server example with custom commands and hooks. Demonstrates:
|
16
|
-
- Custom command registration
|
17
|
-
- Basic hooks (before/after execution)
|
18
|
-
- Global hooks
|
19
|
-
- Performance and security monitoring
|
20
|
-
- Advanced hooks with data transformation and command interception
|
28
|
+
## 🚀 Быстрый старт
|
21
29
|
|
22
|
-
|
30
|
+
### 1. Подготовка окружения
|
23
31
|
|
24
|
-
|
32
|
+
```bash
|
33
|
+
# Активируйте виртуальную среду
|
34
|
+
source .venv/bin/activate
|
35
|
+
|
36
|
+
# Установите зависимости
|
37
|
+
pip install -e .
|
38
|
+
```
|
25
39
|
|
26
|
-
###
|
27
|
-
```python
|
28
|
-
from mcp_proxy_adapter import create_app
|
40
|
+
### 2. Генерация сертификатов
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
)
|
42
|
+
```bash
|
43
|
+
# Сгенерируйте все необходимые сертификаты
|
44
|
+
cd mcp_proxy_adapter/examples
|
45
|
+
python generate_certificates.py
|
35
46
|
```
|
36
47
|
|
37
|
-
###
|
38
|
-
|
39
|
-
|
48
|
+
### 3. Запуск тестов безопасности
|
49
|
+
|
50
|
+
```bash
|
51
|
+
# Запустите все тесты безопасности
|
52
|
+
python run_security_tests.py
|
53
|
+
```
|
40
54
|
|
41
|
-
|
55
|
+
## 🔧 Конфигурации серверов
|
42
56
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
)
|
57
|
+
### Базовый HTTP (порт 8000)
|
58
|
+
```bash
|
59
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_basic_http.json
|
60
|
+
```
|
61
|
+
|
62
|
+
### HTTP + Токен аутентификация (порт 8001)
|
63
|
+
```bash
|
64
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_http_token.json
|
49
65
|
```
|
50
66
|
|
51
|
-
|
67
|
+
### HTTPS (порт 8443)
|
68
|
+
```bash
|
69
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_https.json
|
70
|
+
```
|
52
71
|
|
53
|
-
###
|
72
|
+
### HTTPS + Токен аутентификация (порт 8444)
|
54
73
|
```bash
|
55
|
-
|
56
|
-
python server.py
|
74
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_https_token.json
|
57
75
|
```
|
58
76
|
|
59
|
-
###
|
77
|
+
### mTLS (порт 8445)
|
60
78
|
```bash
|
61
|
-
|
62
|
-
python server.py
|
79
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_mtls.json
|
63
80
|
```
|
64
81
|
|
65
|
-
##
|
82
|
+
## 🧪 Тестирование
|
83
|
+
|
84
|
+
### Тестирование отдельного сервера
|
66
85
|
|
67
|
-
### Basic Server Commands
|
68
86
|
```bash
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
|
87
|
+
# Тест базового HTTP сервера
|
88
|
+
python security_test_client.py --server http://localhost:8000 --auth none
|
89
|
+
|
90
|
+
# Тест HTTP с токеном
|
91
|
+
python security_test_client.py --server http://localhost:8001 --auth api_key --token test-token-123
|
73
92
|
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
93
|
+
# Тест HTTPS сервера
|
94
|
+
python security_test_client.py --server https://localhost:8443 --auth none
|
95
|
+
|
96
|
+
# Тест HTTPS с токеном
|
97
|
+
python security_test_client.py --server https://localhost:8444 --auth api_key --token test-token-123
|
98
|
+
|
99
|
+
# Тест mTLS с сертификатом
|
100
|
+
python security_test_client.py --server https://localhost:8445 --auth certificate --cert certs/admin_cert.pem --key keys/admin_key.pem --ca-cert certs/ca_cert.pem
|
78
101
|
```
|
79
102
|
|
80
|
-
###
|
103
|
+
### Тестирование всех сценариев
|
104
|
+
|
81
105
|
```bash
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
-
|
107
|
-
|
108
|
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
-
|
123
|
-
|
124
|
-
|
106
|
+
# Запустите все серверы и протестируйте их
|
107
|
+
python run_security_tests.py
|
108
|
+
```
|
109
|
+
|
110
|
+
## 📋 Сценарии тестирования
|
111
|
+
|
112
|
+
### 1. Базовый HTTP (config_basic_http.json)
|
113
|
+
- **Порт**: 8000
|
114
|
+
- **Безопасность**: Отключена
|
115
|
+
- **Аутентификация**: Нет
|
116
|
+
- **Тесты**: Health check, echo command
|
117
|
+
|
118
|
+
### 2. HTTP + Токен (config_http_token.json)
|
119
|
+
- **Порт**: 8001
|
120
|
+
- **Безопасность**: API Key аутентификация
|
121
|
+
- **Токены**:
|
122
|
+
- `test-token-123` (admin)
|
123
|
+
- `user-token-456` (user)
|
124
|
+
- **Тесты**: Ролевая аутентификация, негативные тесты
|
125
|
+
|
126
|
+
### 3. HTTPS (config_https.json)
|
127
|
+
- **Порт**: 8443
|
128
|
+
- **Безопасность**: SSL/TLS
|
129
|
+
- **Сертификаты**: Самоподписанные
|
130
|
+
- **Тесты**: Защищенные соединения
|
131
|
+
|
132
|
+
### 4. HTTPS + Токен (config_https_token.json)
|
133
|
+
- **Порт**: 8444
|
134
|
+
- **Безопасность**: SSL/TLS + API Key
|
135
|
+
- **Тесты**: Комбинированная безопасность
|
136
|
+
|
137
|
+
### 5. mTLS (config_mtls.json)
|
138
|
+
- **Порт**: 8445
|
139
|
+
- **Безопасность**: Взаимная аутентификация сертификатами
|
140
|
+
- **Тесты**: Сертификатная аутентификация
|
141
|
+
|
142
|
+
## 🔑 Токены для тестирования
|
143
|
+
|
144
|
+
```json
|
145
|
+
{
|
146
|
+
"test-token-123": {
|
147
|
+
"roles": ["admin"],
|
148
|
+
"permissions": ["*"]
|
149
|
+
},
|
150
|
+
"user-token-456": {
|
151
|
+
"roles": ["user"],
|
152
|
+
"permissions": ["read", "execute"]
|
153
|
+
}
|
154
|
+
}
|
155
|
+
```
|
156
|
+
|
157
|
+
## 📜 Роли и разрешения
|
158
|
+
|
159
|
+
```json
|
160
|
+
{
|
161
|
+
"admin": ["*"],
|
162
|
+
"user": ["read", "write", "execute"],
|
163
|
+
"readonly": ["read"],
|
164
|
+
"guest": ["read"]
|
165
|
+
}
|
166
|
+
```
|
167
|
+
|
168
|
+
## 🛠️ Генерация конфигураций
|
169
|
+
|
170
|
+
Используйте встроенный генератор конфигураций:
|
171
|
+
|
172
|
+
```bash
|
173
|
+
# Генерация всех типов конфигураций
|
174
|
+
python -m mcp_proxy_adapter.utils.config_generator --all --output-dir ./generated_configs
|
175
|
+
|
176
|
+
# Генерация конкретного типа
|
177
|
+
python -m mcp_proxy_adapter.utils.config_generator --type https_token --output ./my_config.json
|
178
|
+
```
|
179
|
+
|
180
|
+
Доступные типы конфигураций:
|
181
|
+
- `minimal` - Минимальная конфигурация
|
182
|
+
- `development` - Для разработки
|
183
|
+
- `secure` - Максимальная безопасность
|
184
|
+
- `full` - Полная конфигурация
|
185
|
+
- `basic_http` - Базовый HTTP
|
186
|
+
- `http_token` - HTTP + токен
|
187
|
+
- `https` - HTTPS
|
188
|
+
- `https_token` - HTTPS + токен
|
189
|
+
- `mtls` - mTLS
|
190
|
+
|
191
|
+
## 🔍 Мониторинг и логи
|
192
|
+
|
193
|
+
Логи сохраняются в:
|
194
|
+
- `./logs/server.log` - Логи сервера
|
195
|
+
- `./logs/security.log` - Логи безопасности
|
196
|
+
|
197
|
+
Для просмотра логов в реальном времени:
|
198
|
+
```bash
|
199
|
+
tail -f logs/server.log
|
200
|
+
tail -f logs/security.log
|
201
|
+
```
|
202
|
+
|
203
|
+
## 🚨 Устранение неполадок
|
204
|
+
|
205
|
+
### Проблема: Сертификаты не найдены
|
206
|
+
```bash
|
207
|
+
# Проверьте наличие сертификатов
|
208
|
+
ls -la certs/
|
209
|
+
ls -la keys/
|
210
|
+
|
211
|
+
# Перегенерируйте сертификаты
|
212
|
+
python generate_certificates.py
|
213
|
+
```
|
214
|
+
|
215
|
+
### Проблема: Порт занят
|
216
|
+
```bash
|
217
|
+
# Найдите процесс, использующий порт
|
218
|
+
lsof -i :8000
|
219
|
+
lsof -i :8443
|
220
|
+
|
221
|
+
# Остановите процесс
|
222
|
+
kill -9 <PID>
|
223
|
+
```
|
224
|
+
|
225
|
+
### Проблема: SSL ошибки
|
226
|
+
```bash
|
227
|
+
# Проверьте сертификаты
|
228
|
+
openssl x509 -in certs/server_cert.pem -text -noout
|
229
|
+
|
230
|
+
# Проверьте приватный ключ
|
231
|
+
openssl rsa -in keys/server_key.pem -check
|
232
|
+
```
|
233
|
+
|
234
|
+
## 📚 Дополнительная документация
|
235
|
+
|
236
|
+
- [SECURITY_TESTING.md](SECURITY_TESTING.md) - Подробное руководство по тестированию безопасности
|
237
|
+
- [API Documentation](../docs/api/) - Документация API
|
238
|
+
- [Configuration Guide](../docs/configuration.md) - Руководство по конфигурации
|
239
|
+
|
240
|
+
## 🤝 Поддержка
|
241
|
+
|
242
|
+
Если у вас возникли проблемы:
|
243
|
+
|
244
|
+
1. Проверьте логи в `./logs/`
|
245
|
+
2. Убедитесь, что все зависимости установлены
|
246
|
+
3. Проверьте, что сертификаты сгенерированы корректно
|
247
|
+
4. Обратитесь к документации по устранению неполадок
|
248
|
+
|
249
|
+
## 📄 Лицензия
|
250
|
+
|
251
|
+
Этот проект распространяется под лицензией MIT. См. файл [LICENSE](../../LICENSE) для подробностей.
|
252
|
+
|
253
|
+
---
|
254
|
+
|
255
|
+
**Автор**: Vasiliy Zdanovskiy
|
256
|
+
**Email**: vasilyvz@gmail.com
|
257
|
+
**Версия**: 1.0.0
|
@@ -0,0 +1,258 @@
|
|
1
|
+
# MCP Proxy Adapter - Examples and Security Testing
|
2
|
+
|
3
|
+
This directory contains examples of using MCP Proxy Adapter with various security configurations and a comprehensive testing system.
|
4
|
+
|
5
|
+
## 📁 Directory Structure
|
6
|
+
|
7
|
+
```
|
8
|
+
examples/
|
9
|
+
├── README.md # This documentation
|
10
|
+
├── README_EN.md # English documentation
|
11
|
+
├── SECURITY_TESTING.md # Security testing documentation
|
12
|
+
├── generate_certificates.py # Certificate generation script
|
13
|
+
├── security_test_client.py # Security testing client
|
14
|
+
├── run_security_tests.py # Main test runner script
|
15
|
+
├── cert_config.json # Certificate generation configuration
|
16
|
+
├── certs/ # Generated certificates
|
17
|
+
├── keys/ # Private keys
|
18
|
+
├── server_configs/ # Server configurations
|
19
|
+
│ ├── config_basic_http.json # Basic HTTP
|
20
|
+
│ ├── config_http_token.json # HTTP + token
|
21
|
+
│ ├── config_https.json # HTTPS
|
22
|
+
│ ├── config_https_token.json # HTTPS + token
|
23
|
+
│ ├── config_mtls.json # mTLS
|
24
|
+
│ └── roles.json # Roles and permissions
|
25
|
+
└── commands/ # Custom commands
|
26
|
+
└── __init__.py
|
27
|
+
```
|
28
|
+
|
29
|
+
## 🚀 Quick Start
|
30
|
+
|
31
|
+
### 1. Environment Setup
|
32
|
+
|
33
|
+
```bash
|
34
|
+
# Activate virtual environment
|
35
|
+
source .venv/bin/activate
|
36
|
+
|
37
|
+
# Install dependencies
|
38
|
+
pip install -e .
|
39
|
+
```
|
40
|
+
|
41
|
+
### 2. Generate Certificates
|
42
|
+
|
43
|
+
```bash
|
44
|
+
# Generate all necessary certificates
|
45
|
+
cd mcp_proxy_adapter/examples
|
46
|
+
python generate_certificates.py
|
47
|
+
```
|
48
|
+
|
49
|
+
### 3. Run Security Tests
|
50
|
+
|
51
|
+
```bash
|
52
|
+
# Run all security tests
|
53
|
+
python run_security_tests.py
|
54
|
+
```
|
55
|
+
|
56
|
+
## 🔧 Server Configurations
|
57
|
+
|
58
|
+
### Basic HTTP (port 8000)
|
59
|
+
```bash
|
60
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_basic_http.json
|
61
|
+
```
|
62
|
+
|
63
|
+
### HTTP + Token Authentication (port 8001)
|
64
|
+
```bash
|
65
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_http_token.json
|
66
|
+
```
|
67
|
+
|
68
|
+
### HTTPS (port 8443)
|
69
|
+
```bash
|
70
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_https.json
|
71
|
+
```
|
72
|
+
|
73
|
+
### HTTPS + Token Authentication (port 8444)
|
74
|
+
```bash
|
75
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_https_token.json
|
76
|
+
```
|
77
|
+
|
78
|
+
### mTLS (port 8445)
|
79
|
+
```bash
|
80
|
+
python -m mcp_proxy_adapter.main --config server_configs/config_mtls.json
|
81
|
+
```
|
82
|
+
|
83
|
+
## 🧪 Testing
|
84
|
+
|
85
|
+
### Testing Individual Server
|
86
|
+
|
87
|
+
```bash
|
88
|
+
# Test basic HTTP server
|
89
|
+
python security_test_client.py --server http://localhost:8000 --auth none
|
90
|
+
|
91
|
+
# Test HTTP with token
|
92
|
+
python security_test_client.py --server http://localhost:8001 --auth api_key --token test-token-123
|
93
|
+
|
94
|
+
# Test HTTPS server
|
95
|
+
python security_test_client.py --server https://localhost:8443 --auth none
|
96
|
+
|
97
|
+
# Test HTTPS with token
|
98
|
+
python security_test_client.py --server https://localhost:8444 --auth api_key --token test-token-123
|
99
|
+
|
100
|
+
# Test mTLS with certificate
|
101
|
+
python security_test_client.py --server https://localhost:8445 --auth certificate --cert certs/admin_cert.pem --key keys/admin_key.pem --ca-cert certs/ca_cert.pem
|
102
|
+
```
|
103
|
+
|
104
|
+
### Testing All Scenarios
|
105
|
+
|
106
|
+
```bash
|
107
|
+
# Start all servers and test them
|
108
|
+
python run_security_tests.py
|
109
|
+
```
|
110
|
+
|
111
|
+
## 📋 Testing Scenarios
|
112
|
+
|
113
|
+
### 1. Basic HTTP (config_basic_http.json)
|
114
|
+
- **Port**: 8000
|
115
|
+
- **Security**: Disabled
|
116
|
+
- **Authentication**: None
|
117
|
+
- **Tests**: Health check, echo command
|
118
|
+
|
119
|
+
### 2. HTTP + Token (config_http_token.json)
|
120
|
+
- **Port**: 8001
|
121
|
+
- **Security**: API Key authentication
|
122
|
+
- **Tokens**:
|
123
|
+
- `test-token-123` (admin)
|
124
|
+
- `user-token-456` (user)
|
125
|
+
- **Tests**: Role-based authentication, negative tests
|
126
|
+
|
127
|
+
### 3. HTTPS (config_https.json)
|
128
|
+
- **Port**: 8443
|
129
|
+
- **Security**: SSL/TLS
|
130
|
+
- **Certificates**: Self-signed
|
131
|
+
- **Tests**: Secure connections
|
132
|
+
|
133
|
+
### 4. HTTPS + Token (config_https_token.json)
|
134
|
+
- **Port**: 8444
|
135
|
+
- **Security**: SSL/TLS + API Key
|
136
|
+
- **Tests**: Combined security
|
137
|
+
|
138
|
+
### 5. mTLS (config_mtls.json)
|
139
|
+
- **Port**: 8445
|
140
|
+
- **Security**: Mutual certificate authentication
|
141
|
+
- **Tests**: Certificate authentication
|
142
|
+
|
143
|
+
## 🔑 Test Tokens
|
144
|
+
|
145
|
+
```json
|
146
|
+
{
|
147
|
+
"test-token-123": {
|
148
|
+
"roles": ["admin"],
|
149
|
+
"permissions": ["*"]
|
150
|
+
},
|
151
|
+
"user-token-456": {
|
152
|
+
"roles": ["user"],
|
153
|
+
"permissions": ["read", "execute"]
|
154
|
+
}
|
155
|
+
}
|
156
|
+
```
|
157
|
+
|
158
|
+
## 📜 Roles and Permissions
|
159
|
+
|
160
|
+
```json
|
161
|
+
{
|
162
|
+
"admin": ["*"],
|
163
|
+
"user": ["read", "write", "execute"],
|
164
|
+
"readonly": ["read"],
|
165
|
+
"guest": ["read"]
|
166
|
+
}
|
167
|
+
```
|
168
|
+
|
169
|
+
## 🛠️ Configuration Generation
|
170
|
+
|
171
|
+
Use the built-in configuration generator:
|
172
|
+
|
173
|
+
```bash
|
174
|
+
# Generate all configuration types
|
175
|
+
python -m mcp_proxy_adapter.utils.config_generator --all --output-dir ./generated_configs
|
176
|
+
|
177
|
+
# Generate specific type
|
178
|
+
python -m mcp_proxy_adapter.utils.config_generator --type https_token --output ./my_config.json
|
179
|
+
```
|
180
|
+
|
181
|
+
Available configuration types:
|
182
|
+
- `minimal` - Minimal configuration
|
183
|
+
- `development` - For development
|
184
|
+
- `secure` - Maximum security
|
185
|
+
- `full` - Full configuration
|
186
|
+
- `basic_http` - Basic HTTP
|
187
|
+
- `http_token` - HTTP + token
|
188
|
+
- `https` - HTTPS
|
189
|
+
- `https_token` - HTTPS + token
|
190
|
+
- `mtls` - mTLS
|
191
|
+
|
192
|
+
## 🔍 Monitoring and Logs
|
193
|
+
|
194
|
+
Logs are saved to:
|
195
|
+
- `./logs/server.log` - Server logs
|
196
|
+
- `./logs/security.log` - Security logs
|
197
|
+
|
198
|
+
To view logs in real-time:
|
199
|
+
```bash
|
200
|
+
tail -f logs/server.log
|
201
|
+
tail -f logs/security.log
|
202
|
+
```
|
203
|
+
|
204
|
+
## 🚨 Troubleshooting
|
205
|
+
|
206
|
+
### Issue: Certificates not found
|
207
|
+
```bash
|
208
|
+
# Check certificate availability
|
209
|
+
ls -la certs/
|
210
|
+
ls -la keys/
|
211
|
+
|
212
|
+
# Regenerate certificates
|
213
|
+
python generate_certificates.py
|
214
|
+
```
|
215
|
+
|
216
|
+
### Issue: Port in use
|
217
|
+
```bash
|
218
|
+
# Find process using port
|
219
|
+
lsof -i :8000
|
220
|
+
lsof -i :8443
|
221
|
+
|
222
|
+
# Stop process
|
223
|
+
kill -9 <PID>
|
224
|
+
```
|
225
|
+
|
226
|
+
### Issue: SSL errors
|
227
|
+
```bash
|
228
|
+
# Check certificates
|
229
|
+
openssl x509 -in certs/server_cert.pem -text -noout
|
230
|
+
|
231
|
+
# Check private key
|
232
|
+
openssl rsa -in keys/server_key.pem -check
|
233
|
+
```
|
234
|
+
|
235
|
+
## 📚 Additional Documentation
|
236
|
+
|
237
|
+
- [SECURITY_TESTING.md](SECURITY_TESTING.md) - Detailed security testing guide
|
238
|
+
- [API Documentation](../docs/api/) - API documentation
|
239
|
+
- [Configuration Guide](../docs/configuration.md) - Configuration guide
|
240
|
+
|
241
|
+
## 🤝 Support
|
242
|
+
|
243
|
+
If you encounter issues:
|
244
|
+
|
245
|
+
1. Check logs in `./logs/`
|
246
|
+
2. Ensure all dependencies are installed
|
247
|
+
3. Verify certificates are generated correctly
|
248
|
+
4. Refer to troubleshooting documentation
|
249
|
+
|
250
|
+
## 📄 License
|
251
|
+
|
252
|
+
This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details.
|
253
|
+
|
254
|
+
---
|
255
|
+
|
256
|
+
**Author**: Vasiliy Zdanovskiy
|
257
|
+
**Email**: vasilyvz@gmail.com
|
258
|
+
**Version**: 1.0.0
|