PrefectHQ/fastmcp · warning · RuntimeError
logging/setLevel is not available on MCP 2026-07-28 connecti
Error message
logging/setLevel is not available on MCP 2026-07-28 connections; the method requires per-session server state that the modern protocol does not have. Filter incoming log messages by level in your log_handler instead.
What it means
`logging/setLevel` exists in legacy MCP but is absent in the modern (MCP 2026-07-28) era, which has no per-session server state. FastMCP raises this RuntimeError from `client.set_logging_level()` when the connection's protocol version is modern and recommends filtering log messages client-side in your `log_handler`. Log notifications themselves still arrive.
Source
Thrown at fastmcp_slim/fastmcp/client/client.py:1414
"""Send a progress notification."""
# Deprecated upstream in SDK v2 but deliberately kept per compat directive;
# removed with the multi-round-trip follow-up.
await self.session.send_progress_notification( # ty: ignore[deprecated]
progress_token, progress, total, message
)
async def set_logging_level(self, level: mcp_types.LoggingLevel) -> None:
"""Send a logging/setLevel request.
Handshake-era servers only. `logging/setLevel` asks the server to
remember a level for the rest of the session, and the 2026-07-28
protocol has no session to remember it in — the method is absent from
that era's registry. Log *notifications* are unaffected: they ride the
request's own stream, so a server's `ctx.info()` still reaches you.
Filter by level on the receiving side instead, in your `log_handler`.
"""
if self.protocol_version in MODERN_PROTOCOL_VERSIONS:
raise RuntimeError(
"logging/setLevel is not available on MCP 2026-07-28 "
"connections; the method requires per-session server state that "
"the modern protocol does not have. Filter incoming log "
"messages by level in your log_handler instead."
)
# Deprecated upstream in SDK v2 but deliberately kept per compat directive;
# removed with the multi-round-trip follow-up.
await self._await_with_session_monitoring(
self.session.set_logging_level(level) # ty: ignore[deprecated]
)
async def send_roots_list_changed(self) -> None:
"""Send a roots/list_changed notification."""
# Deprecated upstream in SDK v2 but deliberately kept per compat directive;
# removed with the multi-round-trip follow-up.
await self.session.send_roots_list_changed() # ty: ignore[deprecated]
# --- Completion ---View on GitHub (pinned to 1f02114297)
Solutions
- Remove the set_logging_level call and filter by level inside your log_handler
- Connect with mode='legacy' if you control the client and need server-side level state
- Wrap in try/except RuntimeError and fall back to client-side filtering
Example fix
// before
await client.set_logging_level("debug")
// after
async def log_handler(msg) -> None:
if msg.level in ("debug", "info"):
print(msg.data)
# pass log_handler=log_handler when constructing the Client Defensive patterns
Strategy: fallback
Validate before calling
def can_set_logging_level(client) -> bool:
return client.protocol_version not in MODERN_PROTOCOL_VERSIONS Try / catch
try:
await client.set_logging_level("debug")
except RuntimeError as e:
if "logging/setLevel is not available" in str(e):
pass # rely on log_handler level filtering instead
else:
raise Prevention
- Filter log messages by level in log_handler rather than server-side
- Check protocol_version before calling protocol-specific methods
- Document protocol-era assumptions in shared client helpers
When it happens
Trigger: Calling `client.set_logging_level(...)` (or a session-level variant) on a client connected in modern mode / with a modern protocol version.
Common situations: Migrating client code from legacy to modern-era servers; shared logging helpers calling set_logging_level unconditionally; wanting dynamic verbosity control after a server protocol upgrade.
Related errors
- The client negotiated a modern protocol era (server/discover
- INVALID_PARAMS
- Unexpected elicitation action: {result.action}
- Error reading resource {uri!r}
- Error reading resource {uri!r}: {e}
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/05895eb2193a714f.
Report an issue: GitHub.