Skip to content

Fix handling of notifications/cancelled in MCP server #21

@ryanrozich

Description

@ryanrozich

Description

The MCP-GSuite server crashes when it receives a notifications/cancelled notification. This happens when a request times out (after approximately 10 seconds), and the client sends a cancellation notification that the server doesn't know how to handle.

Error from logs:

pydantic_core._pydantic_core.ValidationError: 5 validation errors for ClientNotification
ProgressNotification.method
  Input should be 'notifications/progress' [type=literal_error, input_value='notifications/cancelled', input_type=str]

Root Cause

The MCP library version 1.1.0 doesn't properly support the notifications/cancelled notification type, which is part of the MCP specification for request cancellation.

Solution

Upgrade to MCP library version 1.3.0 or later, which added support for request cancellation via notifications in PR modelcontextprotocol/python-sdk#167.

The PR specifically:

  • Adds support for request cancellation via notifications
  • Implements periodic cleanup of in-flight requests
  • Tracks request state throughout the lifecycle

This should resolve the validation errors when the server receives cancellation notifications, especially in cases where operations time out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions