MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / LoggingHandler

Struct LoggingHandler

mcp/logging.go:80–90  ·  view source on GitHub ↗

A LoggingHandler is a [slog.Handler] for MCP.

Source from the content-addressed store, hash-verified

78
79// A LoggingHandler is a [slog.Handler] for MCP.
80type LoggingHandler struct {
81 opts LoggingHandlerOptions
82 ss *ServerSession
83 // Ensures that the buffer reset is atomic with the write (see Handle).
84 // A pointer so that clones share the mutex. See
85 // https://github.com/golang/example/blob/master/slog-handler-guide/README.md#getting-the-mutex-right.
86 mu *sync.Mutex
87 lastMessageSent time.Time // for rate-limiting
88 buf *bytes.Buffer
89 handler slog.Handler
90}
91
92// ensureLogger returns l if non-nil, otherwise a discard logger.
93func ensureLogger(l *slog.Logger) *slog.Logger {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected