mcp-proxy-adapter 6.1.1__py3-none-any.whl → 6.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_proxy_adapter/__main__.py +27 -7
- mcp_proxy_adapter/api/app.py +18 -7
- mcp_proxy_adapter/commands/ssl_setup_command.py +234 -351
- mcp_proxy_adapter/core/app_factory.py +87 -3
- mcp_proxy_adapter/core/app_runner.py +272 -0
- mcp_proxy_adapter/core/certificate_utils.py +291 -73
- mcp_proxy_adapter/core/client.py +574 -0
- mcp_proxy_adapter/core/client_manager.py +284 -0
- mcp_proxy_adapter/core/server_adapter.py +17 -80
- mcp_proxy_adapter/core/server_engine.py +5 -99
- mcp_proxy_adapter/core/ssl_utils.py +13 -12
- mcp_proxy_adapter/core/transport_manager.py +5 -5
- mcp_proxy_adapter/examples/__init__.py +16 -0
- mcp_proxy_adapter/examples/basic_framework/__init__.py +7 -0
- mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +21 -40
- mcp_proxy_adapter/examples/commands/__init__.py +5 -1
- mcp_proxy_adapter/examples/create_certificates_simple.py +260 -75
- mcp_proxy_adapter/examples/debug_request_state.py +4 -36
- mcp_proxy_adapter/examples/debug_role_chain.py +2 -49
- mcp_proxy_adapter/examples/demo_client.py +0 -66
- mcp_proxy_adapter/examples/full_application/__init__.py +11 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +0 -19
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +0 -16
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +7 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +0 -22
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +0 -24
- mcp_proxy_adapter/examples/full_application/main.py +65 -44
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +154 -0
- mcp_proxy_adapter/examples/generate_all_certificates.py +0 -67
- mcp_proxy_adapter/examples/generate_certificates.py +0 -15
- mcp_proxy_adapter/examples/generate_certificates_and_tokens.py +369 -0
- mcp_proxy_adapter/examples/generate_test_configs.py +204 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +3 -70
- mcp_proxy_adapter/examples/run_example.py +1 -23
- mcp_proxy_adapter/examples/run_security_tests.py +2 -60
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +0 -53
- mcp_proxy_adapter/examples/security_test_client.py +18 -123
- mcp_proxy_adapter/examples/setup_test_environment.py +179 -0
- mcp_proxy_adapter/examples/test_config.py +148 -0
- mcp_proxy_adapter/examples/test_config_generator.py +1 -25
- mcp_proxy_adapter/examples/test_examples.py +4 -67
- mcp_proxy_adapter/examples/universal_client.py +154 -162
- mcp_proxy_adapter/main.py +51 -161
- mcp_proxy_adapter/version.py +1 -1
- mcp_proxy_adapter-6.2.0.dist-info/METADATA +687 -0
- mcp_proxy_adapter-6.2.0.dist-info/RECORD +122 -0
- mcp_proxy_adapter/docs/EN/TROUBLESHOOTING.md +0 -285
- mcp_proxy_adapter/docs/RU/TROUBLESHOOTING.md +0 -285
- mcp_proxy_adapter/examples/README.md +0 -257
- mcp_proxy_adapter/examples/README_EN.md +0 -258
- mcp_proxy_adapter/examples/SECURITY_TESTING.md +0 -455
- mcp_proxy_adapter/examples/basic_framework/configs/http_auth.json +0 -37
- mcp_proxy_adapter/examples/basic_framework/configs/http_simple.json +0 -23
- mcp_proxy_adapter/examples/basic_framework/configs/https_auth.json +0 -43
- mcp_proxy_adapter/examples/basic_framework/configs/https_no_protocol_middleware.json +0 -36
- mcp_proxy_adapter/examples/basic_framework/configs/https_simple.json +0 -29
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_protocol_middleware.json +0 -34
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_roles.json +0 -39
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_simple.json +0 -35
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_with_roles.json +0 -45
- mcp_proxy_adapter/examples/basic_framework/roles.json +0 -21
- mcp_proxy_adapter/examples/cert_config.json +0 -9
- mcp_proxy_adapter/examples/certs/admin.crt +0 -32
- mcp_proxy_adapter/examples/certs/admin.key +0 -52
- mcp_proxy_adapter/examples/certs/admin_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/admin_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/ca_cert.pem +0 -23
- mcp_proxy_adapter/examples/certs/ca_cert.srl +0 -1
- mcp_proxy_adapter/examples/certs/ca_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/cert_config.json +0 -9
- mcp_proxy_adapter/examples/certs/client.crt +0 -32
- mcp_proxy_adapter/examples/certs/client.key +0 -52
- mcp_proxy_adapter/examples/certs/client_admin.crt +0 -32
- mcp_proxy_adapter/examples/certs/client_admin.key +0 -52
- mcp_proxy_adapter/examples/certs/client_user.crt +0 -32
- mcp_proxy_adapter/examples/certs/client_user.key +0 -52
- mcp_proxy_adapter/examples/certs/guest_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/guest_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/mcp_proxy_adapter_ca_ca.crt +0 -23
- mcp_proxy_adapter/examples/certs/proxy_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/proxy_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/readonly.crt +0 -32
- mcp_proxy_adapter/examples/certs/readonly.key +0 -52
- mcp_proxy_adapter/examples/certs/readonly_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/readonly_key.pem +0 -28
- mcp_proxy_adapter/examples/certs/server.crt +0 -32
- mcp_proxy_adapter/examples/certs/server.key +0 -52
- mcp_proxy_adapter/examples/certs/server_cert.pem +0 -32
- mcp_proxy_adapter/examples/certs/server_key.pem +0 -52
- mcp_proxy_adapter/examples/certs/test_ca_ca.crt +0 -20
- mcp_proxy_adapter/examples/certs/user.crt +0 -32
- mcp_proxy_adapter/examples/certs/user.key +0 -52
- mcp_proxy_adapter/examples/certs/user_cert.pem +0 -21
- mcp_proxy_adapter/examples/certs/user_key.pem +0 -28
- mcp_proxy_adapter/examples/client_configs/api_key_client.json +0 -13
- mcp_proxy_adapter/examples/client_configs/basic_auth_client.json +0 -13
- mcp_proxy_adapter/examples/client_configs/certificate_client.json +0 -22
- mcp_proxy_adapter/examples/client_configs/jwt_client.json +0 -15
- mcp_proxy_adapter/examples/client_configs/no_auth_client.json +0 -9
- mcp_proxy_adapter/examples/full_application/configs/http_auth.json +0 -37
- mcp_proxy_adapter/examples/full_application/configs/http_simple.json +0 -23
- mcp_proxy_adapter/examples/full_application/configs/https_auth.json +0 -39
- mcp_proxy_adapter/examples/full_application/configs/https_simple.json +0 -25
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles.json +0 -39
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles.json +0 -45
- mcp_proxy_adapter/examples/full_application/roles.json +0 -21
- mcp_proxy_adapter/examples/keys/ca_key.pem +0 -28
- mcp_proxy_adapter/examples/keys/mcp_proxy_adapter_ca_ca.key +0 -28
- mcp_proxy_adapter/examples/keys/test_ca_ca.key +0 -28
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log +0 -220
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter.log.5 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log +0 -220
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_access.log.5 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log +0 -2
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.1 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.2 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.3 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.4 +0 -1
- mcp_proxy_adapter/examples/logs/mcp_proxy_adapter_error.log.5 +0 -1
- mcp_proxy_adapter/examples/roles.json +0 -38
- mcp_proxy_adapter/examples/server_configs/config_basic_http.json +0 -204
- mcp_proxy_adapter/examples/server_configs/config_http_token.json +0 -238
- mcp_proxy_adapter/examples/server_configs/config_https.json +0 -215
- mcp_proxy_adapter/examples/server_configs/config_https_token.json +0 -231
- mcp_proxy_adapter/examples/server_configs/config_mtls.json +0 -215
- mcp_proxy_adapter/examples/server_configs/config_proxy_registration.json +0 -250
- mcp_proxy_adapter/examples/server_configs/config_simple.json +0 -46
- mcp_proxy_adapter/examples/server_configs/roles.json +0 -38
- mcp_proxy_adapter-6.1.1.dist-info/METADATA +0 -205
- mcp_proxy_adapter-6.1.1.dist-info/RECORD +0 -197
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.1.1.dist-info → mcp_proxy_adapter-6.2.0.dist-info}/top_level.txt +0 -0
@@ -1,38 +1,28 @@
|
|
1
1
|
"""
|
2
2
|
Proxy Registration Example
|
3
|
-
|
4
3
|
This example demonstrates how to use the MCP Proxy Adapter framework
|
5
4
|
for proxy registration with different authentication methods.
|
6
|
-
|
7
5
|
Author: Vasiliy Zdanovskiy
|
8
6
|
email: vasilyvz@gmail.com
|
9
7
|
"""
|
10
|
-
|
11
8
|
import asyncio
|
12
9
|
import json
|
13
10
|
import sys
|
14
11
|
import os
|
15
12
|
from pathlib import Path
|
16
13
|
from typing import Dict, Any, Optional
|
17
|
-
|
18
14
|
# Add project root to path
|
19
15
|
project_root = Path(__file__).parent.parent.parent
|
20
16
|
sys.path.insert(0, str(project_root))
|
21
|
-
|
22
17
|
import aiohttp
|
23
18
|
from aiohttp import ClientTimeout, TCPConnector
|
24
19
|
import ssl
|
25
|
-
|
26
20
|
from mcp_proxy_adapter.core.logging import logger
|
27
|
-
|
28
|
-
|
29
21
|
class ProxyRegistrationExample:
|
30
22
|
"""Example client for testing proxy registration functionality."""
|
31
|
-
|
32
23
|
def __init__(self, server_url: str, auth_token: Optional[str] = None):
|
33
24
|
"""
|
34
25
|
Initialize example client.
|
35
|
-
|
36
26
|
Args:
|
37
27
|
server_url: Server URL
|
38
28
|
auth_token: Authentication token
|
@@ -40,7 +30,6 @@ class ProxyRegistrationExample:
|
|
40
30
|
self.server_url = server_url
|
41
31
|
self.auth_token = auth_token
|
42
32
|
self.session: Optional[aiohttp.ClientSession] = None
|
43
|
-
|
44
33
|
# Test data
|
45
34
|
self.test_servers = [
|
46
35
|
{
|
@@ -59,7 +48,7 @@ class ProxyRegistrationExample:
|
|
59
48
|
"security_enabled": True
|
60
49
|
},
|
61
50
|
{
|
62
|
-
"server_id": "example-server-2",
|
51
|
+
"server_id": "example-server-2",
|
63
52
|
"server_url": "http://localhost:8002",
|
64
53
|
"server_name": "Example Server 2",
|
65
54
|
"description": "Another example server",
|
@@ -74,7 +63,6 @@ class ProxyRegistrationExample:
|
|
74
63
|
"security_enabled": True
|
75
64
|
}
|
76
65
|
]
|
77
|
-
|
78
66
|
async def __aenter__(self):
|
79
67
|
"""Async context manager entry."""
|
80
68
|
# Create SSL context for HTTPS
|
@@ -83,42 +71,32 @@ class ProxyRegistrationExample:
|
|
83
71
|
ssl_context = ssl.create_default_context()
|
84
72
|
ssl_context.check_hostname = False
|
85
73
|
ssl_context.verify_mode = ssl.CERT_NONE
|
86
|
-
|
87
74
|
# Create connector
|
88
75
|
connector = TCPConnector(ssl=ssl_context) if ssl_context else None
|
89
|
-
|
90
76
|
# Create session
|
91
77
|
timeout = ClientTimeout(total=30)
|
92
78
|
self.session = aiohttp.ClientSession(
|
93
79
|
connector=connector,
|
94
80
|
timeout=timeout
|
95
81
|
)
|
96
|
-
|
97
82
|
return self
|
98
|
-
|
99
83
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
100
84
|
"""Async context manager exit."""
|
101
85
|
if self.session:
|
102
86
|
await self.session.close()
|
103
|
-
|
104
87
|
def _get_headers(self) -> Dict[str, str]:
|
105
88
|
"""Get request headers with authentication."""
|
106
89
|
headers = {
|
107
90
|
"Content-Type": "application/json"
|
108
91
|
}
|
109
|
-
|
110
92
|
if self.auth_token:
|
111
93
|
headers["X-API-Key"] = self.auth_token
|
112
|
-
|
113
94
|
return headers
|
114
|
-
|
115
95
|
async def test_registration(self, server_data: Dict[str, Any]) -> Dict[str, Any]:
|
116
96
|
"""
|
117
97
|
Test registration with authentication.
|
118
|
-
|
119
98
|
Args:
|
120
99
|
server_data: Server registration data
|
121
|
-
|
122
100
|
Returns:
|
123
101
|
Test result
|
124
102
|
"""
|
@@ -133,10 +111,8 @@ class ProxyRegistrationExample:
|
|
133
111
|
**server_data
|
134
112
|
}
|
135
113
|
}
|
136
|
-
|
137
114
|
logger.info(f"Testing registration for server: {server_data['server_id']}")
|
138
115
|
logger.debug(f"Request data: {json.dumps(request_data, indent=2)}")
|
139
|
-
|
140
116
|
# Make request
|
141
117
|
async with self.session.post(
|
142
118
|
f"{self.server_url}/cmd",
|
@@ -144,17 +120,14 @@ class ProxyRegistrationExample:
|
|
144
120
|
headers=self._get_headers()
|
145
121
|
) as response:
|
146
122
|
result = await response.json()
|
147
|
-
|
148
123
|
logger.info(f"Response status: {response.status}")
|
149
124
|
logger.debug(f"Response: {json.dumps(result, indent=2)}")
|
150
|
-
|
151
125
|
return {
|
152
126
|
"success": response.status == 200,
|
153
127
|
"status_code": response.status,
|
154
128
|
"result": result,
|
155
129
|
"server_id": server_data["server_id"]
|
156
130
|
}
|
157
|
-
|
158
131
|
except Exception as e:
|
159
132
|
logger.error(f"Registration test failed: {e}")
|
160
133
|
return {
|
@@ -162,11 +135,9 @@ class ProxyRegistrationExample:
|
|
162
135
|
"error": str(e),
|
163
136
|
"server_id": server_data["server_id"]
|
164
137
|
}
|
165
|
-
|
166
138
|
async def test_discovery(self) -> Dict[str, Any]:
|
167
139
|
"""
|
168
140
|
Test discovery operation.
|
169
|
-
|
170
141
|
Returns:
|
171
142
|
Test result
|
172
143
|
"""
|
@@ -180,9 +151,7 @@ class ProxyRegistrationExample:
|
|
180
151
|
"operation": "discover"
|
181
152
|
}
|
182
153
|
}
|
183
|
-
|
184
154
|
logger.info("Testing discovery operation")
|
185
|
-
|
186
155
|
# Make request
|
187
156
|
async with self.session.post(
|
188
157
|
f"{self.server_url}/cmd",
|
@@ -190,30 +159,24 @@ class ProxyRegistrationExample:
|
|
190
159
|
headers=self._get_headers()
|
191
160
|
) as response:
|
192
161
|
result = await response.json()
|
193
|
-
|
194
162
|
logger.info(f"Response status: {response.status}")
|
195
163
|
logger.debug(f"Response: {json.dumps(result, indent=2)}")
|
196
|
-
|
197
164
|
return {
|
198
165
|
"success": response.status == 200,
|
199
166
|
"status_code": response.status,
|
200
167
|
"result": result
|
201
168
|
}
|
202
|
-
|
203
169
|
except Exception as e:
|
204
170
|
logger.error(f"Discovery test failed: {e}")
|
205
171
|
return {
|
206
172
|
"success": False,
|
207
173
|
"error": str(e)
|
208
174
|
}
|
209
|
-
|
210
175
|
async def test_heartbeat(self, server_key: str) -> Dict[str, Any]:
|
211
176
|
"""
|
212
177
|
Test heartbeat operation.
|
213
|
-
|
214
178
|
Args:
|
215
179
|
server_key: Server key for heartbeat
|
216
|
-
|
217
180
|
Returns:
|
218
181
|
Test result
|
219
182
|
"""
|
@@ -230,9 +193,7 @@ class ProxyRegistrationExample:
|
|
230
193
|
"status": "healthy"
|
231
194
|
}
|
232
195
|
}
|
233
|
-
|
234
196
|
logger.info(f"Testing heartbeat for server: {server_key}")
|
235
|
-
|
236
197
|
# Make request
|
237
198
|
async with self.session.post(
|
238
199
|
f"{self.server_url}/cmd",
|
@@ -240,17 +201,14 @@ class ProxyRegistrationExample:
|
|
240
201
|
headers=self._get_headers()
|
241
202
|
) as response:
|
242
203
|
result = await response.json()
|
243
|
-
|
244
204
|
logger.info(f"Response status: {response.status}")
|
245
205
|
logger.debug(f"Response: {json.dumps(result, indent=2)}")
|
246
|
-
|
247
206
|
return {
|
248
207
|
"success": response.status == 200,
|
249
208
|
"status_code": response.status,
|
250
209
|
"result": result,
|
251
210
|
"server_key": server_key
|
252
211
|
}
|
253
|
-
|
254
212
|
except Exception as e:
|
255
213
|
logger.error(f"Heartbeat test failed: {e}")
|
256
214
|
return {
|
@@ -258,12 +216,9 @@ class ProxyRegistrationExample:
|
|
258
216
|
"error": str(e),
|
259
217
|
"server_key": server_key
|
260
218
|
}
|
261
|
-
|
262
|
-
|
263
219
|
async def run_proxy_registration_example():
|
264
220
|
"""Run proxy registration example."""
|
265
221
|
logger.info("🚀 Starting proxy registration example")
|
266
|
-
|
267
222
|
# Test configurations
|
268
223
|
test_configs = [
|
269
224
|
{
|
@@ -273,7 +228,7 @@ async def run_proxy_registration_example():
|
|
273
228
|
},
|
274
229
|
{
|
275
230
|
"name": "User Token",
|
276
|
-
"server_url": "http://localhost:8002",
|
231
|
+
"server_url": "http://localhost:8002",
|
277
232
|
"auth_token": "user-token-456"
|
278
233
|
},
|
279
234
|
{
|
@@ -282,16 +237,13 @@ async def run_proxy_registration_example():
|
|
282
237
|
"auth_token": "readonly-token-123"
|
283
238
|
}
|
284
239
|
]
|
285
|
-
|
286
240
|
results = []
|
287
|
-
|
288
241
|
for config in test_configs:
|
289
242
|
logger.info(f"\n📋 Testing: {config['name']}")
|
290
243
|
logger.info(f"Server URL: {config['server_url']}")
|
291
244
|
logger.info(f"Auth Token: {config['auth_token']}")
|
292
|
-
|
293
245
|
async with ProxyRegistrationExample(
|
294
|
-
config['server_url'],
|
246
|
+
config['server_url'],
|
295
247
|
config['auth_token']
|
296
248
|
) as client:
|
297
249
|
# Test registration
|
@@ -302,7 +254,6 @@ async def run_proxy_registration_example():
|
|
302
254
|
"server_id": server_data["server_id"],
|
303
255
|
**result
|
304
256
|
})
|
305
|
-
|
306
257
|
# If registration successful, test heartbeat
|
307
258
|
if result["success"] and "result" in result:
|
308
259
|
server_key = result["result"].get("result", {}).get("server_key")
|
@@ -313,14 +264,12 @@ async def run_proxy_registration_example():
|
|
313
264
|
"server_key": server_key,
|
314
265
|
**heartbeat_result
|
315
266
|
})
|
316
|
-
|
317
267
|
# Test discovery
|
318
268
|
discovery_result = await client.test_discovery()
|
319
269
|
results.append({
|
320
270
|
"test": f"{config['name']} - Discovery",
|
321
271
|
**discovery_result
|
322
272
|
})
|
323
|
-
|
324
273
|
# Test without authentication
|
325
274
|
logger.info(f"\n📋 Testing: No Authentication")
|
326
275
|
async with ProxyRegistrationExample("http://localhost:8002") as client:
|
@@ -331,24 +280,19 @@ async def run_proxy_registration_example():
|
|
331
280
|
"server_id": server_data["server_id"],
|
332
281
|
**result
|
333
282
|
})
|
334
|
-
|
335
283
|
# Print results
|
336
284
|
logger.info("\n" + "="*80)
|
337
285
|
logger.info("📊 EXAMPLE RESULTS")
|
338
286
|
logger.info("="*80)
|
339
|
-
|
340
287
|
passed = 0
|
341
288
|
failed = 0
|
342
|
-
|
343
289
|
for result in results:
|
344
290
|
status = "✅ PASS" if result["success"] else "❌ FAIL"
|
345
291
|
logger.info(f"{status} {result['test']}")
|
346
|
-
|
347
292
|
if result["success"]:
|
348
293
|
passed += 1
|
349
294
|
else:
|
350
295
|
failed += 1
|
351
|
-
|
352
296
|
if "error" in result:
|
353
297
|
logger.error(f" Error: {result['error']}")
|
354
298
|
elif "result" in result:
|
@@ -361,41 +305,30 @@ async def run_proxy_registration_example():
|
|
361
305
|
logger.info(f" Server Key: {api_result['server_key']}")
|
362
306
|
if "message" in api_result:
|
363
307
|
logger.info(f" Message: {api_result['message']}")
|
364
|
-
|
365
308
|
logger.info("\n" + "="*80)
|
366
309
|
logger.info(f"📈 SUMMARY: {passed} passed, {failed} failed")
|
367
310
|
logger.info("="*80)
|
368
|
-
|
369
311
|
return passed, failed
|
370
|
-
|
371
|
-
|
372
312
|
def main():
|
373
313
|
"""Main function for the example."""
|
374
314
|
logger.info("🔧 MCP Proxy Adapter - Proxy Registration Example")
|
375
315
|
logger.info("="*60)
|
376
|
-
|
377
316
|
# Check if server is running
|
378
317
|
import socket
|
379
318
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
380
319
|
result = sock.connect_ex(('localhost', 8002))
|
381
320
|
sock.close()
|
382
|
-
|
383
321
|
if result != 0:
|
384
322
|
logger.error("❌ Server is not running on localhost:8002")
|
385
323
|
logger.info("💡 Please start the server first:")
|
386
324
|
logger.info(" cd mcp_proxy_adapter/examples")
|
387
325
|
logger.info(" python -m mcp_proxy_adapter.main --config server_configs/config_proxy_registration.json")
|
388
326
|
sys.exit(1)
|
389
|
-
|
390
327
|
logger.info("✅ Server is running on localhost:8002")
|
391
328
|
logger.info("🚀 Starting proxy registration example...")
|
392
|
-
|
393
329
|
# Run example
|
394
330
|
passed, failed = asyncio.run(run_proxy_registration_example())
|
395
|
-
|
396
331
|
# Exit with appropriate code
|
397
332
|
sys.exit(0 if failed == 0 else 1)
|
398
|
-
|
399
|
-
|
400
333
|
if __name__ == "__main__":
|
401
334
|
main()
|
@@ -1,81 +1,59 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
"""
|
3
3
|
Example Runner Script
|
4
|
-
|
5
4
|
This script provides a simple way to run the examples.
|
6
|
-
|
7
5
|
Author: Vasiliy Zdanovskiy
|
8
6
|
email: vasilyvz@gmail.com
|
9
7
|
"""
|
10
|
-
|
11
8
|
import sys
|
12
9
|
import subprocess
|
13
10
|
import argparse
|
14
11
|
from pathlib import Path
|
15
|
-
|
16
|
-
|
17
12
|
def run_basic_example(config_name: str, port: int = None):
|
18
13
|
"""Run basic framework example."""
|
19
14
|
config_path = Path(__file__).parent / "basic_framework" / "configs" / f"{config_name}.json"
|
20
15
|
main_script = Path(__file__).parent / "basic_framework" / "main.py"
|
21
|
-
|
22
16
|
if not config_path.exists():
|
23
17
|
print(f"❌ Configuration file not found: {config_path}")
|
24
18
|
return False
|
25
|
-
|
26
19
|
cmd = [sys.executable, str(main_script), "--config", str(config_path)]
|
27
20
|
if port:
|
28
21
|
cmd.extend(["--port", str(port)])
|
29
|
-
|
30
22
|
print(f"🚀 Running basic framework example with {config_name} configuration...")
|
31
23
|
return subprocess.run(cmd).returncode == 0
|
32
|
-
|
33
|
-
|
34
24
|
def run_full_example(config_name: str, port: int = None):
|
35
25
|
"""Run full application example."""
|
36
26
|
config_path = Path(__file__).parent / "full_application" / "configs" / f"{config_name}.json"
|
37
27
|
main_script = Path(__file__).parent / "full_application" / "main.py"
|
38
|
-
|
39
28
|
if not config_path.exists():
|
40
29
|
print(f"❌ Configuration file not found: {config_path}")
|
41
30
|
return False
|
42
|
-
|
43
31
|
cmd = [sys.executable, str(main_script), "--config", str(config_path)]
|
44
32
|
if port:
|
45
33
|
cmd.extend(["--port", str(port)])
|
46
|
-
|
47
34
|
print(f"🚀 Running full application example with {config_name} configuration...")
|
48
35
|
return subprocess.run(cmd).returncode == 0
|
49
|
-
|
50
|
-
|
51
36
|
def main():
|
52
37
|
"""Main function."""
|
53
38
|
parser = argparse.ArgumentParser(description="Run MCP Proxy Adapter Examples")
|
54
39
|
parser.add_argument("example", choices=["basic", "full"], help="Example type")
|
55
40
|
parser.add_argument("config", help="Configuration name (e.g., http_simple, https_auth)")
|
56
41
|
parser.add_argument("--port", type=int, help="Override port")
|
57
|
-
|
58
42
|
args = parser.parse_args()
|
59
|
-
|
60
43
|
# Available configurations
|
61
44
|
configs = [
|
62
|
-
"http_simple", "https_simple", "http_auth",
|
45
|
+
"http_simple", "https_simple", "http_auth",
|
63
46
|
"https_auth", "mtls_no_roles", "mtls_with_roles"
|
64
47
|
]
|
65
|
-
|
66
48
|
if args.config not in configs:
|
67
49
|
print(f"❌ Unknown configuration: {args.config}")
|
68
50
|
print(f"Available configurations: {', '.join(configs)}")
|
69
51
|
return 1
|
70
|
-
|
71
52
|
# Run the appropriate example
|
72
53
|
if args.example == "basic":
|
73
54
|
success = run_basic_example(args.config, args.port)
|
74
55
|
else:
|
75
56
|
success = run_full_example(args.config, args.port)
|
76
|
-
|
77
57
|
return 0 if success else 1
|
78
|
-
|
79
|
-
|
80
58
|
if __name__ == "__main__":
|
81
59
|
sys.exit(main())
|