mcp-proxy-adapter 6.3.22__py3-none-any.whl → 6.3.23__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.
@@ -98,19 +98,25 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
98
98
  Response object
99
99
  """
100
100
  logger.debug(
101
- f"ProtocolMiddleware.dispatch called for {request.method} {request.url.path}"
101
+ f"🔍 ProtocolMiddleware.dispatch START for {request.method} {request.url.path}"
102
102
  )
103
+ logger.debug(f"🔍 ProtocolMiddleware - protocols.enabled: {self.protocol_manager.enabled}")
104
+ logger.debug(f"🔍 ProtocolMiddleware - allowed_protocols: {self.protocol_manager.allowed_protocols}")
105
+
103
106
  try:
104
107
  # Get protocol from request
105
108
  protocol = self._get_request_protocol(request)
106
- logger.debug(f"Detected protocol: {protocol} for {request.method} {request.url.path}")
107
- logger.debug(f"Request scheme: {request.url.scheme}")
108
- logger.debug(f"Request headers: {dict(request.headers)}")
109
+ logger.debug(f"🔍 ProtocolMiddleware - Detected protocol: {protocol} for {request.method} {request.url.path}")
110
+ logger.debug(f"🔍 ProtocolMiddleware - Request scheme: {request.url.scheme}")
111
+ logger.debug(f"🔍 ProtocolMiddleware - Request headers: {dict(request.headers)}")
109
112
 
110
113
  # Check if protocol is allowed
111
- if not self.protocol_manager.is_protocol_allowed(protocol):
114
+ is_allowed = self.protocol_manager.is_protocol_allowed(protocol)
115
+ logger.debug(f"🔍 ProtocolMiddleware - Protocol '{protocol}' allowed: {is_allowed}")
116
+
117
+ if not is_allowed:
112
118
  logger.warning(
113
- f"Protocol '{protocol}' not allowed for request to {request.url.path}"
119
+ f"❌ ProtocolMiddleware - Protocol '{protocol}' not allowed for request to {request.url.path}"
114
120
  )
115
121
  return JSONResponse(
116
122
  status_code=403,
@@ -122,13 +128,15 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
122
128
  )
123
129
 
124
130
  # Continue processing
125
- logger.debug(f"Protocol '{protocol}' allowed, continuing to next middleware/handler")
131
+ logger.debug(f"✅ ProtocolMiddleware - Protocol '{protocol}' allowed, continuing to next middleware/handler")
132
+ logger.debug(f"🔍 ProtocolMiddleware - About to call next handler")
126
133
  response = await call_next(request)
127
- logger.debug(f"Protocol middleware completed successfully for {request.method} {request.url.path}")
134
+ logger.debug(f" ProtocolMiddleware - Next handler completed with status: {response.status_code}")
135
+ logger.debug(f"✅ ProtocolMiddleware - Protocol middleware completed successfully for {request.method} {request.url.path}")
128
136
  return response
129
137
 
130
138
  except Exception as e:
131
- logger.error(f"Protocol middleware error: {e}", exc_info=True)
139
+ logger.error(f"❌ ProtocolMiddleware - Protocol middleware error: {e}", exc_info=True)
132
140
  return JSONResponse(
133
141
  status_code=500,
134
142
  content={"error": "Protocol validation error", "message": str(e)},
@@ -144,32 +152,47 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
144
152
  Returns:
145
153
  Protocol name (http, https, mtls)
146
154
  """
155
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol START")
156
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - request.url.scheme: {request.url.scheme}")
157
+
147
158
  try:
148
159
  # Check if request is secure (HTTPS)
149
160
  if request.url.scheme:
150
161
  scheme = request.url.scheme.lower()
162
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - scheme: {scheme}")
151
163
 
152
164
  # If HTTPS, check if client certificate is provided (MTLS)
153
165
  if scheme == "https":
166
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - HTTPS detected, checking for mTLS")
167
+
154
168
  # Check for client certificate in ASGI scope
155
169
  try:
156
170
  # Method 1: Check transport info in ASGI scope
157
171
  if hasattr(request, "scope") and request.scope:
172
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - ASGI scope available")
158
173
  # Check for client certificate in transport layer
159
174
  transport = request.scope.get("transport")
160
175
  if transport and hasattr(transport, "get_extra_info"):
176
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - transport available, checking SSL object")
161
177
  try:
162
178
  ssl_object = transport.get_extra_info("ssl_object")
163
179
  if ssl_object:
180
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - SSL object available, checking peer cert")
164
181
  try:
165
182
  cert = ssl_object.getpeercert()
166
183
  if cert:
167
- logger.debug(f"mTLS client certificate detected: {cert.get('subject', 'unknown')}")
184
+ logger.debug(f"✅ ProtocolMiddleware._get_request_protocol - mTLS client certificate detected: {cert.get('subject', 'unknown')}")
168
185
  return "mtls"
186
+ else:
187
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - No peer certificate found")
169
188
  except Exception as e:
