Skip to content

docs/server: fix logging defaults and the SetLoggingLevel method name - #1251

Open
rishabhsai wants to merge 2 commits into
modelcontextprotocol:mainfrom
rishabhsai:docs-server-logging-defaults
Open

rishabhsai wants to merge 2 commits into
modelcontextprotocol:mainfrom
rishabhsai:docs-server-logging-defaults

Conversation

@rishabhsai

Copy link
Copy Markdown
Contributor

The Logging section of docs/server.md says "For stateful sessions" twice in a row with opposite meanings, so one of the two sentences has to be wrong. The default level of "info" is set in only one place in the SDK, StreamableHTTPHandler.ephemeralConnectOpts in mcp/streamable.go, which handles stateless requests; a session created through Server.Connect starts with an empty ServerSessionState.LogLevel, and ServerSession.Log returns early while the level is empty, which is exactly what the first sentence already says. The second sentence now reads "For stateless sessions". The same section also tells readers to call SetLevel, but there is no such exported method: the client-side call is ClientSession.SetLoggingLevel, and setLevel is only the unexported server handler, so the pkg.go.dev link on the page points at an anchor that does not exist. For context, the stateless default arrived in #411 and the paragraph describing it was written later in #497, which is where the duplicated "stateful" came from.

Checked with go doc ./mcp ClientSession (only SetLoggingLevel is exported) and grep -rn 'LogLevel = "info"' mcp/ (a single hit, mcp/streamable.go:516); docs/server.md was regenerated with go generate ./internal/docs, and go build ./... && go test ./... pass.

The logging section said "for stateful sessions" twice in a row with
opposite meanings, so one of the two sentences had to be wrong. The
default of "info" is set only in `StreamableHTTPHandler.ephemeralConnectOpts`
(mcp/streamable.go), which applies to stateless requests; a session built
through `Server.Connect` starts with an empty level, and `ServerSession.Log`
returns early until the client sets one, which is what the first sentence
already says. The section also told readers to call `SetLevel`, but that is
not an exported method: the client-side call is `ClientSession.SetLoggingLevel`,
so the pkg.go.dev anchor the page linked to does not exist.
Comment thread docs/server.md Outdated
Comment on lines +1069 to +1070
until the client calls `SetLoggingLevel` (see below).
For stateless sessions, the level defaults to "info".

@guglielmo-san guglielmo-san Sep 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For legacy stateless sessions the level defaults to "info". For sessionless 2026-07-28 requests there is no server-side default: each request carries its level in _meta (io.modelcontextprotocol/logLevel), and nothing is logged until the client sends one. (Note: logging is deprecated as of 2026-07-28 / SEP-2577.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied your wording in 04140b2, with backticks around _meta and io.modelcontextprotocol/logLevel to match the rest of the docs; thanks.

Wording suggested by guglielmo-san in review, which distinguishes the legacy stateless default from sessionless 2026-07-28 requests that carry their level in _meta.

Signed-off-by: Rishabh <rishabhsaiv@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants