Skip to content

Commit 4e44366

Browse files
committed
fix: use stderr for logging
Without this, logs get sent to stdout which is captured by the JSONRPC protocol (which also causes some errors with clients when the invalid JSON is sent over the stdout pipe).
1 parent 6a13ab9 commit 4e44366

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/fastmcp/utilities/logging.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
from typing import Literal
55

6+
from rich.console import Console
67
from rich.logging import RichHandler
78

89

@@ -27,5 +28,7 @@ def configure_logging(
2728
level: the log level to use
2829
"""
2930
logging.basicConfig(
30-
level=level, format="%(message)s", handlers=[RichHandler(rich_tracebacks=True)]
31+
level=level,
32+
format="%(message)s",
33+
handlers=[RichHandler(console=Console(stderr=True), rich_tracebacks=True)],
3134
)

0 commit comments

Comments
 (0)