Skip to content

Normalize empty notification params to {} (PHP [] → JSON object) + typo fix#135

Closed
csfh wants to merge 3 commits intolaravel:mainfrom
modoterra:main
Closed

Normalize empty notification params to {} (PHP [] → JSON object) + typo fix#135
csfh wants to merge 3 commits intolaravel:mainfrom
modoterra:main

Conversation

@csfh
Copy link
Contributor

@csfh csfh commented Jan 25, 2026

Hello,

This PR fixes an interop issues caused by PHP JSON serialization, correctly, of [] (PHP empty array) into [] (JSON empty array). But MCP notifications expect params to be an object, even if it's empty.

Here is the link from the specification.

https://modelcontextprotocol.io/specification/2025-03-26/basic?utm_source=chatgpt.com#notifications

User benefits

  • Prevents empty notifications from being rejected due to shape (this is how I discovered this using the MCP Inspector)
  • Removes a subtle PHP-specific edge case for users implement MCP with Laravel.

Safety

  • This is safe because it only affects the empty case. Non-empty arrays (associative arrays) will be correctly serialized into objects as expected.

Tests

  • Added test confirmining that [] params pass.
  • Non-empty arrays are unaffected.

I had earlier on discovered a meaningless typo, that I did not intend to bring up, but since I am submitting a PR anyway I figured that would be okay to resolve.

Other options

I do see that the spec allows for params to be omitted entirely, but I consider that a larger and potentially more risky resolution.

{
  jsonrpc: "2.0";
  method: string;
  params?: {
    [key: string]: unknown;
  };
}

AI

I delegated the fix for this to GitHub Copilot. I have reviewed and verified the fix.

Copilot AI and others added 3 commits January 25, 2026 04:11
… 'primitive'

Co-authored-by: csfh <5760821+csfh@users.noreply.github.com>
…n-serialization

Fix JSON-RPC notification empty params serialization and typo.
@github-actions
Copy link

Thanks for submitting a PR!

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the relevant GitHub documentation. Additionally, GitHub doesn't allow maintainer permissions from organization accounts. Please resubmit this PR from a personal GitHub account with maintainer permissions enabled.

@github-actions github-actions bot closed this Jan 25, 2026
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.

2 participants