Skip to content

Commit 68894a4

Browse files
committed
Fix #64: Bind Session.current in broadcastLog loop
SessionManager.broadcastLog now wraps each session's sendLogNotification in session.work { ... }, ensuring Session.current is set before the transport send path runs. This is the correct fix — only the broadcast fan-out needs the context binding, not individual Session notification methods.
1 parent 496eee0 commit 68894a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/SwiftMCP/Transport/SessionManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ actor SessionManager {
200200
/// - Parameter message: The log message to send.
201201
func broadcastLog(_ message: LogMessage) async {
202202
for session in sessions.values {
203-
await session.sendLogNotification(message)
203+
await session.work { session in
204+
await session.sendLogNotification(message)
205+
}
204206
}
205207
}
206208
}

0 commit comments

Comments
 (0)