mcp-proxy-adapter 4.1.1__py3-none-any.whl → 6.0.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 (101) hide show
  1. mcp_proxy_adapter/__main__.py +12 -0
  2. mcp_proxy_adapter/api/app.py +138 -11
  3. mcp_proxy_adapter/api/handlers.py +16 -1
  4. mcp_proxy_adapter/api/middleware/__init__.py +30 -29
  5. mcp_proxy_adapter/api/middleware/auth_adapter.py +235 -0
  6. mcp_proxy_adapter/api/middleware/error_handling.py +9 -0
  7. mcp_proxy_adapter/api/middleware/factory.py +219 -0
  8. mcp_proxy_adapter/api/middleware/logging.py +32 -6
  9. mcp_proxy_adapter/api/middleware/mtls_adapter.py +305 -0
  10. mcp_proxy_adapter/api/middleware/mtls_middleware.py +296 -0
  11. mcp_proxy_adapter/api/middleware/protocol_middleware.py +135 -0
  12. mcp_proxy_adapter/api/middleware/rate_limit_adapter.py +241 -0
  13. mcp_proxy_adapter/api/middleware/roles_adapter.py +365 -0
  14. mcp_proxy_adapter/api/middleware/roles_middleware.py +381 -0
  15. mcp_proxy_adapter/api/middleware/security.py +376 -0
  16. mcp_proxy_adapter/api/middleware/token_auth_middleware.py +261 -0
  17. mcp_proxy_adapter/api/middleware/transport_middleware.py +122 -0
  18. mcp_proxy_adapter/commands/__init__.py +13 -4
  19. mcp_proxy_adapter/commands/auth_validation_command.py +408 -0
  20. mcp_proxy_adapter/commands/base.py +61 -30
  21. mcp_proxy_adapter/commands/builtin_commands.py +89 -0
  22. mcp_proxy_adapter/commands/catalog_manager.py +838 -0
  23. mcp_proxy_adapter/commands/cert_monitor_command.py +620 -0
  24. mcp_proxy_adapter/commands/certificate_management_command.py +608 -0
  25. mcp_proxy_adapter/commands/command_registry.py +703 -354
  26. mcp_proxy_adapter/commands/dependency_manager.py +245 -0
  27. mcp_proxy_adapter/commands/health_command.py +7 -0
  28. mcp_proxy_adapter/commands/hooks.py +200 -167
  29. mcp_proxy_adapter/commands/key_management_command.py +506 -0
  30. mcp_proxy_adapter/commands/load_command.py +176 -0
  31. mcp_proxy_adapter/commands/plugins_command.py +235 -0
  32. mcp_proxy_adapter/commands/protocol_management_command.py +232 -0
  33. mcp_proxy_adapter/commands/proxy_registration_command.py +268 -0
  34. mcp_proxy_adapter/commands/reload_command.py +48 -50
  35. mcp_proxy_adapter/commands/result.py +1 -0
  36. mcp_proxy_adapter/commands/roles_management_command.py +697 -0
  37. mcp_proxy_adapter/commands/ssl_setup_command.py +483 -0
  38. mcp_proxy_adapter/commands/token_management_command.py +529 -0
  39. mcp_proxy_adapter/commands/transport_management_command.py +144 -0
  40. mcp_proxy_adapter/commands/unload_command.py +158 -0
  41. mcp_proxy_adapter/config.py +99 -2
  42. mcp_proxy_adapter/core/auth_validator.py +606 -0
  43. mcp_proxy_adapter/core/certificate_utils.py +827 -0
  44. mcp_proxy_adapter/core/config_converter.py +405 -0
  45. mcp_proxy_adapter/core/config_validator.py +218 -0
  46. mcp_proxy_adapter/core/logging.py +11 -0
  47. mcp_proxy_adapter/core/protocol_manager.py +226 -0
  48. mcp_proxy_adapter/core/proxy_registration.py +270 -0
  49. mcp_proxy_adapter/core/role_utils.py +426 -0
  50. mcp_proxy_adapter/core/security_adapter.py +373 -0
  51. mcp_proxy_adapter/core/security_factory.py +239 -0
  52. mcp_proxy_adapter/core/settings.py +1 -0
  53. mcp_proxy_adapter/core/ssl_utils.py +233 -0
  54. mcp_proxy_adapter/core/transport_manager.py +292 -0
  55. mcp_proxy_adapter/custom_openapi.py +22 -11
  56. mcp_proxy_adapter/examples/basic_server/config.json +58 -23
  57. mcp_proxy_adapter/examples/basic_server/config_all_protocols.json +54 -0
  58. mcp_proxy_adapter/examples/basic_server/config_http.json +70 -0
  59. mcp_proxy_adapter/examples/basic_server/config_http_only.json +52 -0
  60. mcp_proxy_adapter/examples/basic_server/config_https.json +58 -0
  61. mcp_proxy_adapter/examples/basic_server/config_mtls.json +58 -0
  62. mcp_proxy_adapter/examples/basic_server/config_ssl.json +46 -0
  63. mcp_proxy_adapter/examples/basic_server/server.py +12 -1
  64. mcp_proxy_adapter/examples/custom_commands/__init__.py +1 -1
  65. mcp_proxy_adapter/examples/custom_commands/advanced_hooks.py +339 -23
  66. mcp_proxy_adapter/examples/custom_commands/auto_commands/test_command.py +105 -0
  67. mcp_proxy_adapter/examples/custom_commands/catalog/commands/test_command.py +129 -0
  68. mcp_proxy_adapter/examples/custom_commands/config.json +101 -18
  69. mcp_proxy_adapter/examples/custom_commands/config_all_protocols.json +46 -0
  70. mcp_proxy_adapter/examples/custom_commands/config_https_only.json +46 -0
  71. mcp_proxy_adapter/examples/custom_commands/config_https_transport.json +33 -0
  72. mcp_proxy_adapter/examples/custom_commands/config_mtls_only.json +46 -0
  73. mcp_proxy_adapter/examples/custom_commands/config_mtls_transport.json +33 -0
  74. mcp_proxy_adapter/examples/custom_commands/config_single_transport.json +33 -0
  75. mcp_proxy_adapter/examples/custom_commands/full_help_response.json +1 -0
  76. mcp_proxy_adapter/examples/custom_commands/generated_openapi.json +629 -0
  77. mcp_proxy_adapter/examples/custom_commands/get_openapi.py +103 -0
  78. mcp_proxy_adapter/examples/custom_commands/loadable_commands/test_ignored.py +129 -0
  79. mcp_proxy_adapter/examples/custom_commands/proxy_connection_manager.py +278 -0
  80. mcp_proxy_adapter/examples/custom_commands/server.py +92 -68
  81. mcp_proxy_adapter/examples/custom_commands/simple_openapi_server.py +75 -0
  82. mcp_proxy_adapter/examples/custom_commands/start_server_with_proxy_manager.py +299 -0
  83. mcp_proxy_adapter/examples/custom_commands/start_server_with_registration.py +278 -0
  84. mcp_proxy_adapter/examples/custom_commands/test_openapi.py +27 -0
  85. mcp_proxy_adapter/examples/custom_commands/test_registry.py +23 -0
  86. mcp_proxy_adapter/examples/custom_commands/test_simple.py +19 -0
  87. mcp_proxy_adapter/examples/custom_project_example/README.md +103 -0
  88. mcp_proxy_adapter/examples/custom_project_example/README_EN.md +103 -0
  89. mcp_proxy_adapter/examples/simple_custom_commands/README.md +149 -0
  90. mcp_proxy_adapter/examples/simple_custom_commands/README_EN.md +149 -0
  91. mcp_proxy_adapter/main.py +175 -0
  92. mcp_proxy_adapter/schemas/roles_schema.json +162 -0
  93. mcp_proxy_adapter/tests/unit/test_config.py +53 -0
  94. mcp_proxy_adapter/version.py +1 -1
  95. {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.0.0.dist-info}/METADATA +2 -1
  96. mcp_proxy_adapter-6.0.0.dist-info/RECORD +179 -0
  97. mcp_proxy_adapter/commands/reload_settings_command.py +0 -125
  98. mcp_proxy_adapter-4.1.1.dist-info/RECORD +0 -110
  99. {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.0.0.dist-info}/WHEEL +0 -0
  100. {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.0.0.dist-info}/licenses/LICENSE +0 -0
  101. {mcp_proxy_adapter-4.1.1.dist-info → mcp_proxy_adapter-6.0.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,54 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 8000,
5
+ "debug": true,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "console_output": true
12
+ },
13
+ "commands": {
14
+ "auto_discovery": true,
15
+ "discovery_path": "mcp_proxy_adapter.commands"
16
+ },
17
+ "ssl": {
18
+ "enabled": true,
19
+ "mode": "mtls",
20
+ "cert_file": "../../../test_env/server/server.crt",
21
+ "key_file": "../../../test_env/server/server.key",
22
+ "ca_cert": "../../../test_env/ca/ca.crt",
23
+ "verify_client": true,
24
+ "client_cert_required": true
25
+ },
26
+ "protocols": {
27
+ "enabled": true,
28
+ "allowed_protocols": ["http", "https", "mtls"],
29
+ "http": {
30
+ "enabled": true,
31
+ "port": 8000
32
+ },
33
+ "https": {
34
+ "enabled": true,
35
+ "port": 8443
36
+ },
37
+ "mtls": {
38
+ "enabled": true,
39
+ "port": 9443
40
+ }
41
+ },
42
+ "proxy_registration": {
43
+ "enabled": true,
44
+ "proxy_url": "http://localhost:3004",
45
+ "server_id": "mcp_proxy_adapter_all_protocols",
46
+ "server_name": "Multi-Protocol MCP Proxy Adapter Server",
47
+ "description": "JSON-RPC API for interacting with MCP Proxy (HTTP/HTTPS/MTLS modes)",
48
+ "registration_timeout": 30,
49
+ "retry_attempts": 3,
50
+ "retry_delay": 5,
51
+ "auto_register_on_startup": true,
52
+ "auto_unregister_on_shutdown": true
53
+ }
54
+ }
@@ -0,0 +1,70 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 8443,
5
+ "debug": true,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "console_output": true
12
+ },
13
+ "commands": {
14
+ "auto_discovery": true,
15
+ "discovery_path": "mcp_proxy_adapter.commands"
16
+ },
17
+ "ssl": {
18
+ "enabled": true,
19
+ "mode": "https_only",
20
+ "cert_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.crt",
21
+ "key_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.key",
22
+ "ca_cert": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/ca_test-ca.crt",
23
+ "verify_client": false,
24
+ "client_cert_required": false
25
+ },
26
+ "protocols": {
27
+ "enabled": true,
28
+ "allowed_protocols": ["https"],
29
+ "http": {
30
+ "enabled": false,
31
+ "port": 8000
32
+ },
33
+ "https": {
34
+ "enabled": true,
35
+ "port": 8443
36
+ },
37
+ "mtls": {
38
+ "enabled": false,
39
+ "port": 9443
40
+ }
41
+ },
42
+ "roles": {
43
+ "enabled": false,
44
+ "config_file": "schemas/roles_schema.json",
45
+ "default_policy": {
46
+ "deny_by_default": false,
47
+ "require_role_match": false,
48
+ "case_sensitive": false,
49
+ "allow_wildcard": true
50
+ },
51
+ "auto_load": false,
52
+ "validation_enabled": false
53
+ },
54
+ "proxy_registration": {
55
+ "enabled": true,
56
+ "proxy_url": "http://localhost:3004",
57
+ "server_id": "mcp_proxy_adapter_https",
58
+ "server_name": "HTTPS MCP Proxy Adapter Server",
59
+ "description": "JSON-RPC API for interacting with MCP Proxy (HTTPS mode)",
60
+ "registration_timeout": 30,
61
+ "retry_attempts": 3,
62
+ "retry_delay": 5,
63
+ "auto_register_on_startup": true,
64
+ "auto_unregister_on_shutdown": true
65
+ },
66
+ "custom": {
67
+ "description": "HTTPS-only server example",
68
+ "server_name": "HTTPS MCP Proxy Adapter Server"
69
+ }
70
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 8000,
5
+ "debug": true,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "console_output": true
12
+ },
13
+ "commands": {
14
+ "auto_discovery": true,
15
+ "discovery_path": "mcp_proxy_adapter.commands"
16
+ },
17
+ "ssl": {
18
+ "enabled": false
19
+ },
20
+ "protocols": {
21
+ "enabled": true,
22
+ "allowed_protocols": ["http"],
23
+ "http": {
24
+ "enabled": true,
25
+ "port": 8000
26
+ },
27
+ "https": {
28
+ "enabled": false,
29
+ "port": 8443
30
+ },
31
+ "mtls": {
32
+ "enabled": false,
33
+ "port": 9443
34
+ }
35
+ },
36
+ "proxy_registration": {
37
+ "enabled": true,
38
+ "proxy_url": "http://localhost:3004",
39
+ "server_id": "mcp_proxy_adapter_http",
40
+ "server_name": "HTTP MCP Proxy Adapter Server",
41
+ "description": "JSON-RPC API for interacting with MCP Proxy (HTTP mode)",
42
+ "registration_timeout": 30,
43
+ "retry_attempts": 3,
44
+ "retry_delay": 5,
45
+ "auto_register_on_startup": true,
46
+ "auto_unregister_on_shutdown": true
47
+ },
48
+ "custom": {
49
+ "description": "HTTP-only server example",
50
+ "server_name": "HTTP MCP Proxy Adapter Server"
51
+ }
52
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 8443,
5
+ "debug": true,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "console_output": true
12
+ },
13
+ "commands": {
14
+ "auto_discovery": true,
15
+ "discovery_path": "mcp_proxy_adapter.commands"
16
+ },
17
+ "ssl": {
18
+ "enabled": true,
19
+ "mode": "https_only",
20
+ "cert_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.crt",
21
+ "key_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.key",
22
+ "ca_cert": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/ca_test-ca.crt",
23
+ "verify_client": false,
24
+ "client_cert_required": false
25
+ },
26
+ "protocols": {
27
+ "enabled": true,
28
+ "allowed_protocols": ["https"],
29
+ "http": {
30
+ "enabled": false,
31
+ "port": 8000
32
+ },
33
+ "https": {
34
+ "enabled": true,
35
+ "port": 8443
36
+ },
37
+ "mtls": {
38
+ "enabled": false,
39
+ "port": 9443
40
+ }
41
+ },
42
+ "roles": {
43
+ "enabled": false,
44
+ "config_file": "schemas/roles_schema.json",
45
+ "default_policy": {
46
+ "deny_by_default": false,
47
+ "require_role_match": false,
48
+ "case_sensitive": false,
49
+ "allow_wildcard": true
50
+ },
51
+ "auto_load": false,
52
+ "validation_enabled": false
53
+ },
54
+ "custom": {
55
+ "description": "HTTPS-only server example",
56
+ "server_name": "HTTPS MCP Proxy Adapter Server"
57
+ }
58
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 9443,
5
+ "debug": true,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "console_output": true
12
+ },
13
+ "commands": {
14
+ "auto_discovery": true,
15
+ "discovery_path": "mcp_proxy_adapter.commands"
16
+ },
17
+ "ssl": {
18
+ "enabled": true,
19
+ "mode": "mtls_only",
20
+ "cert_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.crt",
21
+ "key_file": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/server_test-server.key",
22
+ "ca_cert": "/home/vasilyvz/projects/mcp_proxy_adapter/test_env/ca_test-ca.crt",
23
+ "verify_client": true,
24
+ "client_cert_required": true
25
+ },
26
+ "protocols": {
27
+ "enabled": true,
28
+ "allowed_protocols": ["mtls"],
29
+ "http": {
30
+ "enabled": false,
31
+ "port": 8000
32
+ },
33
+ "https": {
34
+ "enabled": false,
35
+ "port": 8443
36
+ },
37
+ "mtls": {
38
+ "enabled": true,
39
+ "port": 9443
40
+ }
41
+ },
42
+ "roles": {
43
+ "enabled": true,
44
+ "config_file": "schemas/roles_schema.json",
45
+ "default_policy": {
46
+ "deny_by_default": true,
47
+ "require_role_match": true,
48
+ "case_sensitive": false,
49
+ "allow_wildcard": true
50
+ },
51
+ "auto_load": true,
52
+ "validation_enabled": true
53
+ },
54
+ "custom": {
55
+ "description": "MTLS-only server example with mutual authentication",
56
+ "server_name": "MTLS MCP Proxy Adapter Server"
57
+ }
58
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "server": {
3
+ "host": "0.0.0.0",
4
+ "port": 8443,
5
+ "debug": false,
6
+ "log_level": "INFO"
7
+ },
8
+ "logging": {
9
+ "level": "INFO",
10
+ "log_dir": "./logs",
11
+ "log_file": "basic_server_ssl.log",
12
+ "console_output": true,
13
+ "file_output": true
14
+ },
15
+ "commands": {
16
+ "auto_discovery": true,
17
+ "commands_directory": "./commands",
18
+ "catalog_directory": "./catalog",
19
+ "plugin_servers": [],
20
+ "auto_install_dependencies": true
21
+ },
22
+ "ssl": {
23
+ "enabled": true,
24
+ "mode": "https_only",
25
+ "cert_file": "./certs/server.crt",
26
+ "key_file": "./certs/server.key",
27
+ "ca_cert": "./certs/ca.crt",
28
+ "verify_client": false,
29
+ "client_cert_required": false,
30
+ "cipher_suites": [
31
+ "TLS_AES_256_GCM_SHA384",
32
+ "TLS_CHACHA20_POLY1305_SHA256",
33
+ "TLS_AES_128_GCM_SHA256"
34
+ ],
35
+ "min_tls_version": "1.2",
36
+ "max_tls_version": "1.3"
37
+ },
38
+ "debug": {
39
+ "enabled": false,
40
+ "level": "WARNING"
41
+ },
42
+ "custom": {
43
+ "server_name": "Basic MCP Proxy Adapter Server (SSL)",
44
+ "description": "Basic server example with SSL/TLS encryption enabled"
45
+ }
46
+ }
@@ -20,6 +20,7 @@ from mcp_proxy_adapter.core.settings import (
20
20
  get_server_debug,
21
21
  get_setting
22
22
  )
