Merge branch 'main' of github.com:oraios/serena

This commit is contained in:
Michael Panchenko
2025-03-25 00:55:07 +01:00
+13 -3
View File
@@ -12,6 +12,7 @@ from dataclasses import dataclass
from typing import Any, cast
import yaml
from mcp.server.fastmcp import server
from mcp.server.fastmcp.prompts.base import Message, UserMessage
from mcp.server.fastmcp.server import Context, FastMCP, Settings
from sensai.util import logging
@@ -25,6 +26,17 @@ from serena.util.file_system import scan_directory
log = logging.getLogger(__name__)
def configure_logging(*args, **kwargs) -> None:
# log to stderr (will be captured by Claude Desktop); stdio is the MCP communication stream and cannot be used!
logging.basicConfig(
level=logging.DEBUG, stream=sys.stderr, format="%(levelname)-5s %(asctime)-15s %(name)s:%(funcName)s:%(lineno)d - %(message)s"
)
# patch the logging configuration function in fastmcp, because it's hard-coded and broken
server.configure_logging = configure_logging
@dataclass
class SerenaMCPRequestContext:
language_server: SyncLanguageServer
@@ -193,7 +205,5 @@ def onboarding(ctx: Context) -> str:
if __name__ == "__main__":
logging.basicConfig(
level=logging.DEBUG, stream=sys.stderr, format="%(levelname)-5s %(asctime)-15s %(name)s:%(funcName)s:%(lineno)d - %(message)s"
)
log.info("Starting server")
mcp.run()