Skip to content

Commit a63d32a

Browse files
authored
refactor: change int to Integer for optional numeric fields (#604)
Convert primitive int types to Integer wrapper class for: - JSONRPCError.code - CreateMessageRequest.maxTokens (including constructor and builder) This allows these fields to be nullable, properly representing optional parameters in the MCP protocol schema. Signed-off-by: Christian Tzolov <[email protected]>
1 parent 94a8b53 commit a63d32a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public record JSONRPCResponse( // @formatter:off
306306
@JsonInclude(JsonInclude.Include.NON_ABSENT)
307307
@JsonIgnoreProperties(ignoreUnknown = true)
308308
public record JSONRPCError( // @formatter:off
309-
@JsonProperty("code") int code,
309+
@JsonProperty("code") Integer code,
310310
@JsonProperty("message") String message,
311311
@JsonProperty("data") Object data) { // @formatter:on
312312
}
@@ -1822,14 +1822,14 @@ public record CreateMessageRequest( // @formatter:off
18221822
@JsonProperty("systemPrompt") String systemPrompt,
18231823
@JsonProperty("includeContext") ContextInclusionStrategy includeContext,
18241824
@JsonProperty("temperature") Double temperature,
1825-
@JsonProperty("maxTokens") int maxTokens,
1825+
@JsonProperty("maxTokens") Integer maxTokens,
18261826
@JsonProperty("stopSequences") List<String> stopSequences,
18271827
@JsonProperty("metadata") Map<String, Object> metadata,
18281828
@JsonProperty("_meta") Map<String, Object> meta) implements Request { // @formatter:on
18291829

18301830
// backwards compatibility constructor
18311831
public CreateMessageRequest(List<SamplingMessage> messages, ModelPreferences modelPreferences,
1832-
String systemPrompt, ContextInclusionStrategy includeContext, Double temperature, int maxTokens,
1832+
String systemPrompt, ContextInclusionStrategy includeContext, Double temperature, Integer maxTokens,
18331833
List<String> stopSequences, Map<String, Object> metadata) {
18341834
this(messages, modelPreferences, systemPrompt, includeContext, temperature, maxTokens, stopSequences,
18351835
metadata, null);
@@ -1859,7 +1859,7 @@ public static class Builder {
18591859

18601860
private Double temperature;
18611861

1862-
private int maxTokens;
1862+
private Integer maxTokens;
18631863

18641864
private List<String> stopSequences;
18651865

0 commit comments

Comments
 (0)