`logging/setLevel` from one session changes the log level of other sessions
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ruby
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with lib/mcp/server.rb:1386, lib/mcp/server_session.rb:310-314, and lib/mcp/server.rb:448-450 to trace how session and server log levels are applied. The issue suggests updating the server-wide value only when session is nil; check existing logging specs and add coverage for two legacy sessions. Done means setting a level in one session does not change notifications sent to another session that never set a level. An open linked pull request (#667) is already addressing this issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Server#configure_logging_level sets the level on the calling session, then always sets the server-wide @logging_message_notification too (server.rb:1386).
Legacy sessions that did not set their own level fall back to that server-wide value (server_session.rb:310-314), and Server#notify_log_message uses it for broadcasts (server.rb:448-450). So when one client calls logging/setLevel, every other legacy session without its own level starts to get notifications/message at that level. This includes sessions created later.
The spec treats the log level as a preference of the connection that sets it. The modern lifecycle is not affected, because it uses the per-request logLevel from the envelope.
Repro
Run from the repository root with bundle exec ruby -I lib repro.rb:
require "mcp"
class RecordingTransport
attr_reader :log_messages
def initialize
@log_messages = []
end
def send_notification(method, params = nil, session_id: nil, **)
@log_messages << [session_id, params["data"]] if method == "notifications/message"
true
end
end
log_tool = MCP::Tool.define(name: "log_tool") do |server_context:|
server_context.notify_log_message(data: "debug detail", level: "debug")
MCP::Tool::Response.new([{ type: "text", text: "ok" }])
end
transport = RecordingTransport.new
server = MCP::Server.new(name: "example", tools: [log_tool])
server.transport = transport
initialize_request = {
jsonrpc: "2.0", id: 1, method: "initialize",
params: { protocolVersion: "2025-11-25", capabilities: {}, clientInfo: { name: "client", version: "1" } },
}
session_a = MCP::ServerSession.new(server: server, transport: transport, session_id: "A")
session_b = MCP::ServerSession.new(server: server, transport: transport, session_id: "B")
session_a.handle(initialize_request)
session_b.handle(initialize_request)
session_a.handle({ jsonrpc: "2.0", id: 2, method: "logging/setLevel", params: { level: "debug" } })
session_b.handle({ jsonrpc: "2.0", id: 3, method: "tools/call", params: { name: "log_tool", arguments: {} } })
p transport.log_messages
Expected: []. Session B never called logging/setLevel.
Actual: [["B", "debug detail"]]
Suggested fix
Set the server-wide value only on the session-less path (session is nil). With a session, change only that session's level. Applications can still set a server-wide default with Server#logging_message_notification=.
- Ngôn ngữ chính
- Ruby
- Star
- 940
- Fork
- 143
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 48
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/ruby-sdk
-
Invalid UTF-8 in `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` gives 500 instead of 400Có thể đã có người làm @koic đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
modelcontextprotocol/ruby-sdk#663 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`Client::Stdio` passes the whole parent environment to the server processCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
modelcontextprotocol/ruby-sdk#662 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Elicitation results are not checked against `requested_schema`, but the docs say they match itCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#661 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`JWTVerifier` answers 500 instead of 401 for a PS256 token when it verifies with an EC key (jwt < 3.3.0)Có thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#659 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Concurrent requests overwrite each other's instrumentation dataCó thể đã có người làm @atesgoral đã nhận 1 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
modelcontextprotocol/ruby-sdk#657 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/ruby-sdk
Issue tương tự
-
test_rescues_connection_reset_on_issue_comments_lookup fails on master and blocks every pull requestĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
zerocracy/judges-action#3142 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Malformed encoded_filters causes a 500, and keeps failing with session persistenceCó thể đã có người làm @officialasishkumar đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
avo-hq/avo#4986 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
endoflife-date/endoflife.date#11561 ·
Maintainer thường phản hồi trong vòng 1 ngày