test: Setup interactive browser test

This commit is contained in:
Chris Coutinho
2025-10-14 01:23:30 +02:00
parent 4d7e4b9a4b
commit 33b962a7fc
9 changed files with 162 additions and 63 deletions
+11 -9
View File
@@ -274,18 +274,20 @@ def get_app(transport: str = "sse", enabled_apps: list[str] | None = None):
# Determine authentication mode
oauth_enabled = is_oauth_mode()
# WARNING: This is a synchronous function but OAuth setup requires async
# For now, OAuth configuration will be handled differently
# We'll need to restructure this or use a factory pattern
if oauth_enabled:
logger.info("Configuring MCP server for OAuth mode")
logger.warning(
"OAuth mode requires async initialization - use factory pattern or separate setup"
# Asynchronously get the OAuth configuration
import asyncio
nextcloud_host, token_verifier, auth_settings = asyncio.run(
setup_oauth_config()
)
mcp = FastMCP(
"Nextcloud MCP",
lifespan=app_lifespan_oauth,
token_verifier=token_verifier,
auth=auth_settings,
)
# For now, fall back to a simplified OAuth setup
# TODO: This needs to be restructured to support async initialization
mcp = FastMCP("Nextcloud MCP", lifespan=app_lifespan_oauth)
else:
logger.info("Configuring MCP server for BasicAuth mode")
mcp = FastMCP("Nextcloud MCP", lifespan=app_lifespan_basic)
@@ -211,7 +211,7 @@ async def load_or_register_client(
storage_path: str | Path,
client_name: str = "Nextcloud MCP Server",
redirect_uris: list[str] | None = None,
force_register: bool = False,
force_register: bool = True,
) -> ClientInfo:
"""
Load client from storage or register a new one if not found/expired.
@@ -30,6 +30,7 @@ def get_client_from_context(ctx: Context, base_url: str) -> NextcloudClient:
ValueError: If username cannot be extracted from token
"""
try:
logger.info(f"Inspecting session object: {dir(ctx.request_context.session)}")
# Get AccessToken from MCP session (set by TokenVerifier)
access_token: AccessToken = ctx.request_context.session.access_token
+1 -1
View File
@@ -104,7 +104,7 @@ class NextcloudClient:
async def capabilities(self):
response = await self._client.get(
"/ocs/v2.php/cloud/capabilities",
"/ocs/v2.php/apps/notifications/api/v2/notifications",
headers={"OCS-APIRequest": "true", "Accept": "application/json"},
)
response.raise_for_status()