Repository navigation
Accept omitted params per JSON-RPC 2.0 §4 - #106
Merged
Merged
Conversation
Per JSON-RPC 2.0 §4 the `params` member MAY be omitted. The dispatcher now normalizes an absent or null `params` to an empty object before running the endpoint codec, so parameterless methods are reachable from spec-compliant clients (e.g. MCP TypeScript SDK calling `tools/list`).
Push the empty-params default down from `MessageDispatcher` into
`RawMessage.toMessage`, so absent/null `params` is normalized to `{}`
as the JSON message is decoded. The dispatcher keeps its original
pattern match; the `None` branches are now only reachable via direct
programmatic construction.
Tests parse messages from raw JSON to exercise the wire-layer fix.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace `params: Option[Payload]` on `RequestMessage` and
`NotificationMessage` with `params: Payload`, introducing a
`Payload.Empty` (= `{}`) sentinel. The wire decoder normalizes
absent/null params to `Payload.Empty`; the encoder elides the field
when it equals `Payload.Empty` (per spec, omitted and empty-object
params are equivalent).
This removes the dead "Missing payload" branches from the dispatcher
and the wire-vs-programmatic construction inconsistency.
Binary-breaking: case class signatures changed.
ghostbuster91
marked this pull request as ready for review
May 27, 2026 12:04
kubukoz
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #104.
Problem
Per JSON-RPC 2.0 §4 the
paramsmember MAY be omitted. The dispatcherrejected any request whose
paramsfield was absent (ornull) with-32600 InvalidRequest "Missing payload", making spec-compliant clientsunable to call parameterless methods (e.g. the official MCP TypeScript
SDK calling
tools/list).Approach
Payload.Emptysentinel =Payload(Json.obj()).RequestMessage.params/NotificationMessage.paramschange fromOption[Payload]toPayload—Noneis no longer expressible.RawMessage.toMessagenormalizes an absent/null wireparamsto
Payload.Empty.RawMessage.fromelides theparamsfield on the wire when itequals
Payload.Empty(spec treats omitted and{}as equivalent).MessageDispatcherdrops the now-impossibleNonebranches —the pattern match shrinks from 6 cases to 4.
The earlier commits in this PR are intermediate iterations of the same
fix; happy to squash before merging.
Binary compatibility
This is a binary-breaking change to public case-class signatures
(
InputMessage.RequestMessage/NotificationMessage). MIMA isn'tconfigured with previous artifacts so CI won't catch it — worth calling
out in release notes / version bump.
Test plan
core/testandcore3/test—RawMessageSpeccovers wire-layerdecoding (omitted / null / notification) and serialization elision.
fs2/testandfs23/test— end-to-end tests viaFS2Channelparsing raw JSON for the three relevant shapes.
smithy4sTests/testandsmithy4sTests3/test— existing suitestill green.
scalafmtCheckAll.🤖 Generated with Claude Code