MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / log

Method log

src/mcp/server/mcpserver/context.py:187–208  ·  view source on GitHub ↗

Send a log message to the client. Args: level: Log level (debug, info, notice, warning, error, critical, alert, emergency) data: The data to be logged. Any JSON serializable type is allowed (string, dict, list, number, bool, etc.) per

(
        self,
        level: LoggingLevel,
        data: Any,
        *,
        logger_name: str | None = None,
    )

Source from the content-addressed store, hash-verified

185
186 @deprecated("The logging capability is deprecated as of 2026-07-28 (SEP-2577).", category=MCPDeprecationWarning)
187 async def log(
188 self,
189 level: LoggingLevel,
190 data: Any,
191 *,
192 logger_name: str | None = None,
193 ) -> None:
194 """Send a log message to the client.
195
196 Args:
197 level: Log level (debug, info, notice, warning, error, critical,
198 alert, emergency)
199 data: The data to be logged. Any JSON serializable type is allowed
200 (string, dict, list, number, bool, etc.) per the MCP specification.
201 logger_name: Optional logger name
202 """
203 await self.request_context.session.send_log_message( # pyright: ignore[reportDeprecated]
204 level=level,
205 data=data,
206 logger=logger_name,
207 related_request_id=self.request_id,
208 )
209
210 # TODO(maxisbey): see if this is needed otherwise remove
211 @property

Callers 4

debugMethod · 0.95
infoMethod · 0.95
warningMethod · 0.95
errorMethod · 0.95

Calls 1

send_log_messageMethod · 0.80

Tested by

no test coverage detected