Skip to content

Commit 8314b7c

Browse files
authored
Merge branch 'main' into main
2 parents df31e14 + 19a8c00 commit 8314b7c

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

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

Lines changed: 7 additions & 6 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
}
@@ -1064,8 +1064,8 @@ public UnsubscribeRequest(String uri) {
10641064
* The contents of a specific resource or sub-resource.
10651065
*/
10661066
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
1067-
@JsonSubTypes({ @JsonSubTypes.Type(value = TextResourceContents.class, name = "text"),
1068-
@JsonSubTypes.Type(value = BlobResourceContents.class, name = "blob") })
1067+
@JsonSubTypes({ @JsonSubTypes.Type(value = TextResourceContents.class),
1068+
@JsonSubTypes.Type(value = BlobResourceContents.class) })
10691069
public sealed interface ResourceContents extends Meta permits TextResourceContents, BlobResourceContents {
10701070

10711071
/**
@@ -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

@@ -2501,6 +2501,7 @@ public CompleteResult(CompleteCompletion completion) {
25012501
* @param hasMore Indicates whether there are additional completion options beyond
25022502
* those provided in the current response, even if the exact total is unknown
25032503
*/
2504+
@JsonInclude(JsonInclude.Include.ALWAYS)
25042505
public record CompleteCompletion( // @formatter:off
25052506
@JsonProperty("values") List<String> values,
25062507
@JsonProperty("total") Integer total,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.modelcontextprotocol.spec;
2+
3+
import io.modelcontextprotocol.json.McpJsonMapper;
4+
import org.junit.jupiter.api.Test;
5+
import java.io.IOException;
6+
import java.util.Collections;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
class CompleteCompletionSerializationTest {
10+
11+
@Test
12+
void codeCompletionSerialization() throws IOException {
13+
McpJsonMapper jsonMapper = McpJsonMapper.getDefault();
14+
McpSchema.CompleteResult.CompleteCompletion codeComplete = new McpSchema.CompleteResult.CompleteCompletion(
15+
Collections.emptyList(), 0, false);
16+
String json = jsonMapper.writeValueAsString(codeComplete);
17+
String expected = """
18+
{"values":[],"total":0,"hasMore":false}""";
19+
assertEquals(expected, json, json);
20+
21+
McpSchema.CompleteResult completeResult = new McpSchema.CompleteResult(codeComplete);
22+
json = jsonMapper.writeValueAsString(completeResult);
23+
expected = """
24+
{"completion":{"values":[],"total":0,"hasMore":false}}""";
25+
assertEquals(expected, json, json);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)