Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.modelcontextprotocol.spec;

import com.fasterxml.jackson.annotation.JsonCreator;
import io.modelcontextprotocol.spec.McpSchema.JSONRPCResponse.JSONRPCError;
import io.modelcontextprotocol.util.Assert;

Expand All @@ -22,6 +23,10 @@ public class McpError extends RuntimeException {

private JSONRPCError jsonRpcError;

/**
* Add @JsonCreator to make sure Jackson can deserialize it properly.
*/
@JsonCreator
public McpError(JSONRPCError jsonRpcError) {
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using @JsonCreator with a single-parameter constructor, it's recommended to explicitly annotate the constructor parameter with @JsonProperty to ensure reliable deserialization across different Jackson configurations. While the current code may work due to the -parameters compiler flag, adding @JsonProperty("jsonRpcError") to the constructor parameter would make the deserialization contract explicit and more robust.

This follows the pattern seen throughout the codebase where all record constructors explicitly use @JsonProperty annotations on their parameters (e.g., JSONRPCError in McpSchema.java:306-308).

Copilot uses AI. Check for mistakes.
super(jsonRpcError.message());
this.jsonRpcError = jsonRpcError;
Expand Down
Loading