170
- logger.debug(f"Error checking client certificate: {e}")
189
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Error checking client certificate: {e}")
190
+ else:
191
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - No SSL object found")
171
192
  except Exception as e:
172
- logger.debug(f"Error getting SSL object from transport: {e}")
193
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Error getting SSL object from transport: {e}")
194
+ else:
195
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - No transport or get_extra_info method")
173
196
 
174
197
  # Method 2: Check client info in ASGI scope
175
198
  try:
@@ -177,36 +200,50 @@ class ProtocolMiddleware(BaseHTTPMiddleware):
177
200
  if client_info and len(client_info) > 2:
178
201
  # client_info format: (host, port, additional_info...)
179
202
  # Additional info might contain certificate information
180
- logger.debug(f"Client info detected, might be mTLS: {client_info}")
203
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Client info detected, might be mTLS: {client_info}")
204
+ else:
205
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Client info: {client_info}")
181
206
  except Exception as e:
182
- logger.debug(f"Error checking client info: {e}")
207
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Error checking client info: {e}")
208
+ else:
209
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - No ASGI scope available")
183
210
  except Exception as e:
184
- logger.debug(f"Error checking ASGI scope for mTLS: {e}")
211
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Error checking ASGI scope for mTLS: {e}")
185
212
 
186
213
  # Check for client certificate in headers (proxy forwarded)
187
214
  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")
215
+ mtls_headers = [
216
+ request.headers.get("ssl-client-cert"),
217
+ request.headers.get("x-client-cert"),
218
+ request.headers.get("x-ssl-cert"),
219
+ request.headers.get("x-forwarded-client-cert")
220
+ ]
221
+ if any(mtls_headers):
222
+ logger.debug(f"✅ ProtocolMiddleware._get_request_protocol - mTLS client certificate detected in headers")
193
223
  return "mtls"
224
+ else:
225
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - No mTLS headers found")
194
226
  except Exception as e:
195
- logger.debug(f"Error checking headers for mTLS: {e}")
227
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Error checking headers for mTLS: {e}")
196
228
 
229
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Returning 'https' (no mTLS detected)")
197
230
  return "https"
198
231
 
232
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Returning scheme: {scheme}")
199
233
  return scheme
200
234
 
201
235
  # Fallback to checking headers
202
- if request.headers.get("x-forwarded-proto"):
203
- return request.headers.get("x-forwarded-proto").lower()
236
+ x_forwarded_proto = request.headers.get("x-forwarded-proto")
237
+ if x_forwarded_proto:
238
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Using x-forwarded-proto: {x_forwarded_proto}")
239
+ return x_forwarded_proto.lower()
204
240
 
205
241
  # Default to HTTP
242
+ logger.debug(f"🔍 ProtocolMiddleware._get_request_protocol - Defaulting to 'http'")
206
243
  return "http"
207
244
 
208
245
  except Exception as e:
209
- logger.error(f"Error in _get_request_protocol: {e}", exc_info=True)
246
+ logger.error(f" ProtocolMiddleware._get_request_protocol - Error: {e}", exc_info=True)
210
247
  # Fallback to HTTP if there's any error
211
248
  return "http"
212
249
 
@@ -160,14 +160,18 @@ class ProtocolManager:
160
160
  Returns:
161
161
  True if protocol is allowed, False otherwise
162
162
  """
163
+ logger.debug(f"🔍 ProtocolManager.is_protocol_allowed - protocol: {protocol}")
164
+ logger.debug(f"🔍 ProtocolManager.is_protocol_allowed - enabled: {self.enabled}")
165
+ logger.debug(f"🔍 ProtocolManager.is_protocol_allowed - allowed_protocols: {self.allowed_protocols}")
166
+
163
167
  if not self.enabled:
164
- logger.debug("Protocol management is disabled, allowing all protocols")
168
+ logger.debug("✅ ProtocolManager.is_protocol_allowed - Protocol management is disabled, allowing all protocols")
165
169
  return True
166
170
 
167
171
  protocol_lower = protocol.lower()
168
172
  is_allowed = protocol_lower in self.allowed_protocols
169
173
 
170
- logger.debug(f"Protocol '{protocol}' allowed: {is_allowed}")
174
+ logger.debug(f"🔍 ProtocolManager.is_protocol_allowed - Protocol '{protocol}' allowed: {is_allowed}")
171
175
  return is_allowed
172
176
 
173
177
  def get_protocol_port(self, protocol: str) -> Optional[int]:
@@ -2,4 +2,4 @@
2
2
  Version information for MCP Proxy Adapter.
3
3
  """
4
4
 
5
- __version__ = "6.3.22"
5
+ __version__ = "6.3.23"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-proxy-adapter
3
- Version: 6.3.22
3
+ Version: 6.3.23
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=LoepnC3yoCK-S-sNntpi33Js6H0zhCp1nuQ-NcSXoNw,3656
6
6
  mcp_proxy_adapter/openapi.py,sha256=2UZOI09ZDRJuBYBjKbMyb2U4uASszoCMD5o_4ktRpvg,13480