23
+ from mcp_proxy_adapter.core.ssl_utils import SSLUtils
23
24
 
24
25
 
25
26
  def main():
@@ -42,6 +43,7 @@ def main():
42
43
  server_settings = Settings.get_server_settings()
43
44
  logging_settings = Settings.get_logging_settings()
44
45
  commands_settings = Settings.get_commands_settings()
46
+ ssl_settings = Settings.get_custom_setting("ssl", {})
45
47
  custom_settings = Settings.get_custom_setting("custom", {})
46
48
 
47
49
  # Print server header and description
@@ -58,6 +60,10 @@ def main():
58
60
  print(f" • Log Directory: {logging_settings['log_dir']}")
59
61
  print(f" • Auto Discovery: {commands_settings['auto_discovery']}")
60
62
  print(f" • Discovery Path: {commands_settings['discovery_path']}")
63
+ print(f" • SSL Enabled: {ssl_settings.get('enabled', False)}")
64
+ if ssl_settings.get('enabled', False):
65
+ print(f" • SSL Mode: {ssl_settings.get('mode', 'https_only')}")
66
+ print(f" • SSL Cert: {ssl_settings.get('cert_file', 'Not specified')}")
61
67
  print()
62
68
  print("🔧 Available Commands:")
63
69
  print(" • help - Built-in help command")
