Skip to main content
MCP Apps SDK

Overview

sendLog sends log messages from the View to the host for debugging purposes. These logs are not added to the conversation and are not visible to the end user. They are intended for developers to diagnose issues during development or in production. Use sendLog when you need structured logging that the host can capture, filter, or display in its developer tools. This is particularly useful because MCP App Views run in sandboxed iframes where console.log output may not be easily accessible.

Signature

Parameters

params
object
required
level
string
required
The log level. Common values include "debug", "info", "warning", and "error".
data
string
required
The log message content.
logger
string
An optional logger name to identify the source of the log message. Useful when multiple components emit logs.

Returns

Returns Promise<void>. The method resolves when the log has been sent to the host.

Usage

Basic logging

Logging at different levels

Wrapping in a helper

  • useSendLog — React hook that wraps this method.
  • Requests — Overview of all View-to-host request methods.