mcp-proxy-adapter 6.2.5__py3-none-any.whl → 6.2.7__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/basic_framework/__init__.py +4 -2
- mcp_proxy_adapter/examples/generate_certificates.py +153 -82
- mcp_proxy_adapter/examples/generate_test_configs.py +19 -1
- mcp_proxy_adapter/examples/run_security_tests.py +28 -4
- mcp_proxy_adapter/examples/setup_test_environment.py +199 -62
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.2.5.dist-info → mcp_proxy_adapter-6.2.7.dist-info}/METADATA +3 -3
- {mcp_proxy_adapter-6.2.5.dist-info → mcp_proxy_adapter-6.2.7.dist-info}/RECORD +13 -13
- {mcp_proxy_adapter-6.2.5.dist-info → mcp_proxy_adapter-6.2.7.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.2.5.dist-info → mcp_proxy_adapter-6.2.7.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.2.5.dist-info → mcp_proxy_adapter-6.2.7.dist-info}/top_level.txt +0 -0
mcp_proxy_adapter/__main__.py
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This example demonstrates the fundamental usage of MCP Proxy Adapter
|
4
4
|
with minimal configuration and basic command registration.
|
5
|
-
"""
|
6
5
|
|
7
|
-
|
6
|
+
Note: This package provides a basic example of MCP Proxy Adapter usage.
|
7
|
+
The main application is created dynamically in main.py and not exported
|
8
|
+
as a global variable for this example.
|
9
|
+
"""
|
@@ -2,105 +2,176 @@
|
|
2
2
|
"""
|
3
3
|
Certificate Generation Script
|
4
4
|
This script generates all necessary certificates for the examples using
|
5
|
-
mcp_security_framework
|
5
|
+
mcp_security_framework API directly.
|
6
6
|
Author: Vasiliy Zdanovskiy
|
7
7
|
email: vasilyvz@gmail.com
|
8
8
|
"""
|
9
9
|
import os
|
10
|
-
import subprocess
|
11
10
|
import sys
|
12
11
|
from pathlib import Path
|
13
|
-
|
14
|
-
|
15
|
-
print(f"🔧 {description}...")
|
16
|
-
try:
|
17
|
-
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
|
18
|
-
print(f"✅ {description} completed successfully")
|
19
|
-
return True
|
20
|
-
except subprocess.CalledProcessError as e:
|
21
|
-
print(f"❌ {description} failed: {e}")
|
22
|
-
print(f"Error output: {e.stderr}")
|
23
|
-
return False
|
12
|
+
from datetime import datetime, timedelta, timezone
|
13
|
+
|
24
14
|
def main():
|
25
15
|
"""Generate all certificates for examples."""
|
26
16
|
print("🔐 Certificate Generation Script")
|
27
17
|
print("=" * 50)
|
18
|
+
|
28
19
|
# Create directories
|
29
20
|
cert_dir = Path("certs")
|
21
|
+
key_dir = Path("keys")
|
30
22
|
cert_dir.mkdir(exist_ok=True)
|
23
|
+
key_dir.mkdir(exist_ok=True)
|
24
|
+
|
31
25
|
# Check if mcp_security_framework is available
|
32
26
|
try:
|
33
|
-
import
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
"python -m mcp_security_framework.cli.cert_cli create-ca "
|
41
|
-
"--common-name 'MCP Proxy Adapter CA' "
|
42
|
-
"--organization 'MCP Proxy Adapter' "
|
43
|
-
"--country 'US' "
|
44
|
-
"--state 'State' "
|
45
|
-
"--locality 'City' "
|
46
|
-
"--validity-years 10 "
|
47
|
-
"--key-size 2048",
|
48
|
-
"Creating root CA certificate"
|
49
|
-
):
|
50
|
-
return False
|
51
|
-
# Generate server certificate
|
52
|
-
if not run_command(
|
53
|
-
"python -m mcp_security_framework.cli.cert_cli -c cert_config.json create-server "
|
54
|
-
"--common-name 'localhost' "
|
55
|
-
"--organization 'MCP Proxy Adapter' "
|
56
|
-
"--country 'US' "
|
57
|
-
"--validity-days 365 "
|
58
|
-
"--key-size 2048",
|
59
|
-
"Creating server certificate"
|
60
|
-
):
|
27
|
+
from mcp_security_framework.core.cert_manager import CertificateManager
|
28
|
+
from mcp_security_framework.schemas import (
|
29
|
+
CAConfig, ServerCertConfig, ClientCertConfig, CertificateConfig
|
30
|
+
)
|
31
|
+
print("✅ mcp_security_framework API available")
|
32
|
+
except ImportError as e:
|
33
|
+
print(f"❌ mcp_security_framework not found: {e}")
|
61
34
|
return False
|
62
|
-
|
63
|
-
|
64
|
-
"
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
"
|
97
|
-
|
98
|
-
"Creating
|
99
|
-
|
35
|
+
|
36
|
+
try:
|
37
|
+
print("🔧 Creating root CA certificate...")
|
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
|
50
|
+
ca_config = CAConfig(
|
51
|
+
common_name="MCP Proxy Adapter CA",
|
52
|
+
organization="MCP Proxy Adapter",
|
53
|
+
organizational_unit="Development",
|
54
|
+
country="US",
|
55
|
+
state="State",
|
56
|
+
locality="City",
|
57
|
+
validity_years=10,
|
58
|
+
key_size=2048,
|
59
|
+
hash_algorithm="sha256"
|
60
|
+
)
|
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")
|
65
|
+
return False
|
66
|
+
|
67
|
+
ca_cert_path = ca_cert_pair.certificate_path
|
68
|
+
ca_key_path = ca_cert_pair.private_key_path
|
69
|
+
print(f"✅ Root CA certificate created: {ca_cert_path}")
|
70
|
+
|
71
|
+
print("🔧 Creating server certificate...")
|
72
|
+
# Create server certificate
|
73
|
+
server_config = ServerCertConfig(
|
74
|
+
common_name="localhost",
|
75
|
+
organization="MCP Proxy Adapter",
|
76
|
+
country="US",
|
77
|
+
validity_days=365,
|
78
|
+
key_size=2048,
|
79
|
+
subject_alt_names=["localhost", "127.0.0.1"],
|
80
|
+
ca_cert_path=str(ca_cert_path),
|
81
|
+
ca_key_path=str(ca_key_path)
|
82
|
+
)
|
83
|
+
|
84
|
+
server_cert_pair = cert_manager.create_server_certificate(server_config)
|
85
|
+
print(f"✅ Server certificate created: {server_cert_pair.certificate_path}")
|
86
|
+
|
87
|
+
print("🔧 Creating admin client certificate...")
|
88
|
+
# Create admin client certificate
|
89
|
+
admin_config = ClientCertConfig(
|
90
|
+
common_name="admin",
|
91
|
+
organization="MCP Proxy Adapter",
|
92
|
+
country="US",
|
93
|
+
validity_days=365,
|
94
|
+
key_size=2048,
|
95
|
+
roles=["admin"],
|
96
|
+
permissions=["read", "write", "delete"],
|
97
|
+
ca_cert_path=str(ca_cert_path),
|
98
|
+
ca_key_path=str(ca_key_path)
|
99
|
+
)
|
100
|
+
|
101
|
+
admin_cert_pair = cert_manager.create_client_certificate(admin_config)
|
102
|
+
print(f"✅ Admin client certificate created: {admin_cert_pair.certificate_path}")
|
103
|
+
|
104
|
+
print("🔧 Creating user client certificate...")
|
105
|
+
# Create user client certificate
|
106
|
+
user_config = ClientCertConfig(
|
107
|
+
common_name="user",
|
108
|
+
organization="MCP Proxy Adapter",
|
109
|
+
country="US",
|
110
|
+
validity_days=365,
|
111
|
+
key_size=2048,
|
112
|
+
roles=["user"],
|
113
|
+
permissions=["read", "write"],
|
114
|
+
ca_cert_path=str(ca_cert_path),
|
115
|
+
ca_key_path=str(ca_key_path)
|
116
|
+
)
|
117
|
+
|
118
|
+
user_cert_pair = cert_manager.create_client_certificate(user_config)
|
119
|
+
print(f"✅ User client certificate created: {user_cert_pair.certificate_path}")
|
120
|
+
|
121
|
+
print("🔧 Creating readonly client certificate...")
|
122
|
+
# Create readonly client certificate
|
123
|
+
readonly_config = ClientCertConfig(
|
124
|
+
common_name="readonly",
|
125
|
+
organization="MCP Proxy Adapter",
|
126
|
+
country="US",
|
127
|
+
validity_days=365,
|
128
|
+
key_size=2048,
|
129
|
+
roles=["readonly"],
|
130
|
+
permissions=["read"],
|
131
|
+
ca_cert_path=str(ca_cert_path),
|
132
|
+
ca_key_path=str(ca_key_path)
|
133
|
+
)
|
134
|
+
|
135
|
+
readonly_cert_pair = cert_manager.create_client_certificate(readonly_config)
|
136
|
+
print(f"✅ Readonly client certificate created: {readonly_cert_pair.certificate_path}")
|
137
|
+
|
138
|
+
print("\n🎉 All certificates generated successfully!")
|
139
|
+
print(f"📁 Certificates are stored in the '{cert_dir}' directory")
|
140
|
+
print(f"🔑 Private keys are stored in the '{key_dir}' directory")
|
141
|
+
print(f"🔐 CA certificate: {ca_cert_path}")
|
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)
|
155
|
+
return True
|
156
|
+
|
157
|
+
except Exception as e:
|
158
|
+
print(f"\n❌ CERTIFICATE GENERATION FAILED: {e}")
|
159
|
+
print("=" * 60)
|
160
|
+
import traceback
|
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)
|
100
168
|
return False
|
101
|
-
|
102
|
-
print("📁 Certificates are stored in the 'certs' directory")
|
103
|
-
return True
|
169
|
+
|
104
170
|
if __name__ == "__main__":
|
171
|
+
print("🔐 Starting certificate generation...")
|
105
172
|
success = main()
|
173
|
+
if success:
|
174
|
+
print("\n✅ Script completed successfully!")
|
175
|
+
else:
|
176
|
+
print("\n❌ Script failed with errors!")
|
106
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__":
|
@@ -19,10 +19,8 @@ import sys
|
|
19
19
|
import time
|
20
20
|
from pathlib import Path
|
21
21
|
from typing import Dict, List, Optional, Any
|
22
|
-
#
|
23
|
-
|
24
|
-
sys.path.insert(0, str(project_root))
|
25
|
-
from security_test_client import SecurityTestClient, TestResult
|
22
|
+
# Import security test client with proper module path
|
23
|
+
from mcp_proxy_adapter.examples.security_test_client import SecurityTestClient, TestResult
|
26
24
|
class SecurityTestRunner:
|
27
25
|
"""Main test runner for security testing."""
|
28
26
|
def __init__(self):
|
@@ -207,10 +205,36 @@ class SecurityTestRunner:
|
|
207
205
|
# Overall status
|
208
206
|
if total_passed == total_tests and total_tests > 0:
|
209
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)
|
210
219
|
elif total_passed > 0:
|
211
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)
|
212
228
|
else:
|
213
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)
|
214
238
|
def cleanup(self):
|
215
239
|
"""Cleanup all running servers."""
|
216
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.7
|
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
|
@@ -34,7 +34,7 @@ Requires-Dist: docstring-parser<1.0.0,>=0.15
|
|
34
34
|
Requires-Dist: typing-extensions<5.0.0,>=4.5.0
|
35
35
|
Requires-Dist: jsonrpc>=1.2.0
|
36
36
|
Requires-Dist: psutil>=5.9.0
|
37
|
-
Requires-Dist: mcp_security_framework>=1.1.
|
37
|
+
Requires-Dist: mcp_security_framework>=1.1.2
|
38
38
|
Requires-Dist: packaging>=20.0
|
39
39
|
Requires-Dist: aiohttp<4.0.0,>=3.8.0
|
40
40
|
Requires-Dist: requests<3.0.0,>=2.28.0
|
@@ -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.7** - 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=CeNc01hXwosGurxshp_WNFDZxFif828qJgI0TZGQ-pM,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=flte9zg9fbWIFffeX5r6wgvBlCScZw8l_4KySxkON6U,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,26 +80,26 @@ 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=5YV71gn4exEXLcxCTWmCuxKchJjcof9idtLZdb02orU,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=ERbq9KHhE3MEm2EbbE4eHh649SDRdj0tQahfi0vKJlk,12343
|
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
|
101
101
|
mcp_proxy_adapter/examples/universal_client.py,sha256=IIKGRa0__KoWVla3VnVl-RjkkG_nPpM8vglPm70pV9c,26948
|
102
|
-
mcp_proxy_adapter/examples/basic_framework/__init__.py,sha256=
|
102
|
+
mcp_proxy_adapter/examples/basic_framework/__init__.py,sha256=4aYD--R6hy9n9CUxj7Osb9HcdVUMJ6_cfpu4ujkbCwI,345
|
103
103
|
mcp_proxy_adapter/examples/basic_framework/main.py,sha256=cDmqeUN1lDBBwuwLjmnP3qIyofCZ3Jr5Ct7Im-qCsUU,1728
|
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
|
@@ -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.7.dist-info/licenses/LICENSE,sha256=6KdtUcTwmTRbJrAmYjVn7e6S-V42ubeDJ-AiVEzZ510,1075
|
117
|
+
mcp_proxy_adapter-6.2.7.dist-info/METADATA,sha256=sQ_fhxY9ISs0zMZMHb7ghvbw_i4iTENFef1QvrWsUKI,22198
|
118
|
+
mcp_proxy_adapter-6.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
119
|
+
mcp_proxy_adapter-6.2.7.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
|
120
|
+
mcp_proxy_adapter-6.2.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|