wip Move testing to container
This commit is contained in:
@@ -195,10 +195,10 @@ class NextcloudClient:
|
||||
# Sort by score in descending order
|
||||
search_results.sort(key=lambda x: x["_score"], reverse=True)
|
||||
|
||||
# Remove score field before returning (optional)
|
||||
for result in search_results:
|
||||
if "_score" in result:
|
||||
del result["_score"]
|
||||
# Keep score field for debugging
|
||||
# for result in search_results:
|
||||
# if "_score" in result:
|
||||
# del result["_score"]
|
||||
|
||||
return search_results
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ LOGGING_CONFIG = {
|
||||
"loggers": {
|
||||
"": {
|
||||
"handlers": ["default"],
|
||||
"level": "INFO",
|
||||
"level": "DEBUG",
|
||||
},
|
||||
"httpx": {
|
||||
"handlers": ["default"],
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user