Compare commits

...

1 commit

Author SHA1 Message Date
marvin-context-protocol[bot]
2702f5ad85 fix: widen Rich console and traceback output
Add rich_console_width setting (default 120) to control Rich console
width for better readability of tracebacks and console output.

This fixes the issue where Rich tracebacks were extremely narrow
and hard to read by setting a reasonable default width.

Co-authored-by: William Easton <strawgate@users.noreply.github.com>
2025-09-18 22:23:16 +00:00
4 changed files with 21 additions and 2 deletions

View file

@ -10,6 +10,7 @@ if settings.log_enabled:
_configure_logging(
level=settings.log_level,
enable_rich_tracebacks=settings.enable_rich_tracebacks,
console_width=settings.rich_console_width,
)
from fastmcp.server.server import FastMCP

View file

@ -172,6 +172,19 @@ class Settings(BaseSettings):
),
] = True
rich_console_width: Annotated[
int | None,
Field(
description=inspect.cleandoc(
"""
Width for Rich console output including tracebacks. If None,
Rich will auto-detect the terminal width. Set to a larger value
(e.g., 120, 140) for wider tracebacks that show more code context.
"""
)
),
] = 120
deprecation_warnings: Annotated[
bool,
Field(

View file

@ -231,5 +231,8 @@ def log_server_banner(
expand=False,
)
console = Console(stderr=True)
from fastmcp.settings import Settings
settings = Settings()
console = Console(stderr=True, width=settings.rich_console_width)
console.print(Group("\n", panel, "\n"))

View file

@ -23,6 +23,7 @@ def configure_logging(
level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | int = "INFO",
logger: logging.Logger | None = None,
enable_rich_tracebacks: bool = True,
console_width: int | None = None,
**rich_kwargs: Any,
) -> None:
"""
@ -31,6 +32,7 @@ def configure_logging(
Args:
logger: the logger to configure
level: the log level to use
console_width: width for Rich console output
rich_kwargs: the parameters to use for creating RichHandler
"""
@ -39,7 +41,7 @@ def configure_logging(
# Only configure the FastMCP logger namespace
handler = RichHandler(
console=Console(stderr=True),
console=Console(stderr=True, width=console_width),
rich_tracebacks=enable_rich_tracebacks,
**rich_kwargs,
)