mcplog

package
v0.0.65 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MCPSessionContextKey = ContextKey("mcp_session")

MCPSessionContextKey is the context key for storing MCP ServerSession

Variables

This section is empty.

Functions

func HandleK8sError

func HandleK8sError(ctx context.Context, err error, operation string)

HandleK8sError sends appropriate MCP log messages based on Kubernetes API error types. operation should describe the operation (e.g., "pod access", "deployment deletion").

func Sanitize added in v0.0.63

func Sanitize(msg string) string

Sanitize redacts secret-shaped substrings (Bearer/Basic credentials, JWTs, JSON "token"/"secret"/"password"/... fields, AWS/GitHub/Anthropic keys, private-key PEM blocks, DB connection strings) from msg. It is intended for log messages that may inline user-supplied or tool-supplied payloads.

This is best-effort: the patterns are a denylist, and content that doesn't match a known shape (e.g. arbitrary YAML kubeconfig fields) passes through unchanged. Callers handling structured credentials should still avoid logging them in the first place.

func SendMCPLog

func SendMCPLog(ctx context.Context, level Level, message string)

SendMCPLog sends a log notification to the MCP client and server logs. Uses dedicated "mcp" named logger. Message is automatically sanitized.

Types

type ContextKey

type ContextKey string

ContextKey is a type for context keys to avoid collisions

type Level

type Level int

Level represents MCP log severity levels per RFC 5424 syslog specification. https://modelcontextprotocol.io/specification/2025-11-25/server/utilities/logging#log-levels

const (
	// LevelDebug is for detailed debugging information.
	LevelDebug Level = iota
	// LevelInfo is for general informational messages.
	LevelInfo
	// LevelNotice is for normal but significant events.
	LevelNotice
	// LevelWarning is for warning conditions.
	LevelWarning
	// LevelError is for error conditions.
	LevelError
	// LevelCritical is for critical conditions.
	LevelCritical
	// LevelAlert is for conditions requiring immediate action.
	LevelAlert
	// LevelEmergency is for system unusable conditions.
	LevelEmergency
)

Log levels from least to most severe, per MCP specification.

func (Level) String

func (l Level) String() string

String returns the MCP protocol string representation of the level.

Jump to

Keyboard shortcuts

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