mcp-proxy-adapter 6.3.10__py3-none-any.whl → 6.3.12__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 -0
- mcp_proxy_adapter/core/app_factory.py +9 -2
- mcp_proxy_adapter/core/client_security.py +1 -1
- mcp_proxy_adapter/core/proxy_registration.py +68 -3
- mcp_proxy_adapter/examples/setup_test_environment.py +830 -20
- mcp_proxy_adapter/examples/setup_test_environment_old.py +316 -0
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/METADATA +1 -1
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/RECORD +14 -13
- mcp_proxy_adapter_issue_package/demonstrate_issue.py +74 -44
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-6.3.10.dist-info → mcp_proxy_adapter-6.3.12.dist-info}/top_level.txt +0 -0
mcp_proxy_adapter/__main__.py
CHANGED
@@ -21,7 +21,7 @@ from mcp_proxy_adapter.commands.builtin_commands import register_builtin_command
|
|
21
21
|
logger = get_logger("app_factory")
|
22
22
|
|
23
23
|
|
24
|
-
def create_and_run_server(
|
24
|
+
async def create_and_run_server(
|
25
25
|
config_path: Optional[str] = None,
|
26
26
|
log_config_path: Optional[str] = None,
|
27
27
|
title: str = "MCP Proxy Adapter Server",
|
@@ -361,7 +361,14 @@ def create_and_run_server(
|
|
361
361
|
print(f"🌐 Starting HTTP server with hypercorn...")
|
362
362
|
|
363
363
|
# Run the server
|
364
|
-
|
364
|
+
try:
|
365
|
+
# Check if we're already in an event loop
|
366
|
+
loop = asyncio.get_running_loop()
|
367
|
+
# If we're in a loop, use await instead of asyncio.run
|
368
|
+
await hypercorn.asyncio.serve(app, config_hypercorn)
|
369
|
+
except RuntimeError:
|
370
|
+
# No event loop running, use asyncio.run
|
371
|
+
asyncio.run(hypercorn.asyncio.serve(app, config_hypercorn))
|
365
372
|
|
366
373
|
except KeyboardInterrupt:
|
367
374
|
print("\n🛑 Server stopped by user")
|
@@ -74,7 +74,7 @@ class ClientSecurityManager:
|
|
74
74
|
def _create_ssl_config(self) -> SSLConfig:
|
75
75
|
"""Create SSL configuration for client connections."""
|
76
76
|
ssl_section = self.security_config.get("ssl", {})
|
77
|
-
|
77
|
+
|
78
78
|
# Determine verify_mode based on verify_server setting
|
79
79
|
verify_server = ssl_section.get("verify_server", True)
|
80
80
|
if verify_server:
|
@@ -147,19 +147,84 @@ class ProxyRegistrationManager:
|
|
147
147
|
|
148
148
|
def _create_ssl_context(self) -> Optional[ssl.SSLContext]:
|
149
149
|
"""
|
150
|
-
Create SSL context for secure connections.
|
150
|
+
Create SSL context for secure connections using registration SSL configuration.
|
151
151
|
|
152
152
|
Returns:
|
153
153
|
SSL context or None if SSL not needed
|
154
154
|
"""
|
155
|
+
logger.debug("_create_ssl_context called")
|
155
156
|
if not self.client_security:
|
157
|
+
logger.debug("SSL context creation failed: client_security is None")
|
156
158
|
return None
|
157
159
|
|
158
160
|
try:
|
159
161
|
# Check if SSL is enabled for registration
|
160
162
|
cert_config = self.registration_config.get("certificate", {})
|
161
|
-
|
162
|
-
|
163
|
+
ssl_config = self.registration_config.get("ssl", {})
|
164
|
+
|
165
|
+
logger.debug(
|
166
|
+
f"SSL context creation: cert_config={cert_config}, ssl_config={ssl_config}"
|
167
|
+
)
|
168
|
+
|
169
|
+
# SSL is enabled if certificate config exists or SSL config exists
|
170
|
+
if cert_config or ssl_config:
|
171
|
+
# Create a custom SSL context based on registration configuration
|
172
|
+
context = ssl.create_default_context()
|
173
|
+
|
174
|
+
# Load client certificates if provided
|
175
|
+
if cert_config:
|
176
|
+
cert_file = cert_config.get("cert_file")
|
177
|
+
key_file = cert_config.get("key_file")
|
178
|
+
|
179
|
+
if cert_file and key_file:
|
180
|
+
context.load_cert_chain(cert_file, key_file)
|
181
|
+
logger.debug(
|
182
|
+
f"Loaded client certificates: {cert_file}, {key_file}"
|
183
|
+
)
|
184
|
+
|
185
|
+
# Configure SSL verification based on registration settings
|
186
|
+
if ssl_config:
|
187
|
+
ca_cert_file = ssl_config.get("ca_cert")
|
188
|
+
verify_mode = ssl_config.get("verify_mode", "CERT_REQUIRED")
|
189
|
+
|
190
|
+
# Load CA certificate if provided
|
191
|
+
if ca_cert_file:
|
192
|
+
context.load_verify_locations(ca_cert_file)
|
193
|
+
logger.debug(f"Loaded CA certificate: {ca_cert_file}")
|
194
|
+
|
195
|
+
# Set verification mode based on ssl_config verify_mode
|
196
|
+
if verify_mode == "CERT_NONE":
|
197
|
+
context.check_hostname = False
|
198
|
+
context.verify_mode = ssl.CERT_NONE
|
199
|
+
logger.debug("SSL verification disabled (CERT_NONE)")
|
200
|
+
elif verify_mode == "CERT_REQUIRED":
|
201
|
+
context.check_hostname = True
|
202
|
+
context.verify_mode = ssl.CERT_REQUIRED
|
203
|
+
logger.debug("SSL verification enabled (CERT_REQUIRED)")
|
204
|
+
else:
|
205
|
+
# Default to CERT_REQUIRED
|
206
|
+
context.check_hostname = True
|
207
|
+
context.verify_mode = ssl.CERT_REQUIRED
|
208
|
+
logger.debug("SSL verification enabled (default)")
|
209
|
+
else:
|
210
|
+
# Check certificate config for verify_server setting
|
211
|
+
verify_server = cert_config.get("verify_server", True)
|
212
|
+
if not verify_server:
|
213
|
+
context.check_hostname = False
|
214
|
+
context.verify_mode = ssl.CERT_NONE
|
215
|
+
logger.debug("SSL verification disabled (verify_server: false)")
|
216
|
+
else:
|
217
|
+
# Default SSL context if no specific SSL config
|
218
|
+
context.check_hostname = True
|
219
|
+
context.verify_mode = ssl.CERT_REQUIRED
|
220
|
+
logger.debug("Using default SSL verification")
|
221
|
+
|
222
|
+
logger.info("Created custom SSL context for proxy registration")
|
223
|
+
return context
|
224
|
+
else:
|
225
|
+
logger.debug(
|
226
|
+
"SSL context creation skipped: no cert_config or ssl_config"
|
227
|
+
)
|
163
228
|
|
164
229
|
return None
|
165
230
|
except Exception as e:
|