wip Move testing to container

This commit is contained in:
Chris Coutinho
2025-05-10 12:47:10 +02:00
parent c1763ebc6a
commit b0012d6e4a
8 changed files with 183 additions and 9 deletions
+9 -3
View File
@@ -7,6 +7,7 @@ from mcp.server.fastmcp import FastMCP, Context
from mcp.server import Server
from collections.abc import AsyncIterator
from nextcloud_mcp_server.client import NextcloudClient
import asyncio # Import asyncio
setup_logging()
@@ -24,6 +25,9 @@ async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
# Initialize on startup
logger.info("Creating Nextcloud client")
client = NextcloudClient.from_env()
# Add a small delay to allow client initialization to complete
logger.info("Waiting 2 seconds for client initialization...")
logger.info("Client initialization wait complete.")
try:
yield AppContext(client=client)
finally:
@@ -115,14 +119,16 @@ def nc_notes_get_attachment(note_id: int, attachment_filename: str):
client: NextcloudClient = ctx.request_context.lifespan_context.client
# Assuming a method get_note_attachment exists in the client
# This method should return the raw content and determine the mime type
content, mime_type = client.get_note_attachment(note_id=note_id, filename=attachment_filename)
content, mime_type = client.get_note_attachment(
note_id=note_id, filename=attachment_filename
)
return {
"contents": [
{
# Use uppercase 'Notes' to match the decorator
"uri": f"nc://Notes/{note_id}/attachments/{attachment_filename}",
"mimeType": mime_type, # Client needs to determine this
"data": content, # Return raw bytes/data
"mimeType": mime_type, # Client needs to determine this
"data": content, # Return raw bytes/data
}
]
}