@@ -82,6 +88,7 @@ def main():
82
88
  logger.info(f"Server configuration: {server_settings}")
83
89
  logger.info(f"Logging configuration: {logging_settings}")
84
90
  logger.info(f"Commands configuration: {commands_settings}")
91
+ logger.info(f"SSL configuration: {ssl_settings}")
85
92
 
86
93
  # Create application with settings from configuration
87
94
  app = create_app(
@@ -90,12 +97,16 @@ def main():
90
97
  version="1.0.0"
91
98
  )
92
99
 
100
+ # Get SSL configuration for uvicorn
101
+ uvicorn_ssl_config = SSLUtils.get_ssl_config_for_uvicorn(ssl_settings)
102
+
93
103
  # Run the server with configuration settings
94
104
  uvicorn.run(
95
105
  app,
96
106
  host=server_settings['host'],
97
107
  port=server_settings['port'],
98
- log_level=server_settings['log_level'].lower()
108
+ log_level=server_settings['log_level'].lower(),
109
+ **uvicorn_ssl_config
99
110
  )
100
111
 
101
112
 
@@ -20,7 +20,7 @@ from . import advanced_hooks
20
20
  from . import hooks
21
21
  from . import custom_settings_manager
22
22
  from . import custom_openapi_generator
23
- from . import server
23
+ # Server import removed to avoid circular imports
24
24
 
25
25
  # Import auto commands
26
26
  from .auto_commands import auto_echo_command