7
- mcp_proxy_adapter/version.py,sha256=l2ln4rN1GYmXKKSn3i7mIS_ofjhJYyapKnbp74PtWHA,75
7
+ mcp_proxy_adapter/version.py,sha256=AXsJFeJCfu8pwHEkazFV-fjEHQwdgjswIDoJv45-fak,75
8
8
  mcp_proxy_adapter/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  mcp_proxy_adapter/api/app.py,sha256=Ayvk_WsWuDkjYkKCzUB1ImCVINYnxzkGIgKE50UkqRY,29215
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=bXui9rUn4Gem3PoXuxldSB
18
18
  mcp_proxy_adapter/api/middleware/factory.py,sha256=r0BXntUOxF6DiCVqqmAUb3JjargdR28aj2d9X5z-zX4,7987
19
19
  mcp_proxy_adapter/api/middleware/logging.py,sha256=iME87hrbvyTjI-RJro5Cwao7VlHUIuWubpVUabv-s1M,5229
20
20
  mcp_proxy_adapter/api/middleware/performance.py,sha256=-EvA7YIcTlxn8RuxlWlScJvX2EIoeEp3P5dKVWZHYRY,2357
21
- mcp_proxy_adapter/api/middleware/protocol_middleware.py,sha256=zm-Q0KnCzbAB3ue8dwnEkb-OyCuIbqu01s2_GE2rtH0,11094
21
+ mcp_proxy_adapter/api/middleware/protocol_middleware.py,sha256=pM-VvsYzE8jiyn0kcehvZzg1UfJW38UemNMcp7xoT-w,14651
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=94oItW3uyNhLvp6p1Sl7EhY_gC4MqrbR9KyAJWreTwk,10326
@@ -67,7 +67,7 @@ mcp_proxy_adapter/core/errors.py,sha256=UNEfdmK0zPGJrWH1zUMRjHIJMcoVDcBO4w8xxKHB
67
67
  mcp_proxy_adapter/core/logging.py,sha256=gNI6vfPQC7jrUtVu6NeDsmU72JPlrRRBhtJipL1eVrI,9560
68
68
  mcp_proxy_adapter/core/mtls_asgi.py,sha256=tvk0P9024s18dcCHY9AaQIecT4ojOTv21EuQWXwooU0,5200
69
69
  mcp_proxy_adapter/core/mtls_asgi_app.py,sha256=DT_fTUH1RkvBa3ThbyCyNb-XUHyCb4DqaKA1gcZC6z4,6538
70
- mcp_proxy_adapter/core/protocol_manager.py,sha256=FM01lBDxUU-W7P8sQR72Jel1aB2nbp1PvO4TRoZ5c_Y,14881
70
+ mcp_proxy_adapter/core/protocol_manager.py,sha256=3sWOAiMniQY5nu9CHkitIOGN4CXH28hOTwY92D0yasM,15268
71
71
  mcp_proxy_adapter/core/proxy_client.py,sha256=XweRXBNbntJ5UYdSxUDcOYmJY0jbsKbfdWC0Jw72wdQ,23039
72
72
  mcp_proxy_adapter/core/proxy_registration.py,sha256=HzcYay7V0lPgHdmHa980e9HiRGNvFpwPaure1fULiGk,25610
73
73
  mcp_proxy_adapter/core/role_utils.py,sha256=YwRenGoXI5YrHVbFjKFAH2DJs2miyqhcr9LWF7mxieg,12284
@@ -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.22.dist-info/METADATA,sha256=p1HyxQikJHF2KV0iqmvGMF3ipXX_BcaQYQpyk5Otzl8,22266
141
- mcp_proxy_adapter-6.3.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
142
- mcp_proxy_adapter-6.3.22.dist-info/entry_points.txt,sha256=J3eV6ID0lt_VSp4lIdIgBFTqLCThgObNNxRCbyfiMHw,70
143
- mcp_proxy_adapter-6.3.22.dist-info/top_level.txt,sha256=CHk-Mc-AxjO-tRheegA2qLiQnU4vZRnxuTF81So6SAc,50
144
- mcp_proxy_adapter-6.3.22.dist-info/RECORD,,
140
+ mcp_proxy_adapter-6.3.23.dist-info/METADATA,sha256=ANw-yWKRXnyrro6xp_eYtwxIvqlCasWLQ1KLj-IIibI,22266
141
+ mcp_proxy_adapter-6.3.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
142
+ mcp_proxy_adapter-6.3.23.dist-info/entry_points.txt,sha256=J3eV6ID0lt_VSp4lIdIgBFTqLCThgObNNxRCbyfiMHw,70
143
+ mcp_proxy_adapter-6.3.23.dist-info/top_level.txt,sha256=CHk-Mc-AxjO-tRheegA2qLiQnU4vZRnxuTF81So6SAc,50
144
+ mcp_proxy_adapter-6.3.23.dist-info/RECORD,,