Repository navigation
Description
Split out of #180, where the decision was that a structured access log should be opt-in on every
framework.
Today
FastMcpConfig.logging_turn_off_middleware: bool = False (fastmcp_bootstrapper.py:84), so
FastMcpLoggingMiddleware is installed by default and every MCP message produces a log line.
Litestar's equivalent is off by default (litestar_logging_middleware_enabled: bool = False), and
#180 adds FastAPI's off by default too. FastMCP is then the only framework logging every message
without being asked.
The change
Flip the default, and rename while doing it. Keeping the current name would mean
logging_turn_off_middleware: bool = True, which reads as "turn off defaults to true, set it false
to turn on", and would contradict docs/integrations/fastmcp.md:50 ("Set
logging_turn_off_middleware=True on the config to disable").
Rename to fastmcp_logging_middleware_enabled: bool = False, so all three frameworks read the same
way:
| framework | field |
|---|---|
| Litestar | litestar_logging_middleware_enabled |
| FastAPI (#180) | fastapi_logging_middleware_enabled |
| FastMCP | fastmcp_logging_middleware_enabled |
Keep the old name working
FastMcpConfig is a frozen dataclass, so an unknown keyword raises TypeError. A bare rename breaks
every service that set the old field, at construction.
AGENTS.md's rule is "a public rename ships a silent alias", worked as
OpentelemetryConfig = OpenTelemetryConfig. A dataclass field cannot alias that way, so the nearest
equivalent:
- keep
logging_turn_off_middleware: bool | None = None - in
__post_init__, when it is notNone, map it onto the new field (Falsemeans the caller
wanted the middleware on,Truemeans off) andwarn_at_callerthat it is superseded
That preserves the intent of anyone who set it explicitly. Anyone who never set it gets the new
default, which is the point of the change. The repo has no DeprecationWarning precedent, and
warn_at_caller is already the documented channel for a warning reached from config construction
(AGENTS.md, "Code style"), so a plain warn_at_caller fits better than introducing a new warning
category.
Verification
- A config setting neither field installs no middleware.
fastmcp_logging_middleware_enabled=Trueinstalls it, and messages are logged as they are today.logging_turn_off_middleware=Falsestill installs it, and warns.logging_turn_off_middleware=Truedoes not install it, and warns.- The warning is attributed to the user's own frame, the invariant
tests/test_config_cascade.py:61
already pins for other config-construction warnings.
docs/integrations/fastmcp.md needs the new field, the new default, and a note that the old name
still works.
Note for the release
This removes log output from services that never configured it. It wants its own release-note line,
which is why it is a separate issue from #180 rather than folded into it.
Activity