fix: Configure logging
This commit is contained in:
+1
-5
@@ -6,8 +6,4 @@ COPY . .
|
|||||||
|
|
||||||
RUN uv sync --locked
|
RUN uv sync --locked
|
||||||
|
|
||||||
ENV VIRTUAL_ENV=/app/.venv
|
CMD ["uv", "run", "mcp", "run", "--transport", "sse", "nextcloud_mcp_server/server.py:mcp"]
|
||||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
||||||
ENV FASTMCP_LOG_LEVEL=DEBUG
|
|
||||||
|
|
||||||
CMD ["mcp", "run", "--transport", "sse", "nextcloud_mcp_server/server.py:mcp"]
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import time # Import time for sleep
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from io import BytesIO
|
|
||||||
from httpx import (
|
from httpx import (
|
||||||
Client,
|
Client,
|
||||||
Auth,
|
Auth,
|
||||||
BasicAuth,
|
BasicAuth,
|
||||||
Headers,
|
|
||||||
Request,
|
Request,
|
||||||
Response,
|
Response,
|
||||||
HTTPStatusError,
|
HTTPStatusError,
|
||||||
|
|||||||
@@ -4,11 +4,8 @@ LOGGING_CONFIG = {
|
|||||||
"version": 1,
|
"version": 1,
|
||||||
"handlers": {
|
"handlers": {
|
||||||
"default": {
|
"default": {
|
||||||
"class": "logging.FileHandler",
|
"class": "logging.StreamHandler",
|
||||||
"formatter": "http",
|
"formatter": "http",
|
||||||
# "stream": "ext://sys.stderr"
|
|
||||||
"filename": "/tmp/nextcloud-mcp-server.log",
|
|
||||||
"mode": "a",
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"formatters": {
|
"formatters": {
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import asyncio # Import asyncio
|
|||||||
|
|
||||||
setup_logging()
|
setup_logging()
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class AppContext:
|
class AppContext:
|
||||||
@@ -23,11 +21,9 @@ class AppContext:
|
|||||||
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
||||||
"""Manage application lifecycle with type-safe context"""
|
"""Manage application lifecycle with type-safe context"""
|
||||||
# Initialize on startup
|
# Initialize on startup
|
||||||
logger.info("Creating Nextcloud client")
|
logging.info("Creating Nextcloud client")
|
||||||
client = NextcloudClient.from_env()
|
client = NextcloudClient.from_env()
|
||||||
# Add a small delay to allow client initialization to complete
|
logging.info("Client initialization wait complete.")
|
||||||
logger.info("Waiting 2 seconds for client initialization...")
|
|
||||||
logger.info("Client initialization wait complete.")
|
|
||||||
try:
|
try:
|
||||||
yield AppContext(client=client)
|
yield AppContext(client=client)
|
||||||
finally:
|
finally:
|
||||||
@@ -38,6 +34,8 @@ async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
|
|||||||
# Create an MCP server
|
# Create an MCP server
|
||||||
mcp = FastMCP("Nextcloud MCP", lifespan=app_lifespan)
|
mcp = FastMCP("Nextcloud MCP", lifespan=app_lifespan)
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@mcp.resource("nc://capabilities")
|
@mcp.resource("nc://capabilities")
|
||||||
def nc_get_capabilities():
|
def nc_get_capabilities():
|
||||||
|
|||||||
Reference in New Issue
Block a user