logging

package
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logging provides MCP protocol-level logging via ServerSession. It sends structured log messages to connected clients for server monitoring, complementing the stderr-based slog logging already in place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionLogger

type SessionLogger struct {
	// contains filtered or unexported fields
}

SessionLogger wraps a *mcp.ServerSession and provides convenience methods for sending MCP protocol log messages to the connected client.

SECURITY: All data passed to log methods is sent to the MCP client. Never pass secrets (tokens, passwords, credentials) or structs that contain them.

func FromToolRequest

func FromToolRequest(req *mcp.CallToolRequest) *SessionLogger

FromToolRequest extracts the ServerSession from a CallToolRequest and returns a SessionLogger. Returns nil if the request, session, or client initialization params are nil (session not yet initialized).

func NewSessionLogger

func NewSessionLogger(session *mcp.ServerSession) *SessionLogger

NewSessionLogger creates a SessionLogger from an explicit ServerSession. Returns nil if session is nil.

func (*SessionLogger) Debug

func (l *SessionLogger) Debug(ctx context.Context, message string, data any)

Debug sends a debug-level log message to the client. The data parameter is sent to the MCP client as-is; do not include secrets.

func (*SessionLogger) Error

func (l *SessionLogger) Error(ctx context.Context, message string, data any)

Error sends an error-level log message to the client. The data parameter is sent to the MCP client as-is; do not include secrets.

func (*SessionLogger) Info

func (l *SessionLogger) Info(ctx context.Context, message string, data any)

Info sends an info-level log message to the client. The data parameter is sent to the MCP client as-is; do not include secrets.

func (*SessionLogger) LogToolCall

func (l *SessionLogger) LogToolCall(ctx context.Context, tool string, start time.Time, err error)

LogToolCall sends a structured tool execution log to the client. It includes tool name, duration, and success/failure status. This complements the stderr-based logToolCall in the tools package.

func (*SessionLogger) Warning

func (l *SessionLogger) Warning(ctx context.Context, message string, data any)

Warning sends a warning-level log message to the client. The data parameter is sent to the MCP client as-is; do not include secrets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL