mcp-proxy-adapter 6.3.15__py3-none-any.whl → 6.3.16__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/api/middleware/protocol_middleware.py +63 -48
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.3.15.dist-info → mcp_proxy_adapter-6.3.16.dist-info}/METADATA +1 -1
- {mcp_proxy_adapter-6.3.15.dist-info → mcp_proxy_adapter-6.3.16.dist-info}/RECORD +7 -7
- {mcp_proxy_adapter-6.3.15.dist-info → mcp_proxy_adapter-6.3.16.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.3.15.dist-info → mcp_proxy_adapter-6.3.16.dist-info}/entry_points.txt +0 -0
- {mcp_proxy_adapter-6.3.15.dist-info → mcp_proxy_adapter-6.3.16.dist-info}/top_level.txt +0 -0
@@ -144,56 +144,71 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
|
|
144
144
|
Returns:
|
145
145
|
Protocol name (http, https, mtls)
|
146
146
|
"""
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if ssl_object:
|
147
|
+
try:
|
148
|
+
# Check if request is secure (HTTPS)
|
149
|
+
if request.url.scheme:
|
150
|
+
scheme = request.url.scheme.lower()
|
151
|
+
|
152
|
+
# If HTTPS, check if client certificate is provided (MTLS)
|
153
|
+
if scheme == "https":
|
154
|
+
# Check for client certificate in ASGI scope
|
155
|
+
try:
|
156
|
+
# Method 1: Check transport info in ASGI scope
|
157
|
+
if hasattr(request, "scope") and request.scope:
|
158
|
+
# Check for client certificate in transport layer
|
159
|
+
transport = request.scope.get("transport")
|
160
|
+
if transport and hasattr(transport, "get_extra_info"):
|
162
161
|
try:
|
163
|
-
|
164
|
-
if
|
165
|
-
|
166
|
-
|
162
|
+
ssl_object = transport.get_extra_info("ssl_object")
|
163
|
+
if ssl_object:
|
164
|
+
try:
|
165
|
+
cert = ssl_object.getpeercert()
|
166
|
+
if cert:
|
167
|
+
logger.debug(f"mTLS client certificate detected: {cert.get('subject', 'unknown')}")
|
168
|
+
return "mtls"
|
169
|
+
except Exception as e:
|
170
|
+
logger.debug(f"Error checking client certificate: {e}")
|
167
171
|
except Exception as e:
|
168
|
-
logger.debug(f"Error
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
172
|
+
logger.debug(f"Error getting SSL object from transport: {e}")
|
173
|
+
|
174
|
+
# Method 2: Check client info in ASGI scope
|
175
|
+
try:
|
176
|
+
client_info = request.scope.get("client")
|
177
|
+
if client_info and len(client_info) > 2:
|
178
|
+
# client_info format: (host, port, additional_info...)
|
179
|
+
# Additional info might contain certificate information
|
180
|
+
logger.debug(f"Client info detected, might be mTLS: {client_info}")
|
181
|
+
except Exception as e:
|
182
|
+
logger.debug(f"Error checking client info: {e}")
|
183
|
+
except Exception as e:
|
184
|
+
logger.debug(f"Error checking ASGI scope for mTLS: {e}")
|
185
|
+
|
186
|
+
# Check for client certificate in headers (proxy forwarded)
|
187
|
+
try:
|
188
|
+
if (request.headers.get("ssl-client-cert") or
|
189
|
+
request.headers.get("x-client-cert") or
|
190
|
+
request.headers.get("x-ssl-cert") or
|
191
|
+
request.headers.get("x-forwarded-client-cert")):
|
192
|
+
logger.debug("mTLS client certificate detected in headers")
|
193
|
+
return "mtls"
|
194
|
+
except Exception as e:
|
195
|
+
logger.debug(f"Error checking headers for mTLS: {e}")
|
196
|
+
|
197
|
+
return "https"
|
198
|
+
|
199
|
+
return scheme
|
200
|
+
|
201
|
+
# Fallback to checking headers
|
202
|
+
if request.headers.get("x-forwarded-proto"):
|
203
|
+
return request.headers.get("x-forwarded-proto").lower()
|
204
|
+
|
205
|
+
# Default to HTTP
|
206
|
+
return "http"
|
207
|
+
|
208
|
+
except Exception as e:
|
209
|
+
logger.error(f"Error in _get_request_protocol: {e}", exc_info=True)
|
210
|
+
# Fallback to HTTP if there's any error
|
211
|
+
return "http"
|
197
212
|
|
198
213
|
|
199
214
|
def setup_protocol_middleware(app, app_config: Optional[Dict[str, Any]] = None):
|
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.3.
|
3
|
+
Version: 6.3.16
|
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
|
@@ -4,7 +4,7 @@ mcp_proxy_adapter/config.py,sha256=-7iVS0mUWWKNeao7nqTAFlUD6FcMwRlDkchN7OwYsr0,2
|
|
4
4
|
mcp_proxy_adapter/custom_openapi.py,sha256=yLle4CntYK9wpivgn9NflZyJhy-YNrmWjJzt0ai5nP0,14672
|
5
5
|
mcp_proxy_adapter/main.py,sha256=qDkQTXnCvf8u0I3b8PRrguOoVdjd8YRr90ZooOqeOto,3401
|
6
6
|
mcp_proxy_adapter/openapi.py,sha256=2UZOI09ZDRJuBYBjKbMyb2U4uASszoCMD5o_4ktRpvg,13480
|
7
|
-
mcp_proxy_adapter/version.py,sha256=
|
7
|
+
mcp_proxy_adapter/version.py,sha256=pf4_y_pbHzVAUiMXhbiLW3FJHLCg0pslVHNa-MDrJkE,75
|
8
8
|
mcp_proxy_adapter/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
mcp_proxy_adapter/api/app.py,sha256=22NIDGo6pGkOZnvBWeKv_-RIRye4YaYkIskVGIsCCMs,28600
|
10
10
|
mcp_proxy_adapter/api/handlers.py,sha256=iyFGoEuUS1wxbV1ELA0zmaxIyQR7j4zw-4MrD-uIO6E,8294
|
@@ -18,7 +18,7 @@ mcp_proxy_adapter/api/middleware/error_handling.py,sha256=i3oghY1VdjHppFa7bTIx87
|
|
18
18
|
mcp_proxy_adapter/api/middleware/factory.py,sha256=r0BXntUOxF6DiCVqqmAUb3JjargdR28aj2d9X5z-zX4,7987
|
19
19
|
mcp_proxy_adapter/api/middleware/logging.py,sha256=AGv9lqfkTOCVJxYKflLghe1cd4kVPMLO1ni5E2FQBlk,4840
|
20
20
|
mcp_proxy_adapter/api/middleware/performance.py,sha256=-EvA7YIcTlxn8RuxlWlScJvX2EIoeEp3P5dKVWZHYRY,2357
|
21
|
-
mcp_proxy_adapter/api/middleware/protocol_middleware.py,sha256=
|
21
|
+
mcp_proxy_adapter/api/middleware/protocol_middleware.py,sha256=zm-Q0KnCzbAB3ue8dwnEkb-OyCuIbqu01s2_GE2rtH0,11094
|
22
22
|
mcp_proxy_adapter/api/middleware/transport_middleware.py,sha256=VG1rWyuh-O2pdc0kQ3SADFvyh286o5Wrnkt8OFQ0WQw,4274
|
23
23
|
mcp_proxy_adapter/api/middleware/unified_security.py,sha256=PMbJxVzGNlb-IPAqvIeEo1st-jykYX9Mns6lXIfdtAE,7764
|
24
24
|
mcp_proxy_adapter/api/middleware/user_info_middleware.py,sha256=A3liNzkZWDDlkDSBBoz8lH9fTLKlOQc_oI_M_dIGHx4,9330
|
@@ -137,8 +137,8 @@ mcp_proxy_adapter/schemas/base_schema.json,sha256=v9G9cGMd4dRhCZsOQ_FMqOi5VFyVbI
|
|
137
137
|
mcp_proxy_adapter/schemas/openapi_schema.json,sha256=C3yLkwmDsvnLW9B5gnKKdBGl4zxkeU-rEmjTrNVsQU0,8405
|
138
138
|
mcp_proxy_adapter/utils/config_generator.py,sha256=UXxuxxAyKTesAS3DOofQ26e20v771inA7EfBV8PZD1c,47543
|
139
139
|
mcp_proxy_adapter_issue_package/demonstrate_issue.py,sha256=O54fwWQvUAjEGiHhQGm1JLnARkhVCwAqjBk_89HyRbY,7894
|
140
|
-
mcp_proxy_adapter-6.3.
|
141
|
-
mcp_proxy_adapter-6.3.
|
142
|
-
mcp_proxy_adapter-6.3.
|
143
|
-
mcp_proxy_adapter-6.3.
|
144
|
-
mcp_proxy_adapter-6.3.
|
140
|
+
mcp_proxy_adapter-6.3.16.dist-info/METADATA,sha256=MbTaIC1gffjPJw8WnlLRi2EbvWVGCZy_2xQOCsgyw9E,22266
|
141
|
+
mcp_proxy_adapter-6.3.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
142
|
+
mcp_proxy_adapter-6.3.16.dist-info/entry_points.txt,sha256=J3eV6ID0lt_VSp4lIdIgBFTqLCThgObNNxRCbyfiMHw,70
|
143
|
+
mcp_proxy_adapter-6.3.16.dist-info/top_level.txt,sha256=CHk-Mc-AxjO-tRheegA2qLiQnU4vZRnxuTF81So6SAc,50
|
144
|
+
mcp_proxy_adapter-6.3.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|