daBongo LMS AI Training Courses

Model Context Protocol – Advanced Patterns for Production

Lesson 2: Notifications and Real-Time Updates

Lesson Objectives

By the end of this lesson, students should be able to:

  • Explain the MCP notification model and when to use it
  • Implement resource change notifications in a server
  • Implement tool list change notifications
  • Design a server that uses notifications appropriately vs. on-demand tool calls

Lesson Content

What notifications are.

MCP notifications are server-to-client messages that do not require a response. They inform the client that something has changed – a resource has been updated, the tool list has changed, a long-running operation has progressed. Clients can act on notifications or ignore them based on their implementation.

When to use notifications vs. polling.

Without notifications, clients poll the server for changes – sending list_resources or list_tools requests periodically to check for updates. For resources that change infrequently, polling wastes transport overhead. For resources that change frequently, polling may miss changes between intervals.

Notifications are appropriate when:

  • Resources change at irregular intervals that polling cannot efficiently cover
  • Tool availability changes dynamically (a tool becomes available or unavailable at runtime)
  • A long-running tool call should report progress before completing

Resource change notifications.

“`python

Notify client that a resource has changed

await app.notify_resource_updated("docs://api-reference")

Notify client that the resource list has changed

await app.notify_resources_list_changed() “`

Clients that receive a resource update notification can re-read the resource to get fresh content. Clients that receive a resource list changed notification can re-request the resource list.

Tool list change notifications.

“`python

Notify client that the available tools have changed

await app.notify_tools_list_changed() “`

Use this when your server dynamically enables or disables tools based on state – for example, a tool that is only available after the user has authenticated, or a tool that is disabled when a dependent service is unavailable.

Progress notifications for long-running tools.

For tools that take significant time (database migrations, large file processing, report generation), progress notifications let the client track status without the tool call blocking:

“`python

Send progress update during a long tool execution

await app.notify_progress(token, current=50, total=100) “`

Clients can surface progress to the user in real time. Verify current progress notification API at modelcontextprotocol.io.

Practical Example

A developer builds a document monitoring MCP server that watches a directory for file changes.

When a file changes, the server sends a resource update notification for that file's resource URI.

Claude Code (the client) re-reads the resource and has the current document content without the developer needing to manually refresh or re-prompt.

The notification-driven approach eliminates the need to restart Claude Code sessions when documents change during a work session.

Safety Notes

Notifications increase server-to-client traffic. For servers monitoring high-frequency data sources (stock ticks, sensor data, log streams), notification-per-change can flood the client. Implement notification debouncing or batching for high-frequency sources – emit one notification summarizing multiple changes rather than one notification per change.

Log in and enroll to access lesson quizzes.

Scroll to Top