MemotivaMCP Advanced: Logging, Progress Notifications, Context Methods for Long Tasks

How do you send log messages from an MCP server tool?

MCP Advanced: Logging, Progress Notifications, Context Methods for Long Tasks

Audio flashcard · 0:27

Nortren·

How do you send log messages from an MCP server tool?

0:27

You send log messages by calling the info method on the Context object inside your tool function. The context is automatically injected when you include it as a parameter in your tool definition. For example, calling await context.info with a string like "About to do research" sends that message to the client in real time. The info method is one of several logging levels available. These messages help users understand what phase of processing the tool is currently in, especially for operations that take several seconds or more.
github.com