Skip to contents

Sends a log message to the MCP client while a tool, a resource, a prompt or a completion function runs. The client gets the messages at the level it set and above, info and above until it sets one. Outside a server, it only checks its arguments, so the function stays callable anywhere. The server sends at most ten messages per second for a call and drops the others, and stops once the call has answered. A message must hold no secret, no personal data and no internal detail that would help an attack: the server only removes control characters from its text.

Usage

log_message(data, level = "info", logger = NULL)

Arguments

data

What to log: a string, a number, a logical, or a list, which the client gets as JSON.

level

The severity, from the least to the most severe: "debug", "info", "notice", "warning", "error", "critical", "alert" or "emergency".

logger

The name of the logger, or NULL for the name of the package.

Value

NULL, invisibly.

Examples

# Outside a server, it only checks its arguments.
log_message(
  "Reading the runs of 2025.",
  level = "debug"
)