Skip to content

fix: handle notifications and batches for invalid sessions in Protocol - #88

Open
TomHAnderson wants to merge 1 commit into
php-mcp:mainfrom
TomHAnderson:fix/84-notification-invalid-session
Open

TomHAnderson wants to merge 1 commit into
php-mcp:mainfrom
TomHAnderson:fix/84-notification-invalid-session

Conversation

@TomHAnderson

Copy link
Copy Markdown

processMessage() read $message->id when the session was not found, which crashed with "Undefined property" for notifications (e.g. a client sending notifications/initialized with a stale Mcp-Session-Id). Notifications are now logged and ignored, and requests/batches use getId() for the error.

Fixes #84

Tests: I added two regression tests to ProtocolTest.php: one for a notification on an unknown session and one for a batch. All 30 tests in ProtocolTest pass.

Full suite: inside the sandbox, the HTTP integration tests can't connect to their local test servers. Outside the sandbox, they still failed on every run: 11 to 30 failures, with different tests failing each time.

Development notes:

composer lint on PHP 8.5.5 results in
Fixed 26 of 121 files in 1.058 seconds, 192.00 MB memory used

lint fixes not committed

processMessage() read $message->id when the session was not found, which
crashed with "Undefined property" for notifications (e.g. a client sending
notifications/initialized with a stale Mcp-Session-Id). Notifications are
now logged and ignored, and requests/batches use getId() for the error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined property Notification::$id at Protocol.php:123 → HTTP 500 when a client sends a JSON-RPC notification (dev-main)

1 participant