fix: C3 case-insensitive Bearer prefix + S1 MCP asyncio.Lock (closes 2 xfail)
tests / pytest (push) Has been cancelled

This commit is contained in:
Leopold
2026-07-06 07:10:35 +02:00
parent 2672bd86e6
commit 347ccb0c68
2 changed files with 18 additions and 10 deletions
+6 -1
View File
@@ -15,7 +15,12 @@ async def get_current_user(
if not authorization:
raise HTTPException(status_code=401, detail="Missing Authorization header")
token = authorization.replace("Bearer ", "").strip()
# Case-insensitive Bearer prefix handling (C3)
auth_value = authorization.strip()
if auth_value.lower().startswith("bearer "):
token = auth_value[7:].strip()
else:
token = auth_value
# Static-Auth-Token als Master-Key (für Setup/Bootstrap)
if token == settings.AUTH_TOKEN:
+5 -2
View File
@@ -1,4 +1,5 @@
"""MCP-Client: Verbindung zum Tool-Server."""
import asyncio
from typing import List, Dict, Any, Optional
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
@@ -12,9 +13,11 @@ class MCPClient:
self._session: Optional[ClientSession] = None
self._streams = None
self._ctx = None
self._lock = asyncio.Lock()
async def connect(self):
"""Stellt Verbindung zum MCP-Server her (lazy + reconnect-fähig)."""
async with self._lock:
if self._session:
return
self._ctx = streamablehttp_client(url=self.server_url)
@@ -76,8 +79,8 @@ class MCPClient:
"""Prüft ob MCP-Server erreichbar ist."""
try:
await self.connect()
return True
except Exception:
return self._session is not None
except BaseException:
return False