mcp-proxy-adapter 6.2.6__py3-none-any.whl → 6.2.8__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 +1 -1
- mcp_proxy_adapter/examples/__init__.py +1 -1
- mcp_proxy_adapter/examples/full_application/__init__.py +2 -1
- mcp_proxy_adapter/examples/full_application/main.py +14 -0
- mcp_proxy_adapter/examples/generate_certificates.py +48 -34
- mcp_proxy_adapter/examples/generate_test_configs.py +19 -1
- mcp_proxy_adapter/examples/run_security_tests.py +33 -7
- mcp_proxy_adapter/examples/setup_test_environment.py +199 -62
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.2.6.dist-info → mcp_proxy_adapter-6.2.8.dist-info}/METADATA +2 -2
- {mcp_proxy_adapter-6.2.6.dist-info → mcp_proxy_adapter-6.2.8.dist-info}/RECORD +14 -14
- {mcp_proxy_adapter-6.2.6.dist-info → mcp_proxy_adapter-6.2.8.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.2.6.dist-info → mcp_proxy_adapter-6.2.8.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.2.6.dist-info → mcp_proxy_adapter-6.2.8.dist-info}/top_level.txt +0 -0
mcp_proxy_adapter/__main__.py
CHANGED
@@ -155,5 +155,19 @@ def main():
|
|
155
155
|
# Create and run application
|
156
156
|
app = FullApplication(args.config)
|
157
157
|
app.run(host=args.host, port=args.port, debug=args.debug)
|
158
|
+
# Create global app instance for import
|
159
|
+
app = None
|
160
|
+
|
161
|
+
def get_app():
|
162
|
+
"""Get the FastAPI application instance."""
|
163
|
+
global app
|
164
|
+
if app is None:
|
165
|
+
# Create a default configuration for import
|
166
|
+
config = Config("configs/mtls_with_roles.json") # Default config
|
167
|
+
app_instance = FullApplication("configs/mtls_with_roles.json")
|
168
|
+
app_instance.create_application()
|
169
|
+
app = app_instance.app
|
170
|
+
return app
|
171
|
+
|
158
172
|
if __name__ == "__main__":
|
159
173
|
main()
|
@@ -7,6 +7,7 @@ Author: Vasiliy Zdanovskiy
|
|
7
7
|
email: vasilyvz@gmail.com
|
8
8
|
"""
|
9
9
|
import os
|
10
|
+
import sys
|
10
11
|
from pathlib import Path
|
11
12
|
from datetime import datetime, timedelta, timezone
|
12
13
|
|
@@ -34,7 +35,18 @@ def main():
|
|
34
35
|
|
35
36
|
try:
|
36
37
|
print("🔧 Creating root CA certificate...")
|
37
|
-
|
38
|
+
|
39
|
+
# Initialize certificate manager first
|
40
|
+
cert_config = CertificateConfig(
|
41
|
+
cert_storage_path=str(cert_dir),
|
42
|
+
key_storage_path=str(key_dir),
|
43
|
+
default_validity_days=365,
|
44
|
+
key_size=2048,
|
45
|
+
hash_algorithm="sha256"
|
46
|
+
)
|
47
|
+
cert_manager = CertificateManager(cert_config)
|
48
|
+
|
49
|
+
# Create CA certificate using API
|
38
50
|
ca_config = CAConfig(
|
39
51
|
common_name="MCP Proxy Adapter CA",
|
40
52
|
organization="MCP Proxy Adapter",
|
@@ -43,42 +55,19 @@ def main():
|
|
43
55
|
state="State",
|
44
56
|
locality="City",
|
45
57
|
validity_years=10,
|
46
|
-
key_size=2048
|
58
|
+
key_size=2048,
|
59
|
+
hash_algorithm="sha256"
|
47
60
|
)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
"python", "-m", "mcp_security_framework.cli.cert_cli", "create-ca",
|
53
|
-
"--common-name", "MCP Proxy Adapter CA",
|
54
|
-
"--organization", "MCP Proxy Adapter",
|
55
|
-
"--country", "US",
|
56
|
-
"--state", "State",
|
57
|
-
"--locality", "City",
|
58
|
-
"--validity-years", "10",
|
59
|
-
"--key-size", "2048"
|
60
|
-
], capture_output=True, text=True)
|
61
|
-
|
62
|
-
if result.returncode != 0:
|
63
|
-
print(f"❌ CA creation failed: {result.stderr}")
|
61
|
+
|
62
|
+
ca_cert_pair = cert_manager.create_root_ca(ca_config)
|
63
|
+
if not ca_cert_pair or not ca_cert_pair.certificate_path:
|
64
|
+
print("❌ Failed to create CA certificate")
|
64
65
|
return False
|
65
|
-
|
66
|
-
ca_cert_path =
|
67
|
-
ca_key_path =
|
66
|
+
|
67
|
+
ca_cert_path = ca_cert_pair.certificate_path
|
68
|
+
ca_key_path = ca_cert_pair.private_key_path
|
68
69
|
print(f"✅ Root CA certificate created: {ca_cert_path}")
|
69
70
|
|
70
|
-
# Now initialize certificate manager with existing CA
|
71
|
-
cert_config = CertificateConfig(
|
72
|
-
enabled=True,
|
73
|
-
ca_cert_path=str(ca_cert_path),
|
74
|
-
ca_key_path=str(ca_key_path),
|
75
|
-
cert_storage_path=str(cert_dir),
|
76
|
-
key_storage_path=str(key_dir)
|
77
|
-
)
|
78
|
-
|
79
|
-
# Initialize certificate manager
|
80
|
-
cert_manager = CertificateManager(cert_config)
|
81
|
-
|
82
71
|
print("🔧 Creating server certificate...")
|
83
72
|
# Create server certificate
|
84
73
|
server_config = ServerCertConfig(
|
@@ -151,13 +140,38 @@ def main():
|
|
151
140
|
print(f"🔑 Private keys are stored in the '{key_dir}' directory")
|
152
141
|
print(f"🔐 CA certificate: {ca_cert_path}")
|
153
142
|
print(f"🔐 Server certificate: {server_cert_pair.certificate_path}")
|
143
|
+
|
144
|
+
print("\n" + "=" * 60)
|
145
|
+
print("✅ CERTIFICATE GENERATION COMPLETED SUCCESSFULLY")
|
146
|
+
print("=" * 60)
|
147
|
+
print("\n📋 NEXT STEPS:")
|
148
|
+
print("1. Generate test configurations:")
|
149
|
+
print(" python -m mcp_proxy_adapter.examples.generate_test_configs --output-dir configs")
|
150
|
+
print("\n2. Run security tests:")
|
151
|
+
print(" python -m mcp_proxy_adapter.examples.run_security_tests")
|
152
|
+
print("\n3. Start basic framework example:")
|
153
|
+
print(" python -m mcp_proxy_adapter.examples.basic_framework.main --config configs/https_simple.json")
|
154
|
+
print("=" * 60)
|
154
155
|
return True
|
155
156
|
|
156
157
|
except Exception as e:
|
157
|
-
print(f"❌
|
158
|
+
print(f"\n❌ CERTIFICATE GENERATION FAILED: {e}")
|
159
|
+
print("=" * 60)
|
158
160
|
import traceback
|
159
161
|
traceback.print_exc()
|
162
|
+
print("\n🔧 TROUBLESHOOTING:")
|
163
|
+
print("1. Check if mcp_security_framework is installed:")
|
164
|
+
print(" pip install mcp_security_framework")
|
165
|
+
print("\n2. Verify write permissions in current directory")
|
166
|
+
print("\n3. Check if certs/ and keys/ directories exist")
|
167
|
+
print("=" * 60)
|
160
168
|
return False
|
169
|
+
|
161
170
|
if __name__ == "__main__":
|
171
|
+
print("🔐 Starting certificate generation...")
|
162
172
|
success = main()
|
173
|
+
if success:
|
174
|
+
print("\n✅ Script completed successfully!")
|
175
|
+
else:
|
176
|
+
print("\n❌ Script failed with errors!")
|
163
177
|
sys.exit(0 if success else 1)
|
@@ -182,6 +182,18 @@ def generate_all_configs(output_dir: str) -> None:
|
|
182
182
|
json.dump(roles_config, f, indent=2, ensure_ascii=False)
|
183
183
|
print(f"Generated: {certs_roles_filename}")
|
184
184
|
print(f"\nGenerated {len(configs)} configuration files and roles.json in {output_dir}")
|
185
|
+
|
186
|
+
print("\n" + "=" * 60)
|
187
|
+
print("✅ CONFIGURATION GENERATION COMPLETED SUCCESSFULLY")
|
188
|
+
print("=" * 60)
|
189
|
+
print("\n📋 NEXT STEPS:")
|
190
|
+
print("1. Run security tests:")
|
191
|
+
print(" python -m mcp_proxy_adapter.examples.run_security_tests")
|
192
|
+
print("\n2. Start basic framework example:")
|
193
|
+
print(" python -m mcp_proxy_adapter.examples.basic_framework.main --config configs/https_simple.json")
|
194
|
+
print("\n3. Start full application example:")
|
195
|
+
print(" python -m mcp_proxy_adapter.examples.full_application.main --config configs/mtls_with_roles.json")
|
196
|
+
print("=" * 60)
|
185
197
|
def main():
|
186
198
|
"""Main function for command line execution."""
|
187
199
|
parser = argparse.ArgumentParser(
|
@@ -197,7 +209,13 @@ def main():
|
|
197
209
|
generate_all_configs(args.output_dir)
|
198
210
|
print("Configuration generation completed successfully!")
|
199
211
|
except Exception as e:
|
200
|
-
print(f"
|
212
|
+
print(f"\n❌ CONFIGURATION GENERATION FAILED: {e}")
|
213
|
+
print("=" * 60)
|
214
|
+
print("\n🔧 TROUBLESHOOTING:")
|
215
|
+
print("1. Check if output directory is writable")
|
216
|
+
print("2. Verify JSON encoding support")
|
217
|
+
print("3. Check available disk space")
|
218
|
+
print("=" * 60)
|
201
219
|
return 1
|
202
220
|
return 0
|
203
221
|
if __name__ == "__main__":
|
@@ -29,31 +29,31 @@ class SecurityTestRunner:
|
|
29
29
|
self.test_results = {}
|
30
30
|
self.configs = {
|
31
31
|
"basic_http": {
|
32
|
-
"config": "
|
32
|
+
"config": "configs/http_simple.json",
|
33
33
|
"port": 8000,
|
34
34
|
"url": "http://localhost:8000",
|
35
35
|
"auth": "none"
|
36
36
|
},
|
37
37
|
"http_token": {
|
38
|
-
"config": "
|
38
|
+
"config": "configs/http_token.json",
|
39
39
|
"port": 8001,
|
40
40
|
"url": "http://localhost:8001",
|
41
41
|
"auth": "api_key"
|
42
42
|
},
|
43
43
|
"https": {
|
44
|
-
"config": "
|
44
|
+
"config": "configs/https_simple.json",
|
45
45
|
"port": 8443,
|
46
46
|
"url": "https://localhost:8443",
|
47
47
|
"auth": "none"
|
48
48
|
},
|
49
49
|
"https_token": {
|
50
|
-
"config": "
|
50
|
+
"config": "configs/https_token.json",
|
51
51
|
"port": 8444,
|
52
52
|
"url": "https://localhost:8444",
|
53
53
|
"auth": "api_key"
|
54
54
|
},
|
55
55
|
"mtls": {
|
56
|
-
"config": "
|
56
|
+
"config": "configs/mtls_with_roles.json",
|
57
57
|
"port": 8445,
|
58
58
|
"url": "https://localhost:8445",
|
59
59
|
"auth": "certificate"
|
@@ -63,8 +63,8 @@ class SecurityTestRunner:
|
|
63
63
|
"""Check if all prerequisites are met."""
|
64
64
|
print("🔍 Checking prerequisites...")
|
65
65
|
# Check if we're in the right directory
|
66
|
-
if not Path("
|
67
|
-
print("❌
|
66
|
+
if not Path("configs").exists():
|
67
|
+
print("❌ configs directory not found. Please run from the test environment root directory.")
|
68
68
|
return False
|
69
69
|
# Check if certificates exist
|
70
70
|
cert_files = [
|
@@ -205,10 +205,36 @@ class SecurityTestRunner:
|
|
205
205
|
# Overall status
|
206
206
|
if total_passed == total_tests and total_tests > 0:
|
207
207
|
print("🎉 ALL TESTS PASSED!")
|
208
|
+
print("\n" + "=" * 60)
|
209
|
+
print("✅ SECURITY TESTS COMPLETED SUCCESSFULLY")
|
210
|
+
print("=" * 60)
|
211
|
+
print("\n📋 NEXT STEPS:")
|
212
|
+
print("1. Start basic framework example:")
|
213
|
+
print(" python -m mcp_proxy_adapter.examples.basic_framework.main --config configs/https_simple.json")
|
214
|
+
print("\n2. Start full application example:")
|
215
|
+
print(" python -m mcp_proxy_adapter.examples.full_application.main --config configs/mtls_with_roles.json")
|
216
|
+
print("\n3. Test with custom configurations:")
|
217
|
+
print(" python -m mcp_proxy_adapter.examples.basic_framework.main --config configs/http_simple.json")
|
218
|
+
print("=" * 60)
|
208
219
|
elif total_passed > 0:
|
209
220
|
print("⚠️ SOME TESTS FAILED")
|
221
|
+
print("\n🔧 TROUBLESHOOTING:")
|
222
|
+
print("1. Check if certificates are generated:")
|
223
|
+
print(" python -m mcp_proxy_adapter.examples.generate_certificates")
|
224
|
+
print("\n2. Verify configuration files exist:")
|
225
|
+
print(" python -m mcp_proxy_adapter.examples.generate_test_configs --output-dir configs")
|
226
|
+
print("\n3. Check if ports are available (8000-8005, 8443-8445)")
|
227
|
+
print("=" * 60)
|
210
228
|
else:
|
211
229
|
print("❌ ALL TESTS FAILED")
|
230
|
+
print("\n🔧 TROUBLESHOOTING:")
|
231
|
+
print("1. Run setup test environment:")
|
232
|
+
print(" python -m mcp_proxy_adapter.examples.setup_test_environment")
|
233
|
+
print("\n2. Generate certificates:")
|
234
|
+
print(" python -m mcp_proxy_adapter.examples.generate_certificates")
|
235
|
+
print("\n3. Generate configurations:")
|
236
|
+
print(" python -m mcp_proxy_adapter.examples.generate_test_configs --output-dir configs")
|
237
|
+
print("=" * 60)
|
212
238
|
def cleanup(self):
|
213
239
|
"""Cleanup all running servers."""
|
214
240
|
print("\n🧹 Cleaning up...")
|
@@ -5,25 +5,52 @@ email: vasilyvz@gmail.com
|
|
5
5
|
Script for setting up test environment for MCP Proxy Adapter.
|
6
6
|
Prepares the test environment with all necessary files and directories.
|
7
7
|
Uses mcp_security_framework for certificate generation.
|
8
|
+
|
9
|
+
This script accepts an output directory and copies required example files
|
10
|
+
and helper scripts into that directory, creating a ready-to-use workspace.
|
11
|
+
By default, the current working directory is used, so end-users can run
|
12
|
+
it in their project root after installing this framework in a virtual
|
13
|
+
environment.
|
8
14
|
"""
|
9
|
-
import os
|
10
15
|
import shutil
|
11
16
|
import sys
|
17
|
+
import argparse
|
12
18
|
from pathlib import Path
|
13
19
|
# Import mcp_security_framework
|
14
20
|
try:
|
15
21
|
from mcp_security_framework.core.cert_manager import CertificateManager
|
16
|
-
from mcp_security_framework.schemas.config import
|
17
|
-
|
22
|
+
from mcp_security_framework.schemas.config import (
|
23
|
+
CertificateConfig,
|
24
|
+
CAConfig,
|
25
|
+
ServerCertConfig,
|
26
|
+
ClientCertConfig,
|
27
|
+
)
|
18
28
|
SECURITY_FRAMEWORK_AVAILABLE = True
|
19
29
|
except ImportError:
|
20
30
|
SECURITY_FRAMEWORK_AVAILABLE = False
|
21
31
|
print("Warning: mcp_security_framework not available")
|
22
|
-
|
32
|
+
|
33
|
+
|
34
|
+
def _get_package_paths() -> tuple[Path, Path]:
|
23
35
|
"""
|
24
|
-
|
36
|
+
Resolve source paths for examples and utils relative to this file
|
37
|
+
to avoid importing the package during setup.
|
38
|
+
"""
|
39
|
+
pkg_root = Path(__file__).resolve().parents[1]
|
40
|
+
return pkg_root / "examples", pkg_root / "utils"
|
41
|
+
|
42
|
+
|
43
|
+
def setup_test_environment(output_dir: Path) -> None:
|
44
|
+
"""
|
45
|
+
Setup test environment under output_dir with required files
|
46
|
+
and directories.
|
47
|
+
|
48
|
+
All created directories and copied files are rooted at output_dir
|
49
|
+
so users can run scripts relative to that directory.
|
25
50
|
"""
|
26
51
|
print("🔧 Setting up test environment...")
|
52
|
+
output_dir = output_dir.resolve()
|
53
|
+
output_dir.mkdir(parents=True, exist_ok=True)
|
27
54
|
# Create test environment directory structure
|
28
55
|
directories = [
|
29
56
|
"examples/basic_framework",
|
@@ -36,57 +63,70 @@ def setup_test_environment():
|
|
36
63
|
"logs"
|
37
64
|
]
|
38
65
|
for directory in directories:
|
39
|
-
|
40
|
-
|
66
|
+
target_dir = output_dir / directory
|
67
|
+
target_dir.mkdir(parents=True, exist_ok=True)
|
68
|
+
print(f"✅ Created directory: {target_dir}")
|
69
|
+
# Resolve package paths
|
70
|
+
examples_src_root, utils_src_root = _get_package_paths()
|
41
71
|
# Copy example files
|
42
|
-
|
43
|
-
if
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
72
|
+
basic_framework_src = examples_src_root / "basic_framework"
|
73
|
+
if basic_framework_src.exists():
|
74
|
+
shutil.copytree(
|
75
|
+
basic_framework_src,
|
76
|
+
output_dir / "examples/basic_framework",
|
77
|
+
dirs_exist_ok=True,
|
78
|
+
)
|
79
|
+
print("✅ Copied basic_framework examples")
|
80
|
+
full_application_src = examples_src_root / "full_application"
|
81
|
+
if full_application_src.exists():
|
82
|
+
shutil.copytree(
|
83
|
+
full_application_src,
|
84
|
+
output_dir / "examples/full_application",
|
85
|
+
dirs_exist_ok=True,
|
86
|
+
)
|
87
|
+
print("✅ Copied full_application examples")
|
54
88
|
# Copy utility scripts
|
55
|
-
|
56
|
-
if
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
89
|
+
config_generator_src = utils_src_root / "config_generator.py"
|
90
|
+
if config_generator_src.exists():
|
91
|
+
shutil.copy2(config_generator_src, output_dir / "scripts/")
|
92
|
+
print("✅ Copied config_generator.py")
|
93
|
+
# Copy certificate generation scripts
|
94
|
+
create_certs_src = examples_src_root / "create_certificates_simple.py"
|
95
|
+
if create_certs_src.exists():
|
96
|
+
shutil.copy2(create_certs_src, output_dir / "scripts/")
|
97
|
+
print("✅ Copied create_certificates_simple.py")
|
98
|
+
cert_tokens_src = examples_src_root / "generate_certificates_and_tokens.py"
|
99
|
+
if cert_tokens_src.exists():
|
100
|
+
shutil.copy2(cert_tokens_src, output_dir / "scripts/")
|
101
|
+
print("✅ Copied generate_certificates_and_tokens.py")
|
102
|
+
print(
|
103
|
+
"🎉 Test environment setup completed successfully at: {}".format(
|
104
|
+
output_dir
|
105
|
+
)
|
106
|
+
)
|
107
|
+
|
108
|
+
|
109
|
+
def generate_certificates_with_framework(output_dir: Path) -> bool:
|
75
110
|
"""
|
76
111
|
Generate certificates using mcp_security_framework.
|
77
112
|
"""
|
78
113
|
if not SECURITY_FRAMEWORK_AVAILABLE:
|
79
|
-
print(
|
114
|
+
print(
|
115
|
+
"❌ mcp_security_framework not available for certificate "
|
116
|
+
"generation"
|
117
|
+
)
|
80
118
|
return False
|
81
119
|
try:
|
82
|
-
print(
|
120
|
+
print(
|
121
|
+
"🔐 Generating certificates using mcp_security_framework..."
|
122
|
+
)
|
83
123
|
# Configure certificate manager
|
84
124
|
cert_config = CertificateConfig(
|
85
|
-
cert_storage_path="
|
86
|
-
key_storage_path="
|
125
|
+
cert_storage_path=str((output_dir / "certs").resolve()),
|
126
|
+
key_storage_path=str((output_dir / "keys").resolve()),
|
87
127
|
default_validity_days=365,
|
88
128
|
key_size=2048,
|
89
|
-
hash_algorithm="sha256"
|
129
|
+
hash_algorithm="sha256",
|
90
130
|
)
|
91
131
|
cert_manager = CertificateManager(cert_config)
|
92
132
|
# Generate CA certificate
|
@@ -97,13 +137,15 @@ def generate_certificates_with_framework():
|
|
97
137
|
country="US",
|
98
138
|
state="Test State",
|
99
139
|
locality="Test City",
|
100
|
-
validity_years=10, #
|
140
|
+
validity_years=10, # Use validity_years instead of validity_days
|
101
141
|
key_size=2048,
|
102
|
-
hash_algorithm="sha256"
|
142
|
+
hash_algorithm="sha256",
|
103
143
|
)
|
104
144
|
cert_pair = cert_manager.create_root_ca(ca_config)
|
105
145
|
if not cert_pair or not cert_pair.certificate_path:
|
106
|
-
print(
|
146
|
+
print(
|
147
|
+
"❌ Failed to create CA certificate: Invalid certificate pair"
|
148
|
+
)
|
107
149
|
return False
|
108
150
|
print("✅ CA certificate created successfully")
|
109
151
|
# Find CA key file
|
@@ -119,22 +161,57 @@ def generate_certificates_with_framework():
|
|
119
161
|
validity_days=365,
|
120
162
|
key_size=2048,
|
121
163
|
hash_algorithm="sha256",
|
122
|
-
subject_alt_names=[
|
164
|
+
subject_alt_names=[
|
165
|
+
"localhost",
|
166
|
+
"127.0.0.1",
|
167
|
+
],
|
123
168
|
ca_cert_path=cert_pair.certificate_path,
|
124
|
-
ca_key_path=ca_key_path
|
169
|
+
ca_key_path=ca_key_path,
|
125
170
|
)
|
126
171
|
cert_pair = cert_manager.create_server_certificate(server_config)
|
127
172
|
if not cert_pair or not cert_pair.certificate_path:
|
128
|
-
print(
|
173
|
+
print(
|
174
|
+
"❌ Failed to create server certificate: Invalid certificate "
|
175
|
+
"pair"
|
176
|
+
)
|
129
177
|
return False
|
130
178
|
print("✅ Server certificate created successfully")
|
131
179
|
# Generate client certificates
|
132
180
|
client_configs = [
|
133
|
-
(
|
134
|
-
|
181
|
+
(
|
182
|
+
"admin",
|
183
|
+
["admin"],
|
184
|
+
[
|
185
|
+
"read",
|
186
|
+
"write",
|
187
|
+
"execute",
|
188
|
+
"delete",
|
189
|
+
"admin",
|
190
|
+
"register",
|
191
|
+
"unregister",
|
192
|
+
"heartbeat",
|
193
|
+
"discover",
|
194
|
+
],
|
195
|
+
),
|
196
|
+
(
|
197
|
+
"user",
|
198
|
+
["user"],
|
199
|
+
[
|
200
|
+
"read",
|
201
|
+
"execute",
|
202
|
+
"register",
|
203
|
+
"unregister",
|
204
|
+
"heartbeat",
|
205
|
+
"discover",
|
206
|
+
],
|
207
|
+
),
|
135
208
|
("readonly", ["readonly"], ["read", "discover"]),
|
136
209
|
("guest", ["guest"], ["read", "discover"]),
|
137
|
-
(
|
210
|
+
(
|
211
|
+
"proxy",
|
212
|
+
["proxy"],
|
213
|
+
["register", "unregister", "heartbeat", "discover"],
|
214
|
+
),
|
138
215
|
]
|
139
216
|
for client_name, roles, permissions in client_configs:
|
140
217
|
client_config = ClientCertConfig(
|
@@ -154,26 +231,86 @@ def generate_certificates_with_framework():
|
|
154
231
|
)
|
155
232
|
cert_pair = cert_manager.create_client_certificate(client_config)
|
156
233
|
if not cert_pair or not cert_pair.certificate_path:
|
157
|
-
print(
|
234
|
+
print(
|
235
|
+
(
|
236
|
+
"❌ Failed to create client certificate {}: "
|
237
|
+
"Invalid certificate pair"
|
238
|
+
).format(client_name)
|
239
|
+
)
|
158
240
|
return False
|
159
|
-
print(
|
160
|
-
|
241
|
+
print(
|
242
|
+
"✅ Client certificate {} created successfully".format(
|
243
|
+
client_name
|
244
|
+
)
|
245
|
+
)
|
246
|
+
print(
|
247
|
+
"🎉 All certificates generated successfully using "
|
248
|
+
"mcp_security_framework!"
|
249
|
+
)
|
161
250
|
return True
|
162
251
|
except Exception as e:
|
163
|
-
print(
|
252
|
+
print("❌ Error generating certificates with framework: {}".format(e))
|
253
|
+
print("\n🔧 TROUBLESHOOTING:")
|
254
|
+
print("1. Check if mcp_security_framework is installed:")
|
255
|
+
print(" pip install mcp_security_framework")
|
256
|
+
print("\n2. Verify write permissions in output directory")
|
257
|
+
print("\n3. Check if certs/ and keys/ directories exist")
|
164
258
|
return False
|
165
|
-
|
259
|
+
|
260
|
+
|
261
|
+
def main() -> int:
|
166
262
|
"""Main function for command line execution."""
|
263
|
+
parser = argparse.ArgumentParser(
|
264
|
+
description="Setup test environment for MCP Proxy Adapter"
|
265
|
+
)
|
266
|
+
parser.add_argument(
|
267
|
+
"--output-dir",
|
268
|
+
"-o",
|
269
|
+
type=str,
|
270
|
+
default=".",
|
271
|
+
help=(
|
272
|
+
"Target directory to create the test environment "
|
273
|
+
"(default: current directory)"
|
274
|
+
),
|
275
|
+
)
|
276
|
+
args = parser.parse_args()
|
167
277
|
try:
|
168
|
-
|
278
|
+
target_root = Path(args.output_dir)
|
279
|
+
setup_test_environment(target_root)
|
169
280
|
# Generate certificates if framework is available
|
170
281
|
if SECURITY_FRAMEWORK_AVAILABLE:
|
171
|
-
generate_certificates_with_framework()
|
282
|
+
generate_certificates_with_framework(target_root)
|
172
283
|
else:
|
173
|
-
print(
|
284
|
+
print(
|
285
|
+
"⚠️ Skipping certificate generation (mcp_security_framework "
|
286
|
+
"not available)"
|
287
|
+
)
|
174
288
|
except Exception as e:
|
175
|
-
print(
|
289
|
+
print(
|
290
|
+
"❌ Error setting up test environment: {}".format(e),
|
291
|
+
file=sys.stderr,
|
292
|
+
)
|
293
|
+
print("\n🔧 TROUBLESHOOTING:")
|
294
|
+
print("1. Check if output directory is writable")
|
295
|
+
print("2. Verify mcp_security_framework installation")
|
296
|
+
print("3. Check available disk space")
|
176
297
|
return 1
|
298
|
+
|
299
|
+
print("\n" + "=" * 60)
|
300
|
+
print("✅ TEST ENVIRONMENT SETUP COMPLETED SUCCESSFULLY")
|
301
|
+
print("=" * 60)
|
302
|
+
print("\n📋 NEXT STEPS:")
|
303
|
+
print("1. Generate test configurations:")
|
304
|
+
print(" python -m mcp_proxy_adapter.examples.generate_test_configs --output-dir configs")
|
305
|
+
print("\n2. Generate additional certificates (if needed):")
|
306
|
+
print(" python -m mcp_proxy_adapter.examples.generate_certificates")
|
307
|
+
print("\n3. Run security tests:")
|
308
|
+
print(" python -m mcp_proxy_adapter.examples.run_security_tests")
|
309
|
+
print("\n4. Start basic framework example:")
|
310
|
+
print(" python -m mcp_proxy_adapter.examples.basic_framework.main --config configs/https_simple.json")
|
311
|
+
print("=" * 60)
|
177
312
|
return 0
|
313
|
+
|
314
|
+
|
178
315
|
if __name__ == "__main__":
|
179
316
|
exit(main())
|
mcp_proxy_adapter/version.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-proxy-adapter
|
3
|
-
Version: 6.2.
|
3
|
+
Version: 6.2.8
|
4
4
|
Summary: Powerful JSON-RPC microservices framework with built-in security, authentication, and proxy registration
|
5
5
|
Home-page: https://github.com/maverikod/mcp-proxy-adapter
|
6
6
|
Author: Vasiliy Zdanovskiy
|
@@ -650,7 +650,7 @@ MIT License - see [LICENSE](https://github.com/maverikod/mcp-proxy-adapter/blob/
|
|
650
650
|
|
651
651
|
## 📊 Version
|
652
652
|
|
653
|
-
**6.2.
|
653
|
+
**6.2.8** - Production-ready release with comprehensive security, proxy registration, and PyPI optimization.
|
654
654
|
|
655
655
|
---
|
656
656
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
mcp_proxy_adapter/__init__.py,sha256=B7m1YWyv_Wb87-Q-JqVpHQgwajnfIgDyZ_iIxzdTbBY,1021
|
2
|
-
mcp_proxy_adapter/__main__.py,sha256=
|
2
|
+
mcp_proxy_adapter/__main__.py,sha256=Bt1ONguFhFkHo2lrbfpBqLt_2896rkw165HQtDDT7Ys,768
|
3
3
|
mcp_proxy_adapter/config.py,sha256=z4rUbJdxYj6vYw05OM_kMXs1Qn2HRQXGHI9PB4hgPd4,12867
|
4
4
|
mcp_proxy_adapter/custom_openapi.py,sha256=jYUrCy8C1mShh3sjKj-JkzSMLAvxDLTvtzSJFj5HUNg,15023
|
5
5
|
mcp_proxy_adapter/main.py,sha256=_DJwMZdN0393UR-U7xfQh59EpbDDgv1oWPFf-v2MoII,2147
|
6
6
|
mcp_proxy_adapter/openapi.py,sha256=36vOEbJjGnVZR6hUhl6mHCD29HYOEFKo2bL0JdGSm-4,13952
|
7
|
-
mcp_proxy_adapter/version.py,sha256=
|
7
|
+
mcp_proxy_adapter/version.py,sha256=wehJCAiczZs9JWXECcyMYJw_dsc9e9JXRgLJ4u7wfYo,75
|
8
8
|
mcp_proxy_adapter/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
mcp_proxy_adapter/api/app.py,sha256=pYrsDWhZAYoYbxujD0MGeOWdTnBUGueIGmZqeAbaB9A,27884
|
10
10
|
mcp_proxy_adapter/api/handlers.py,sha256=DcZT7MVBV33q-0EJ0iFqxE0VgBkFt6d_SqoRkntwyvc,8477
|
@@ -80,21 +80,21 @@ mcp_proxy_adapter/core/ssl_utils.py,sha256=_2mhpuoiRpSbUBifnQvtuziQfBRrXQUKtB58A
|
|
80
80
|
mcp_proxy_adapter/core/transport_manager.py,sha256=ppcgjO-7Ulrk1ovlzlXVM89Iw4VOGA3awKgLf7FFAJ0,9518
|
81
81
|
mcp_proxy_adapter/core/unified_config_adapter.py,sha256=cpN_VrliIFGDH3JsfRkTlFdQvLcmuMYYedq0QEzlb0Y,22857
|
82
82
|
mcp_proxy_adapter/core/utils.py,sha256=ly8Ttg2v1OBukThJLxudRvmttU1hxJFLJUfat4b2dOI,3268
|
83
|
-
mcp_proxy_adapter/examples/__init__.py,sha256=
|
83
|
+
mcp_proxy_adapter/examples/__init__.py,sha256=XW59G9uq5eddAfxSzXOnusji40gfaZ9EYIPCVd2lCDc,449
|
84
84
|
mcp_proxy_adapter/examples/create_certificates_simple.py,sha256=2KS-s3amvAqasvdh-cxY7ARuFAHVjtbtr_EJF2SKVQ0,23221
|
85
85
|
mcp_proxy_adapter/examples/debug_request_state.py,sha256=x_H3NIlkmIS6lZimvEM6kCXxGdpgFw99Sdui8qa_qeU,4347
|
86
86
|
mcp_proxy_adapter/examples/debug_role_chain.py,sha256=33l2Tk5mrcnwPFwqm2NTHcrWaJrXUU2wxW2I6Y4uIg4,8344
|
87
87
|
mcp_proxy_adapter/examples/demo_client.py,sha256=inic-FP5qG8oQXUaCrtEhmhac_PDZ1pcxp-M1cxSzwA,10240
|
88
88
|
mcp_proxy_adapter/examples/generate_all_certificates.py,sha256=rgcwqIkQ1eDfEIRFRXGIOz-jOSS1w0GPBRhYvMl6Vjc,16948
|
89
|
-
mcp_proxy_adapter/examples/generate_certificates.py,sha256=
|
89
|
+
mcp_proxy_adapter/examples/generate_certificates.py,sha256=A34OHUEiFvINOHrm3_JiDSbp-WG-eQXIvKCsE8JAeXQ,6616
|
90
90
|
mcp_proxy_adapter/examples/generate_certificates_and_tokens.py,sha256=J0qHm_BMY8RYqfuwf7V7xKsHcsRJx8E7x-8JxmW5sPw,15988
|
91
|
-
mcp_proxy_adapter/examples/generate_test_configs.py,sha256=
|
91
|
+
mcp_proxy_adapter/examples/generate_test_configs.py,sha256=AJqsB7sP-tYuOD49MiWBo-CkpdRd92XYQ8m31rPFiFg,8495
|
92
92
|
mcp_proxy_adapter/examples/proxy_registration_example.py,sha256=g59_QG2D1CCqhIXEvgy2XmgXI3toLmLyH7hL3uHZwC8,12647
|
93
93
|
mcp_proxy_adapter/examples/run_example.py,sha256=o8rcy9Xo0UuZG4MpKdex3pFWYdtAi6uW8dEBQE6Yzbw,2539
|
94
|
-
mcp_proxy_adapter/examples/run_security_tests.py,sha256=
|
94
|
+
mcp_proxy_adapter/examples/run_security_tests.py,sha256=s8hOcq-dqhzVU3ikuefLEK2IkmE7WNlKGSjj0lEVHHk,12287
|
95
95
|
mcp_proxy_adapter/examples/run_security_tests_fixed.py,sha256=fNQsbALf9548xJ0OGPKYx5Crzg1GbcL8CSh1x_oKu_A,10540
|
96
96
|
mcp_proxy_adapter/examples/security_test_client.py,sha256=eBy6pZ5Dhdo-qi_7Fk-IWGHq7zAJA-om8RBuOep4XSs,28022
|
97
|
-
mcp_proxy_adapter/examples/setup_test_environment.py,sha256=
|
97
|
+
mcp_proxy_adapter/examples/setup_test_environment.py,sha256=Y6oNaR95Rmn2csupYoGV-_mMF6AtqJ31vwLhY0TQtMk,11319
|
98
98
|
mcp_proxy_adapter/examples/test_config.py,sha256=1X9X8lNlWOcM1ZbIzteeMvLdgxnJEK_ev1BYTZiA9ws,6451
|
99
99
|
mcp_proxy_adapter/examples/test_config_generator.py,sha256=SBKL0bv-kUwUUbwrFVbxuA_6pDvK2573Jxm9wPiyI8s,3927
|
100
100
|
mcp_proxy_adapter/examples/test_examples.py,sha256=KH095FFEQDMKYZglclr5qy3cW__t3H8VX1l8dvCkQos,12132
|
@@ -104,8 +104,8 @@ mcp_proxy_adapter/examples/basic_framework/main.py,sha256=cDmqeUN1lDBBwuwLjmnP3q
|
|
104
104
|
mcp_proxy_adapter/examples/basic_framework/commands/__init__.py,sha256=_VQNLUEdsxUG-4yt9BZI_vtOxHAdGG0OUSsP6Wj-Vz4,76
|
105
105
|
mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py,sha256=IE_EIXMnkdXuakZn7wLD9kBFyfDF5lYi56ejgiBeb-A,70
|
106
106
|
mcp_proxy_adapter/examples/commands/__init__.py,sha256=46FZSOABSeKPffw91JqIWL_UQD_RLL3nAR-ufgb2hr8,169
|
107
|
-
mcp_proxy_adapter/examples/full_application/__init__.py,sha256=
|
108
|
-
mcp_proxy_adapter/examples/full_application/main.py,sha256=
|
107
|
+
mcp_proxy_adapter/examples/full_application/__init__.py,sha256=AEqN_gEBzj-swBtTOvRUWqKSdXqJVk1aUtfPghVL-2o,319
|
108
|
+
mcp_proxy_adapter/examples/full_application/main.py,sha256=h2d90G6XMJFbJpo2ht7M1IqITZ9nZPi9QtH6ETeE9DI,7791
|
109
109
|
mcp_proxy_adapter/examples/full_application/proxy_endpoints.py,sha256=-cpb0nIjzp6OltFHoZqrtFvb4wJf1dgT4WvQ2dcY6Bo,6045
|
110
110
|
mcp_proxy_adapter/examples/full_application/commands/__init__.py,sha256=yQHxVSFkAyFLUOdk42QOebUODPlQV9IbydPgF3UKsGM,217
|
111
111
|
mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py,sha256=u9_XOkoHkiFC-tn9B-yGUXfQi9OL0EDxlVVKSERI1wA,3099
|
@@ -113,8 +113,8 @@ mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.
|
|
113
113
|
mcp_proxy_adapter/examples/full_application/hooks/__init__.py,sha256=ORG4cL8cSXEMmZ0CEPz75OVuwg54pdDm2GIBpP4dtcs,200
|
114
114
|
mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py,sha256=TYXuHI-KW_mH5r8mSKgNMJCr3moeEKrqC4Eex0U298k,3457
|
115
115
|
mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py,sha256=IaskSrckZS6bE3aGxSBL8aTj-iJTSI2ysfsFjhjncyM,2975
|
116
|
-
mcp_proxy_adapter-6.2.
|
117
|
-
mcp_proxy_adapter-6.2.
|
118
|
-
mcp_proxy_adapter-6.2.
|
119
|
-
mcp_proxy_adapter-6.2.
|
120
|
-
mcp_proxy_adapter-6.2.
|
116
|
+
mcp_proxy_adapter-6.2.8.dist-info/licenses/LICENSE,sha256=6KdtUcTwmTRbJrAmYjVn7e6S-V42ubeDJ-AiVEzZ510,1075
|
117
|
+
mcp_proxy_adapter-6.2.8.dist-info/METADATA,sha256=lsVvTJKSGfA8Ncg7FUK9rVpeUKIdUvkJMxzHZt0DGEI,22198
|
118
|
+
mcp_proxy_adapter-6.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
119
|
+
mcp_proxy_adapter-6.2.8.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
|
120
|
+
mcp_proxy_adapter-6.2.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|